fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/pkg/fab/events/client/peerresolver/minblockheight Index | Files

package minblockheight

import "github.com/hyperledger/fabric-sdk-go/pkg/fab/events/client/peerresolver/minblockheight"

Index

Package Files

minblockheight.go opts.go

func NewResolver Uses

func NewResolver() peerresolver.Provider

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

func WithBlockHeightLagThreshold Uses

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 Uses

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.

type PeerResolver Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (p PeerResolver) SetBlockHeightLagThreshold(value int)

func (PeerResolver) SetFromBlock Uses

func (p PeerResolver) SetFromBlock(value uint64)

func (PeerResolver) SetLoadBalancePolicy Uses

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

func (PeerResolver) SetReconnectBlockHeightLagThreshold Uses

func (p PeerResolver) SetReconnectBlockHeightLagThreshold(value int)

func (PeerResolver) SetSnapshot Uses

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

func (*PeerResolver) ShouldDisconnect Uses

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

Package minblockheight imports 8 packages (graph) and is imported by 3 packages. Updated 2018-11-02. Refresh now. Tools for package owners.