peer

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: MIT Imports: 10 Imported by: 0

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 {
	// 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(peer *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) QueueMessage

func (p *Peer) QueueMessage(msg p2p.Message, doneChan chan<- struct{})

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