protocol

package
v0.0.0-...-d9e9b57 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CmdVersion     = "version"
	CmdGetAddr     = "getaddr"
	CmdAddr        = "addr"
	CmdGetBlocks   = "getblocks"
	CmdInv         = "inv"
	CmdGetData     = "getdata"
	CmdNotFound    = "notfound"
	CmdBlock       = "block"
	CmdTx          = "tx"
	CmdGetHeaders  = "getheaders"
	CmdHeaders     = "headers"
	CmdAlert       = "alert"
	CmdMemPool     = "mempool"
	CmdMerkleBlock = "merkleblock"
	CmdSendHeaders = "sendheaders"
)
View Source
const (
	InvTypeError = "ERROR"
	InvTypeTx    = "MSG_TX"
	InvTypeBlock = "MSG_BLOCK"
)

Map of service flags back to their constant names for pretty printing.

View Source
const MaxAddrPerMsg = 1000

MaxAddrPerMsg is the maximum number of addresses that can be in a single bitcoin addr message (MsgAddr).

View Source
const MaxBlocksPerMsg = 500

MaxBlocksPerMsg is the max number of block hashes allowed per message.

View Source
const (
	// MaxInvPerMsg is the maximum number of inventory vectors that can be in a single inv message.
	MaxInvPerMsg = 50000
)
View Source
const (
	// ProtocolVersion is the latest protocol version this package supports.
	ProtocolVersion uint32 = 10000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type InvInfo

type InvInfo struct {
	Type string     // Type of data
	Hash hashx.Hash // Hash of the data
}

func NewInvInfo

func NewInvInfo(typ string, hash hashx.Hash) *InvInfo

NewInvInfo returns a new InvVect using the provided type and hash.

type Message

type Message interface {
	Command() string
	GetFromAddr() string
	SetFromAddr(addr string)
}

Message is an interface that describes a message.

type MessageError

type MessageError struct {
	Func        string // Function name
	Description string // Human readable description of the issue
}

func (*MessageError) Error

func (e *MessageError) Error() string

Error satisfies the error interface and prints human-readable errors.

type MsgAddr

type MsgAddr struct {
	NetMessage
	AddrList []string
}

func NewMsgAddr

func NewMsgAddr() *MsgAddr

NewMsgAddr returns a new addr message

func (*MsgAddr) AddAddress

func (msg *MsgAddr) AddAddress(na string) error

AddAddress adds a known active peer to the message.

func (*MsgAddr) AddAddresses

func (msg *MsgAddr) AddAddresses(netAddrs ...string) error

AddAddresses adds multiple known active peers to the message.

func (*MsgAddr) ClearAddresses

func (msg *MsgAddr) ClearAddresses()

ClearAddresses removes all addresses from the message.

func (*MsgAddr) Command

func (msg *MsgAddr) Command() string

Command returns the protocol command string

type MsgBlock

type MsgBlock struct {
	NetMessage
	Block *chain.Block
}

func NewMsgBlock

func NewMsgBlock(block *chain.Block) *MsgBlock

func (*MsgBlock) Command

func (msg *MsgBlock) Command() string

type MsgGetAddr

type MsgGetAddr struct {
	NetMessage
}

func NewMsgGetAddr

func NewMsgGetAddr() *MsgGetAddr

NewMsgGetAddr returns a new getaddr message

func (*MsgGetAddr) Command

func (msg *MsgGetAddr) Command() string

Command returns the protocol command string

type MsgGetBlocks

type MsgGetBlocks struct {
	NetMessage
	HashStop hashx.Hash
}

func NewMsgGetBlocks

func NewMsgGetBlocks(hashStop hashx.Hash) *MsgGetBlocks

NewMsgGetBlocks returns a new getblocks message

func (*MsgGetBlocks) Command

func (msg *MsgGetBlocks) Command() string

type MsgGetData

type MsgGetData struct {
	NetMessage
	InvList []*InvInfo
}

func NewMsgGetData

func NewMsgGetData() *MsgGetData

func (*MsgGetData) AddInvInfo

func (msg *MsgGetData) AddInvInfo(iv *InvInfo) error

AddInvInfo adds an inventory to the message.

func (*MsgGetData) Command

func (msg *MsgGetData) Command() string

type MsgInv

type MsgInv struct {
	NetMessage
	InvList []*InvInfo
}

func NewMsgInv

func NewMsgInv() *MsgInv

func (*MsgInv) AddInvInfo

func (msg *MsgInv) AddInvInfo(iv *InvInfo) error

AddInvVect adds an inventory info to the message.

func (*MsgInv) Command

func (msg *MsgInv) Command() string

Command returns the protocol command string

type MsgTx

type MsgTx struct {
	NetMessage
	Tx *chain.Transaction
}

func NewMsgTx

func NewMsgTx(tx *chain.Transaction) *MsgTx

func (*MsgTx) Command

func (msg *MsgTx) Command() string

type MsgVersion

type MsgVersion struct {
	NetMessage
	ProtocolVersion int32

	// Time the message was generated.  This is encoded as an int64 on the wire.
	Timestamp time.Time

	// Last block Height seen by the generator of the version message.
	LastBlockHeight int32

	// Last block hash seen by the generator of the version message.
	LastBlockHash []byte

	// Last block prev hash seen by the generator of the version message.
	LastBlockPrevHash []byte
}

func NewMsgVersion

func NewMsgVersion(lastBlockHeight int32, lastBlockHash, lastBlockPrevHash []byte) *MsgVersion

func (*MsgVersion) Command

func (msg *MsgVersion) Command() string

Command returns the protocol command string

type NetMessage

type NetMessage struct {
	ProtocolVersion uint32
	AddrFrom        string
}

func (*NetMessage) GetFromAddr

func (m *NetMessage) GetFromAddr() string

func (*NetMessage) SetFromAddr

func (m *NetMessage) SetFromAddr(addr string)

Jump to

Keyboard shortcuts

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