peer

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidType    = new(InvalidTypeError)
	ErrAlreadyPending = new(AlreadyPendingError)
	ErrUnknown        = new(UnknownError)
)

Functions

This section is empty.

Types

type AlreadyPendingError

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

AlreadyPendingError is an error returned when a message is already pending and cannot be called more than once at a given time.

func (*AlreadyPendingError) Error

func (e *AlreadyPendingError) Error() string

Error returns the error string.

type InvalidTypeError

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

InvalidTypeError is an error returned when a message was received and was not of the expected type.

func (*InvalidTypeError) Error

func (e *InvalidTypeError) Error() string

Error returns the error string.

type Peer

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

func New

func New(network wire.BitcoinNet, id int, address string) (*Peer, error)

func (*Peer) Close

func (p *Peer) Close() error

func (*Peer) Connect

func (p *Peer) Connect(ctx context.Context) error

func (*Peer) FeeFilter

func (p *Peer) FeeFilter() (*wire.MsgFeeFilter, error)

func (*Peer) GetAddr

func (p *Peer) GetAddr(ctx context.Context) (any, error)

func (*Peer) GetBlock

func (p *Peer) GetBlock(ctx context.Context, blockHash *chainhash.Hash) (*wire.MsgBlock, error)

GetBlock sends a getheaders(hash) call, then a getdata(hash) call to the peer and returns the block.

func (*Peer) GetData

func (p *Peer) GetData(ctx context.Context, vector *wire.InvVect) (any, error)

func (*Peer) GetHeaders

func (p *Peer) GetHeaders(ctx context.Context, hashes []*chainhash.Hash, stop *chainhash.Hash) (*wire.MsgHeaders, error)

GetHeaders writes a getheaders message to the peer and returns the headers.

func (*Peer) GetTx

func (p *Peer) GetTx(ctx context.Context, txID *chainhash.Hash) (*wire.MsgTx, error)

GetTx writes a tx message to the peer and returns the response.

func (*Peer) HasService

func (p *Peer) HasService(f wire.ServiceFlag) bool

func (*Peer) IsConnected

func (p *Peer) IsConnected() bool

func (*Peer) MemPool

func (p *Peer) MemPool(ctx context.Context) (*wire.MsgInv, error)

MemPool writes a mempool message to the peer and returns the inv response.

func (*Peer) Ping

func (p *Peer) Ping(ctx context.Context, nonce uint64) (*wire.MsgPong, error)

Ping writes a ping message to the peer and returns the pong.

func (*Peer) Remote

func (p *Peer) Remote() (*wire.MsgVersion, error)

func (*Peer) String

func (p *Peer) String() string

type UnknownError

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

UnknownError is an error returned when the requested data cannot be found.

func (*UnknownError) Error

func (e *UnknownError) Error() string

Error returns the error string.

Directories

Path Synopsis
Package rawpeer provides low level access to a bitcoin p2p node.
Package rawpeer provides low level access to a bitcoin p2p node.

Jump to

Keyboard shortcuts

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