Documentation ¶
Index ¶
- Variables
- type DataPack
- type FetchRequest
- type FetchResult
- type LightPeer
- type Peer
- type PeerConnection
- type PeerDropFn
- type PeerSet
- func (ps *PeerSet) AllPeers() []PeerConnection
- func (ps *PeerSet) BodyIdlePeers() ([]PeerConnection, int)
- func (ps *PeerSet) HeaderIdlePeers() ([]PeerConnection, int)
- func (ps *PeerSet) Len() int
- func (ps *PeerSet) MedianRTT() time.Duration
- func (ps *PeerSet) NodeDataIdlePeers() ([]PeerConnection, int)
- func (ps *PeerSet) Peer(id string) PeerConnection
- func (ps *PeerSet) ReceiptIdlePeers() ([]PeerConnection, int)
- func (ps *PeerSet) Register(p PeerConnection) error
- func (ps *PeerSet) Reset()
- func (ps *PeerSet) SubscribeNewPeers(ch chan<- PeerConnection) event.Subscription
- func (ps *PeerSet) SubscribeNewPeersFast(ch chan<- interface{}) event.Subscription
- func (ps *PeerSet) SubscribePeerDrops(ch chan<- PeerConnection) event.Subscription
- func (ps *PeerSet) Unregister(id string) error
- type StateSyncInter
Constants ¶
This section is empty.
Variables ¶
var ( FsMinFullBlocks = uint64(16) // Number of blocks to retrieve fully even in fast sync ErrCancelStateFetch = errors.New("fast state data download canceled (requested)") )
Functions ¶
This section is empty.
Types ¶
type FetchRequest ¶
type FetchRequest struct { Peer PeerConnection // Peer to which the request was sent From uint64 // [eth/62] Requested chain element index (used for skeleton fills only) Fheaders []*types.Header // [eth/62] Requested headers, sorted by request order Time time.Time // Time when the request was made }
fetchRequest is a currently running data retrieval operation.
type FetchResult ¶
type FetchResult struct { Pending int // Number of data fetches still pending Hash common.Hash // Hash of the header to prevent recalculating Signs []*types.PbftSign Fheader *types.Header Infos types.CommitteeMembers Transactions types.Transactions Receipts types.Receipts }
fetchResult is a struct collecting partial results from data fetchers until all outstanding pieces complete and the result as a whole can be processed.
type LightPeer ¶
type LightPeer interface { Head() (common.Hash, *big.Int) RequestHeadersByHash(common.Hash, int, int, bool) error RequestHeadersByNumber(uint64, int, int, bool) error }
LightPeer encapsulates the methods required to synchronise with a remote light peer.
type Peer ¶
type Peer interface { LightPeer RequestBodies([]common.Hash, bool, uint32) error RequestReceipts([]common.Hash, bool) error RequestNodeData([]common.Hash, bool) error }
Peer encapsulates the methods required to synchronise with a remote full peer.
type PeerConnection ¶
type PeerConnection interface { BlockCapacity(targetRTT time.Duration) int FetchHeaders(from uint64, count int) error FetchBodies(request *FetchRequest) error FetchNodeData(hashes []common.Hash) error FetchReceipts(request *FetchRequest) error HeaderCapacity(targetRTT time.Duration) int Lacks(hash common.Hash) bool MarkLacking(hash common.Hash) NodeDataCapacity(targetRTT time.Duration) int ReceiptCapacity(targetRTT time.Duration) int Reset() SetBlocksIdle(delivered int) SetBodiesIdle(delivered int) SetHeadersIdle(delivered int) SetNodeDataIdle(delivered int) SetReceiptsIdle(delivered int) GetID() string GetHeaderIdle() int32 GetBlockIdle() int32 GetReceiptIdle() int32 GetStateIdle() int32 GetHeaderThroughput() float64 GetBlockThroughput() float64 GetReceiptThroughput() float64 GetStateThroughput() float64 SetHeaderThroughput(t float64) SetBlockThroughput(t float64) SetReceiptThroughput(t float64) SetStateThroughput(t float64) GetRtt() time.Duration // Request round trip time to track responsiveness (QoS) SetRtt(d time.Duration) GetHeaderStarted() time.Time GetBlockStarted() time.Time GetReceiptStarted() time.Time GetStateStarted() time.Time GetLock() *sync.RWMutex GetVersion() int // Eth protocol version number to switch strategies GetPeer() Peer SetPeer(Peer) GetLog() log.Logger }
type PeerDropFn ¶
peerDropFn is a callback type for dropping a peer detected as malicious.
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
peerSet represents the collection of active peer participating in the chain download procedure.
func NewPeerSet ¶
func NewPeerSet() *PeerSet
newPeerSet creates a new peer set top track the active download sources.
func (*PeerSet) AllPeers ¶
func (ps *PeerSet) AllPeers() []PeerConnection
AllPeers retrieves a flat list of all the peers within the set.
func (*PeerSet) BodyIdlePeers ¶
func (ps *PeerSet) BodyIdlePeers() ([]PeerConnection, int)
BodyIdlePeers retrieves a flat list of all the currently body-idle peers within the active peer set, ordered by their reputation.
func (*PeerSet) HeaderIdlePeers ¶
func (ps *PeerSet) HeaderIdlePeers() ([]PeerConnection, int)
HeaderIdlePeers retrieves a flat list of all the currently header-idle peers within the active peer set, ordered by their reputation.
func (*PeerSet) MedianRTT ¶
medianRTT returns the median RTT of the peerset, considering only the tuning peers if there are more peers available.
func (*PeerSet) NodeDataIdlePeers ¶
func (ps *PeerSet) NodeDataIdlePeers() ([]PeerConnection, int)
NodeDataIdlePeers retrieves a flat list of all the currently node-data-idle peers within the active peer set, ordered by their reputation.
func (*PeerSet) Peer ¶
func (ps *PeerSet) Peer(id string) PeerConnection
Peer retrieves the registered peer with the given id.
func (*PeerSet) ReceiptIdlePeers ¶
func (ps *PeerSet) ReceiptIdlePeers() ([]PeerConnection, int)
ReceiptIdlePeers retrieves a flat list of all the currently receipt-idle peers within the active peer set, ordered by their reputation.
func (*PeerSet) Register ¶
func (ps *PeerSet) Register(p PeerConnection) error
Register injects a new peer into the working set, or returns an error if the peer is already known.
The method also sets the starting throughput values of the new peer to the average of all existing peers, to give it a realistic chance of being used for data retrievals.
func (*PeerSet) Reset ¶
func (ps *PeerSet) Reset()
Reset iterates over the current peer set, and resets each of the known peers to prepare for a next batch of block retrieval.
func (*PeerSet) SubscribeNewPeers ¶
func (ps *PeerSet) SubscribeNewPeers(ch chan<- PeerConnection) event.Subscription
SubscribeNewPeers subscribes to peer arrival events.
func (*PeerSet) SubscribeNewPeersFast ¶
func (ps *PeerSet) SubscribeNewPeersFast(ch chan<- interface{}) event.Subscription
SubscribeNewPeers subscribes to peer arrival events.
func (*PeerSet) SubscribePeerDrops ¶
func (ps *PeerSet) SubscribePeerDrops(ch chan<- PeerConnection) event.Subscription
SubscribePeerDrops subscribes to peer departure events.
func (*PeerSet) Unregister ¶
Unregister removes a remote peer from the active set, disabling any further actions to/from that particular entity.