Documentation ¶
Index ¶
- Constants
- type Interface
- type Protocol
- func (bd *Protocol) AddRemotePeer(remote *RemotePeer)
- func (bd *Protocol) GetHeighestBlockNumberFromPeers() uint64
- func (bd *Protocol) GetNextPeer() (*RemotePeer, error)
- func (bd *Protocol) GetRemotePeers() []*RemotePeer
- func (bd *Protocol) RemoveRemotePeer(remote *RemotePeer)
- func (bd *Protocol) Reset()
- type RemotePeer
- func (rp *RemotePeer) CurrentHeight() uint64
- func (rp *RemotePeer) DownloadBlocksRange(ctx context.Context, request *messages.BlockDownloadRequestProto) (*messages.BlockDownloadResponseProto, error)
- func (rp *RemotePeer) GetHeight(ctx context.Context) (*messages.BlockchainHeightResponseProto, error)
- func (rp *RemotePeer) GetPeerID() peer.ID
Constants ¶
const BlockDownloaderProtocolID = "/ffg/block_downloader/1.0.0"
BlockDownloaderProtocolID represents the block downloader protocol version.
const BlockchainHeightProtocolID = "/ffg/blockchain_height/1.0.0"
BlockchainHeightProtocolID is the protocol which returns the blockchain height of a node.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { AddRemotePeer(remote *RemotePeer) RemoveRemotePeer(remote *RemotePeer) GetNextPeer() (*RemotePeer, error) Reset() GetRemotePeers() []*RemotePeer GetHeighestBlockNumberFromPeers() uint64 }
Interface defines the block download protocol functionality.
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol implements the block downloader functionality.
func (*Protocol) AddRemotePeer ¶
func (bd *Protocol) AddRemotePeer(remote *RemotePeer)
AddRemotePeer adds a remote peer.
func (*Protocol) GetHeighestBlockNumberFromPeers ¶
nolint:misspell GetHeighestBlockNumberFromPeers gets the heighest block number from peers.
func (*Protocol) GetNextPeer ¶
func (bd *Protocol) GetNextPeer() (*RemotePeer, error)
GetNextPeer returns next peer in a round robin way.
func (*Protocol) GetRemotePeers ¶
func (bd *Protocol) GetRemotePeers() []*RemotePeer
GetRemotePeers gets a list of remote peers.
func (*Protocol) RemoveRemotePeer ¶
func (bd *Protocol) RemoveRemotePeer(remote *RemotePeer)
RemoveRemotePeer remove a peer.
type RemotePeer ¶
type RemotePeer struct {
// contains filtered or unexported fields
}
RemotePeer represents a peer with blockchain height.
func NewRemotePeer ¶
NewRemotePeer creates a new remote peer.
func (*RemotePeer) CurrentHeight ¶
func (rp *RemotePeer) CurrentHeight() uint64
CurrentHeight returns the current height of the peer.
func (*RemotePeer) DownloadBlocksRange ¶
func (rp *RemotePeer) DownloadBlocksRange(ctx context.Context, request *messages.BlockDownloadRequestProto) (*messages.BlockDownloadResponseProto, error)
DownloadBlocksRange downloads a range of blocks
func (*RemotePeer) GetHeight ¶
func (rp *RemotePeer) GetHeight(ctx context.Context) (*messages.BlockchainHeightResponseProto, error)
GetHeight gets remote peers blockchain height.
func (*RemotePeer) GetPeerID ¶
func (rp *RemotePeer) GetPeerID() peer.ID
GetPeerID returns the peer id.