blockdownloader

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const BlockDownloaderProtocolID = "/ffg/block_downloader/1.0.0"

BlockDownloaderProtocolID represents the block downloader protocol version.

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

func New(bchain blockchain.Interface, h host.Host) (*Protocol, error)

New creates a block downloader protocol.

func (*Protocol) AddRemotePeer

func (bd *Protocol) AddRemotePeer(remote *RemotePeer)

AddRemotePeer adds a remote peer.

func (*Protocol) GetHeighestBlockNumberFromPeers

func (bd *Protocol) GetHeighestBlockNumberFromPeers() uint64

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.

func (*Protocol) Reset

func (bd *Protocol) Reset()

Reset the internals.

type RemotePeer

type RemotePeer struct {
	// contains filtered or unexported fields
}

RemotePeer represents a peer with blockchain height.

func NewRemotePeer

func NewRemotePeer(h host.Host, peer peer.ID) (*RemotePeer, error)

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

DownloadBlocksRange downloads a range of blocks

func (*RemotePeer) GetHeight

GetHeight gets remote peers blockchain height.

func (*RemotePeer) GetPeerID

func (rp *RemotePeer) GetPeerID() peer.ID

GetPeerID returns the peer id.

Jump to

Keyboard shortcuts

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