peer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 11 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func UseLogger

func UseLogger(logger elalog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using elalog.

Types

type Config

type Config struct {
	// OnVersion is invoked when a peer receives a version message.
	OnVersion func(*Peer, *msg.Version)

	// After send a blocks request message, this inventory message
	// will return with a bunch of block hashes, then you can use them
	// to request all the blocks by send data requests.
	OnInv func(*Peer, *msg.Inv)

	// This method will be invoked when a merkleblock and transactions
	// within it has been downloaded.
	OnBlock func(*Peer, *util.Block)

	// After sent a data request with invType TRANSACTION, a txn message will return through this method.
	// these transactions are matched to the bloom filter you have sent with the filterload message.
	OnTx func(*Peer, util.Transaction)

	// If the BLOCK or TRANSACTION requested by the data request message can not be found,
	// notfound message with requested data hash will return through this method.
	OnNotFound func(*Peer, *msg.NotFound)

	// If the submitted transaction was rejected, this message will return.
	OnReject func(*Peer, *msg.Reject)
}

Config is the struct to hold configuration options useful to Peer.

type Peer

type Peer struct {
	*peer.Peer
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(orgPeer *peer.Peer, cfg *Config) *Peer

func (*Peer) PushGetBlocksMsg

func (p *Peer) PushGetBlocksMsg(locator []*common.Uint256, stopHash *common.Uint256) error

PushGetBlocksMsg sends a getblocks message for the provided block locator and stop hash. It will ignore back-to-back duplicate requests.

This function is safe for concurrent access.

func (*Peer) StallClear

func (p *Peer) StallClear()

Jump to

Keyboard shortcuts

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