peer

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 12 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 Listeners

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

	// OnMemPool is invoked when a peer receives a mempool message.
	OnMemPool func(p *Peer, msg *msg.MemPool)

	// OnTx is invoked when a peer receives a tx message.
	OnTx func(p *Peer, msg *msg.Tx)

	// OnBlock is invoked when a peer receives a block message.
	OnBlock func(p *Peer, msg *msg.Block)

	// OnInv is invoked when a peer receives an inv message.
	OnInv func(p *Peer, msg *msg.Inv)

	// OnNotFound is invoked when a peer receives a notfound
	// message.
	OnNotFound func(p *Peer, msg *msg.NotFound)

	// OnGetData is invoked when a peer receives a getdata message.
	OnGetData func(p *Peer, msg *msg.GetData)

	// OnGetBlocks is invoked when a peer receives a getblocks
	// message.
	OnGetBlocks func(p *Peer, msg *msg.GetBlocks)

	// OnFilterAdd is invoked when a peer receives a filteradd message.
	OnFilterAdd func(p *Peer, msg *msg.FilterAdd)

	// OnFilterClear is invoked when a peer receives a filterclear
	// message.
	OnFilterClear func(p *Peer, msg *msg.FilterClear)

	// OnFilterLoad is invoked when a peer receives a filterload
	// message.
	OnFilterLoad func(p *Peer, msg *msg.FilterLoad)

	// OnTxFilterLoad is invoked when a peer receives a txfilter message.
	OnTxFilterLoad func(p *Peer, msg *msg.TxFilterLoad)

	// OnReject is invoked when a peer receives a reject message.
	OnReject func(p *Peer, msg *msg.Reject)

	// OnDAddr is invoked when a peer receives a daddr message.
	OnDAddr func(p *Peer, msg *msg.DAddr)
}

type Peer

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

func New

func New(orgPeer server.IPeer, listeners *Listeners) *Peer

func (*Peer) AddKnownInventory

func (p *Peer) AddKnownInventory(invVect *msg.InvVect)

AddKnownInventory adds the passed inventory to the cache of known inventory for the peer.

This function is safe for concurrent access.

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) PushRejectMsg

func (p *Peer) PushRejectMsg(command string, code msg.RejectCode, reason string, hash *common.Uint256, wait bool)

PushRejectMsg sends a reject message for the provided command, reject code, reject reason, and hash. The hash will only be used when the command is a tx or block and should be nil in other cases. The wait parameter will cause the function to block until the reject message has actually been sent.

This function is safe for concurrent access.

func (*Peer) QueueInventory

func (p *Peer) QueueInventory(invVect *msg.InvVect)

QueueInventory adds the passed inventory to the inventory send queue which might not be sent right away, rather it is trickled to the peer in batches. Inventory that the peer is already known to have is ignored.

This function is safe for concurrent access.

func (*Peer) RelayTxDisabled

func (p *Peer) RelayTxDisabled() bool

relayTxDisabled returns whether or not relaying of transactions for the given peer is disabled. It is safe for concurrent access.

func (*Peer) Services

func (p *Peer) Services() pact.ServiceFlag

Services returns the services flag of the remote peer.

This function is safe for concurrent access.

func (*Peer) SetDisableRelayTx

func (p *Peer) SetDisableRelayTx(disable bool)

setDisableRelayTx toggles relaying of transactions for the given peer. It is safe for concurrent access.

Jump to

Keyboard shortcuts

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