Documentation ¶
Index ¶
Constants ¶
const (
// Disable disables choosing by block height threshold meaning that any peer has a likelihood of being chosen
Disable = -1
)
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts ...coptions.Opt) options.PeerSorter
New returns a peer sorter that uses block height and the provided balancer to sort the peers. This sorter uses a block-height-lag-threshold property which is the number of blocks from the highest block of a group of peers that a peer can lag behind and still be considered to be up-to-date. These peers are sorted using the given Balancer. If a peer's block height falls behind this "lag" threshold then it will be demoted to a lower priority list of peers which will be sorted according to block height.
func WithBalancer ¶
WithBalancer sets the balancing strategy to load balance (sort) the peers.
func WithBlockHeightLagThreshold ¶
WithBlockHeightLagThreshold is the number of blocks from the highest block of a group of peers that a peer can lag behind and still be considered to be up-to-date. These peers are sorted using the given Balancer. If a peer's block height falls behind this "lag" threshold then it will be demoted to a lower priority list of peers which is sorted according to block height.
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) will be load-balanced using the provided balancer.
Types ¶
This section is empty.