Documentation ¶
Index ¶
- Constants
- Variables
- type BlockFetcher
- type FetcherPeer
- type Peer
- func (p *Peer) FetchBlocks(stage protocol.SyncStage, roundFrom uint64, roundTo uint64) error
- func (p *Peer) FetchNodeData(hashes []common.Hash) error
- func (p *Peer) FetchPkgs(stage protocol.SyncStage, hashes []common.Hash) error
- func (p *Peer) GetIdle() int32
- func (p *Peer) GetRtt() time.Duration
- func (p *Peer) GetThroughput() float64
- func (p *Peer) SetIdle(delivered int)
- func (p *Peer) SetIdleWithoutDelivered()
- func (p *Peer) SetRtt(rtt time.Duration)
- func (p *Peer) SetThroughput(throughput float64)
- type StateSync
Constants ¶
const ( States = 0 Blocks = 1 Pkgs = 2 )
Variables ¶
var ( MinBlockRoundFetch = 500 MaxBlockRoundFetch = 1000 // Amount of rounds of blocks to allow fetching per request MinStateFetch = 1 MaxStateFetch = 384 // Amount of node state values to allow fetching per request MinPkgsFetch = 1 MaxPkgsFetch = 500 // Amount of kpgs to allow fetching per request RttMaxEstimate = 60 * time.Second // Maximum Round-trip time to target for download requests QosConfidenceCap = 10 // Number of peers above which not to modify RTT confidence RttMinConfidence = 0.1 // Worse confidence factor in our estimated RTT value TtlScaling = 3 // Constant scaling factor for RTT -> TTL conversion TtlLimit = 90 * time.Second // Maximum TTL allowance to prevent reaching crazy timeouts BytesPerRound = 3 * 100 // Average bits of blocks per round BytesPerPkg = 10 * 1024 //Average bit of kpg )
Functions ¶
This section is empty.
Types ¶
type BlockFetcher ¶
type BlockFetcher struct {
// contains filtered or unexported fields
}
BlockFetcher schedules requests for fetching blocks according a given rounds range.
func StartFetchBlocks ¶
func StartFetchBlocks(roundFrom, roundTo uint64, peers map[string]FetcherPeer, dropPeerFn peerDropFn, autoStop bool, stage protocol.SyncStage, chain blockchain, blockCh chan *types.Block) *BlockFetcher
func (*BlockFetcher) DeliverData ¶
func (bf *BlockFetcher) DeliverData(id string, data interface{}, kind int) error
func (*BlockFetcher) Finish ¶
func (bf *BlockFetcher) Finish()
func (*BlockFetcher) Register ¶
func (bf *BlockFetcher) Register(peer FetcherPeer) error
func (*BlockFetcher) Wait ¶
func (bf *BlockFetcher) Wait() error
Wait blocks until the fetcher is done or canceled.
type FetcherPeer ¶
type Peer ¶
type Peer struct { FP FetcherPeer // Peer used to fetch data // contains filtered or unexported fields }
func (*Peer) FetchBlocks ¶
FetchBodies sends blocks range or a block hash retrieval request to the remote peer.
func (*Peer) FetchNodeData ¶
FetchNodeData sends a node state data retrieval request to the remote peer.
func (*Peer) GetThroughput ¶
func (*Peer) SetIdle ¶
SetNodeDataIdle sets the peer to idle, allowing it to execute new state trie data retrieval requests. Its estimated state retrieval throughput is updated with that measured just now.
func (*Peer) SetIdleWithoutDelivered ¶
func (p *Peer) SetIdleWithoutDelivered()
func (*Peer) SetThroughput ¶
type StateSync ¶
type StateSync struct {
// contains filtered or unexported fields
}
StateSync schedules requests for downloading a particular state trie defined by a given state root.
func SyncState ¶
func SyncState(peers map[string]FetcherPeer, dropPeerFn peerDropFn, root common.Hash, chaindb dbwrapper.Database) *StateSync
syncState starts downloading state with the given root Hash and peers.
func (*StateSync) Cancel ¶
func (f *StateSync) Cancel() error
Cancel cancels the fetcher and waits until it has shut down.
func (*StateSync) DeliverData ¶
deliverData injects a new batch of node state data received from a remote node.