minblockheight

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResolver

func NewResolver() peerresolver.Provider

NewResolver returns a new "min block height" peer resolver provider.

func WithBlockHeightLagThreshold

func WithBlockHeightLagThreshold(value int) options.Opt

WithBlockHeightLagThreshold sets the block height lag threshold. If a peer is lagging behind the most up-to-date peer by more than the given number of blocks then it will be excluded. If set to 0 then only the most up-to-date peers are considered. If set to -1 then all peers (regardless of block height) are considered for selection.

func WithReconnectBlockHeightThreshold

func WithReconnectBlockHeightThreshold(value int) options.Opt

WithReconnectBlockHeightThreshold indicates that the event client is to disconnect from the peer if the peer's block height falls too far behind the other peers. If the connected peer lags more than the given number of blocks then the client will disconnect from that peer and reconnect to another peer at a more acceptable block height. If set to 0 then this feature is disabled. NOTE: Setting this value too low may cause the event client to disconnect/reconnect too frequently, thereby affecting performance.

Types

type PeerResolver

type PeerResolver struct {
	// contains filtered or unexported fields
}

PeerResolver is a peer resolver that chooses the best peer according to a block height lag threshold. The maximum block height of all peers is determined and the peers whose block heights are under the maximum height but above a provided "lag" threshold are load balanced. The other peers are not considered.

func New

func New(dispatcher service.Dispatcher, context context.Client, channelID string, opts ...options.Opt) *PeerResolver

New returns a new "min block height" peer resolver.

func (*PeerResolver) Filter

func (r *PeerResolver) Filter(peers []fab.Peer) []fab.Peer

Filter returns the peers that are within a provided "lag" threshold from the highest block height of all peers.

func (*PeerResolver) Resolve

func (r *PeerResolver) Resolve(peers []fab.Peer) (fab.Peer, error)

Resolve returns the best peer according to a block height lag threshold. The maximum block height of all peers is determined and the peers that are within a provided "lag" threshold are load balanced.

func (PeerResolver) SetBlockHeightLagThreshold

func (p PeerResolver) SetBlockHeightLagThreshold(value int)

func (PeerResolver) SetFromBlock

func (p PeerResolver) SetFromBlock(value uint64)

func (PeerResolver) SetLoadBalancePolicy

func (p PeerResolver) SetLoadBalancePolicy(value lbp.LoadBalancePolicy)

func (PeerResolver) SetReconnectBlockHeightLagThreshold

func (p PeerResolver) SetReconnectBlockHeightLagThreshold(value int)

func (PeerResolver) SetSnapshot

func (p PeerResolver) SetSnapshot(value fab.EventSnapshot) error

func (*PeerResolver) ShouldDisconnect

func (r *PeerResolver) ShouldDisconnect(peers []fab.Peer, connectedPeer fab.Peer) bool

ShouldDisconnect checks the current peer's block height relative to the block heights of the other peers and disconnects the peer if the configured threshold is reached. Returns false if the block height is acceptable; true if the client should be disconnected from the peer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL