blockrelay

package
v0.6.4-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: ISC Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleRelayBlockRequests

func HandleRelayBlockRequests(context RelayBlockRequestsContext, incomingRoute *router.Route,
	outgoingRoute *router.Route, peer *peerpkg.Peer) error

HandleRelayBlockRequests listens to appmessage.MsgRequestRelayBlocks messages and sends their corresponding blocks to the requesting peer.

func HandleRelayInvs

func HandleRelayInvs(context RelayInvsContext, incomingRoute *router.Route, outgoingRoute *router.Route,
	peer *peerpkg.Peer) error

HandleRelayInvs listens to appmessage.MsgInvRelayBlock messages, requests their corresponding blocks if they are missing, adds them to the DAG and propagates them to the rest of the network.

Types

type RelayBlockRequestsContext

type RelayBlockRequestsContext interface {
	DAG() *blockdag.BlockDAG
}

RelayBlockRequestsContext is the interface for the context needed for the HandleRelayBlockRequests flow.

type RelayInvsContext

type RelayInvsContext interface {
	NetAdapter() *netadapter.NetAdapter
	DAG() *blockdag.BlockDAG
	OnNewBlock(block *util.Block) error
	SharedRequestedBlocks() *SharedRequestedBlocks
	StartIBDIfRequired()
	IsInIBD() bool
	Broadcast(message appmessage.Message) error
}

RelayInvsContext is the interface for the context needed for the HandleRelayInvs flow.

type SharedRequestedBlocks

type SharedRequestedBlocks struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SharedRequestedBlocks is a data structure that is shared between peers that holds the hashes of all the requested blocks to prevent redundant requests.

func NewSharedRequestedBlocks

func NewSharedRequestedBlocks() *SharedRequestedBlocks

NewSharedRequestedBlocks returns a new instance of SharedRequestedBlocks.

Jump to

Keyboard shortcuts

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