blockheightsorter

package
v0.0.0-...-b42ce27 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

func WithBalancer(value balancer.Balancer) options.Opt

WithBalancer sets the balancing strategy to load balance (sort) the peers.

func WithBlockHeightLagThreshold

func WithBlockHeightLagThreshold(value int) options.Opt

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.

Jump to

Keyboard shortcuts

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