Documentation ¶
Overview ¶
Package appmessage implements the kaspa appmessage protocol.
At a high level, this package provides support for marshalling and unmarshalling supported kaspa messages to and from the appmessage. This package does not deal with the specifics of message handling such as what to do when a message is received. This provides the caller with a high level of flexibility.
Kaspa Message Overview ¶
The kaspa protocol consists of exchanging messages between peers. Each message is preceded by a header which identifies information about it such as which kaspa network it is a part of, its type, how big it is, and a checksum to verify validity. All encoding and decoding of message headers is handled by this package.
To accomplish this, there is a generic interface for kaspa messages named Message which allows messages of any type to be read, written, or passed around through channels, functions, etc. In addition, concrete implementations of most of the currently supported kaspa messages are provided. For these supported messages, all of the details of marshalling and unmarshalling to and from the appmessage using kaspa encoding are handled so the caller doesn't have to concern themselves with the specifics.
Message Interaction ¶
The following provides a quick summary of how the kaspa messages are intended to interact with one another. As stated above, these interactions are not directly handled by this package.
The initial handshake consists of two peers sending each other a version message (MsgVersion) followed by responding with a verack message (MsgVerAck). Both peers use the information in the version message (MsgVersion) to negotiate things such as protocol version and supported services with each other. Once the initial handshake is complete, the following chart indicates message interactions in no particular order.
Peer A Sends Peer B Responds ---------------------------------------------------------------------------- getaddr message (MsgRequestAddresses) addr message (MsgAddresses) getblockinvs message (MsgGetBlockInvs) inv message (MsgInv) inv message (MsgInv) getdata message (MsgGetData) getdata message (MsgGetData) block message (MsgBlock) -or- tx message (MsgTx) -or- notfound message (MsgNotFound) ping message (MsgPing) pong message (MsgPong)
Common Parameters ¶
There are several common parameters that arise when using this package to read and write kaspa messages. The following sections provide a quick overview of these parameters so the next sections can build on them.
Protocol Version ¶
The protocol version should be negotiated with the remote peer at a higher level than this package via the version (MsgVersion) message exchange, however, this package provides the appmessage.ProtocolVersion constant which indicates the latest protocol version this package supports and is typically the value to use for all outbound connections before a potentially lower protocol version is negotiated.
Kaspa Network ¶
The kaspa network is a magic number which is used to identify the start of a message and which kaspa network the message applies to. This package provides the following constants:
appmessage.Mainnet appmessage.Testnet (Test network) appmessage.Simnet (Simulation test network) appmessage.Devnet (Development network)
Determining Message Type ¶
As discussed in the kaspa message overview section, this package reads and writes kaspa messages using a generic interface named Message. In order to determine the actual concrete type of the message, use a type switch or type assertion. An example of a type switch follows:
// Assumes msg is already a valid concrete message such as one created // via NewMsgVersion or read via ReadMessage. switch msg := msg.(type) { case *appmessage.MsgVersion: // The message is a pointer to a MsgVersion struct. fmt.Printf("Protocol version: %d", msg.ProtocolVersion) case *appmessage.MsgBlock: // The message is a pointer to a MsgBlock struct. fmt.Printf("Number of tx in block: %d", msg.Header.TxnCount) }
Reading Messages ¶
In order to unmarshall kaspa messages from the appmessage, use the ReadMessage function. It accepts any io.Reader, but typically this will be a net.Conn to a remote node running a kaspa peer. Example syntax is:
// Reads and validates the next kaspa message from conn using the // protocol version pver and the kaspa network kaspaNet. The returns // are a appmessage.Message, a []byte which contains the unmarshalled // raw payload, and a possible error. msg, rawPayload, err := appmessage.ReadMessage(conn, pver, kaspaNet) if err != nil { // Log and handle the error }
Writing Messages ¶
In order to marshall kaspa messages to the appmessage, use the WriteMessage function. It accepts any io.Writer, but typically this will be a net.Conn to a remote node running a kaspa peer. Example syntax to request addresses from a remote peer is:
// Create a new getaddr kaspa message. msg := appmessage.NewMsgRequestAddresses() // Writes a kaspa message msg to conn using the protocol version // pver, and the kaspa network kaspaNet. The return is a possible // error. err := appmessage.WriteMessage(conn, msg, pver, kaspaNet) if err != nil { // Log and handle the error }
Errors ¶
Errors returned by this package are either the raw errors provided by underlying calls to read/write from streams such as io.EOF, io.ErrUnexpectedEOF, and io.ErrShortWrite, or of type appmessage.MessageError. This allows the caller to differentiate between general IO errors and malformed messages through type assertions.
Index ¶
- Constants
- Variables
- func ReadElement(r io.Reader, element interface{}) error
- func ReadVarBytes(r io.Reader, pver uint32, maxAllowed uint32, fieldName string) ([]byte, error)
- func ReadVarInt(r io.Reader) (uint64, error)
- func ReadVarString(r io.Reader, pver uint32) (string, error)
- func ValidateUserAgent(userAgent string) error
- func VarIntSerializeSize(val uint64) int
- func WriteElement(w io.Writer, element interface{}) error
- func WriteTxOut(w io.Writer, pver uint32, version int32, to *TxOut) error
- func WriteVarBytes(w io.Writer, pver uint32, bytes []byte) error
- func WriteVarInt(w io.Writer, val uint64) error
- func WriteVarString(w io.Writer, str string) error
- type AcceptedBlock
- type AddPeerRequestMessage
- func (msg *AddPeerRequestMessage) Command() MessageCommand
- func (b *AddPeerRequestMessage) MessageNumber() uint64
- func (b *AddPeerRequestMessage) ReceivedAt() time.Time
- func (b *AddPeerRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *AddPeerRequestMessage) SetReceivedAt(receivedAt time.Time)
- type AddPeerResponseMessage
- func (msg *AddPeerResponseMessage) Command() MessageCommand
- func (b *AddPeerResponseMessage) MessageNumber() uint64
- func (b *AddPeerResponseMessage) ReceivedAt() time.Time
- func (b *AddPeerResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *AddPeerResponseMessage) SetReceivedAt(receivedAt time.Time)
- type BlockAddedNotificationMessage
- func (msg *BlockAddedNotificationMessage) Command() MessageCommand
- func (b *BlockAddedNotificationMessage) MessageNumber() uint64
- func (b *BlockAddedNotificationMessage) ReceivedAt() time.Time
- func (b *BlockAddedNotificationMessage) SetMessageNumber(messageNumber uint64)
- func (b *BlockAddedNotificationMessage) SetReceivedAt(receivedAt time.Time)
- type BlockHeader
- func (h *BlockHeader) BlockHash() *daghash.Hash
- func (h *BlockHeader) Deserialize(r io.Reader) error
- func (h *BlockHeader) IsGenesis() bool
- func (h *BlockHeader) KaspaDecode(r io.Reader, pver uint32) error
- func (h *BlockHeader) KaspaEncode(w io.Writer, pver uint32) error
- func (h *BlockHeader) NumParentBlocks() byte
- func (h *BlockHeader) Serialize(w io.Writer) error
- func (h *BlockHeader) SerializeSize() int
- type BlockVerboseData
- type ChainBlock
- type ChainChangedNotificationMessage
- func (msg *ChainChangedNotificationMessage) Command() MessageCommand
- func (b *ChainChangedNotificationMessage) MessageNumber() uint64
- func (b *ChainChangedNotificationMessage) ReceivedAt() time.Time
- func (b *ChainChangedNotificationMessage) SetMessageNumber(messageNumber uint64)
- func (b *ChainChangedNotificationMessage) SetReceivedAt(receivedAt time.Time)
- type FinalityConflictNotificationMessage
- func (msg *FinalityConflictNotificationMessage) Command() MessageCommand
- func (b *FinalityConflictNotificationMessage) MessageNumber() uint64
- func (b *FinalityConflictNotificationMessage) ReceivedAt() time.Time
- func (b *FinalityConflictNotificationMessage) SetMessageNumber(messageNumber uint64)
- func (b *FinalityConflictNotificationMessage) SetReceivedAt(receivedAt time.Time)
- type FinalityConflictResolvedNotificationMessage
- func (msg *FinalityConflictResolvedNotificationMessage) Command() MessageCommand
- func (b *FinalityConflictResolvedNotificationMessage) MessageNumber() uint64
- func (b *FinalityConflictResolvedNotificationMessage) ReceivedAt() time.Time
- func (b *FinalityConflictResolvedNotificationMessage) SetMessageNumber(messageNumber uint64)
- func (b *FinalityConflictResolvedNotificationMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockCountRequestMessage
- func (msg *GetBlockCountRequestMessage) Command() MessageCommand
- func (b *GetBlockCountRequestMessage) MessageNumber() uint64
- func (b *GetBlockCountRequestMessage) ReceivedAt() time.Time
- func (b *GetBlockCountRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockCountRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockCountResponseMessage
- func (msg *GetBlockCountResponseMessage) Command() MessageCommand
- func (b *GetBlockCountResponseMessage) MessageNumber() uint64
- func (b *GetBlockCountResponseMessage) ReceivedAt() time.Time
- func (b *GetBlockCountResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockCountResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockDAGInfoRequestMessage
- func (msg *GetBlockDAGInfoRequestMessage) Command() MessageCommand
- func (b *GetBlockDAGInfoRequestMessage) MessageNumber() uint64
- func (b *GetBlockDAGInfoRequestMessage) ReceivedAt() time.Time
- func (b *GetBlockDAGInfoRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockDAGInfoRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockDAGInfoResponseMessage
- func (msg *GetBlockDAGInfoResponseMessage) Command() MessageCommand
- func (b *GetBlockDAGInfoResponseMessage) MessageNumber() uint64
- func (b *GetBlockDAGInfoResponseMessage) ReceivedAt() time.Time
- func (b *GetBlockDAGInfoResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockDAGInfoResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockRequestMessage
- func (msg *GetBlockRequestMessage) Command() MessageCommand
- func (b *GetBlockRequestMessage) MessageNumber() uint64
- func (b *GetBlockRequestMessage) ReceivedAt() time.Time
- func (b *GetBlockRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockResponseMessage
- func (msg *GetBlockResponseMessage) Command() MessageCommand
- func (b *GetBlockResponseMessage) MessageNumber() uint64
- func (b *GetBlockResponseMessage) ReceivedAt() time.Time
- func (b *GetBlockResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockTemplateRequestMessage
- func (msg *GetBlockTemplateRequestMessage) Command() MessageCommand
- func (b *GetBlockTemplateRequestMessage) MessageNumber() uint64
- func (b *GetBlockTemplateRequestMessage) ReceivedAt() time.Time
- func (b *GetBlockTemplateRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockTemplateRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockTemplateResponseMessage
- func (msg *GetBlockTemplateResponseMessage) Command() MessageCommand
- func (b *GetBlockTemplateResponseMessage) MessageNumber() uint64
- func (b *GetBlockTemplateResponseMessage) ReceivedAt() time.Time
- func (b *GetBlockTemplateResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockTemplateResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlockTemplateTransactionMessage
- func (msg *GetBlockTemplateTransactionMessage) Command() MessageCommand
- func (b *GetBlockTemplateTransactionMessage) MessageNumber() uint64
- func (b *GetBlockTemplateTransactionMessage) ReceivedAt() time.Time
- func (b *GetBlockTemplateTransactionMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlockTemplateTransactionMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlocksRequestMessage
- func (msg *GetBlocksRequestMessage) Command() MessageCommand
- func (b *GetBlocksRequestMessage) MessageNumber() uint64
- func (b *GetBlocksRequestMessage) ReceivedAt() time.Time
- func (b *GetBlocksRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlocksRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetBlocksResponseMessage
- func (msg *GetBlocksResponseMessage) Command() MessageCommand
- func (b *GetBlocksResponseMessage) MessageNumber() uint64
- func (b *GetBlocksResponseMessage) ReceivedAt() time.Time
- func (b *GetBlocksResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetBlocksResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetChainFromBlockRequestMessage
- func (msg *GetChainFromBlockRequestMessage) Command() MessageCommand
- func (b *GetChainFromBlockRequestMessage) MessageNumber() uint64
- func (b *GetChainFromBlockRequestMessage) ReceivedAt() time.Time
- func (b *GetChainFromBlockRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetChainFromBlockRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetChainFromBlockResponseMessage
- func (msg *GetChainFromBlockResponseMessage) Command() MessageCommand
- func (b *GetChainFromBlockResponseMessage) MessageNumber() uint64
- func (b *GetChainFromBlockResponseMessage) ReceivedAt() time.Time
- func (b *GetChainFromBlockResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetChainFromBlockResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetConnectedPeerInfoMessage
- type GetConnectedPeerInfoRequestMessage
- func (msg *GetConnectedPeerInfoRequestMessage) Command() MessageCommand
- func (b *GetConnectedPeerInfoRequestMessage) MessageNumber() uint64
- func (b *GetConnectedPeerInfoRequestMessage) ReceivedAt() time.Time
- func (b *GetConnectedPeerInfoRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetConnectedPeerInfoRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetConnectedPeerInfoResponseMessage
- func (msg *GetConnectedPeerInfoResponseMessage) Command() MessageCommand
- func (b *GetConnectedPeerInfoResponseMessage) MessageNumber() uint64
- func (b *GetConnectedPeerInfoResponseMessage) ReceivedAt() time.Time
- func (b *GetConnectedPeerInfoResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetConnectedPeerInfoResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetCurrentNetworkRequestMessage
- func (msg *GetCurrentNetworkRequestMessage) Command() MessageCommand
- func (b *GetCurrentNetworkRequestMessage) MessageNumber() uint64
- func (b *GetCurrentNetworkRequestMessage) ReceivedAt() time.Time
- func (b *GetCurrentNetworkRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetCurrentNetworkRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetCurrentNetworkResponseMessage
- func (msg *GetCurrentNetworkResponseMessage) Command() MessageCommand
- func (b *GetCurrentNetworkResponseMessage) MessageNumber() uint64
- func (b *GetCurrentNetworkResponseMessage) ReceivedAt() time.Time
- func (b *GetCurrentNetworkResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetCurrentNetworkResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetMempoolEntryRequestMessage
- func (msg *GetMempoolEntryRequestMessage) Command() MessageCommand
- func (b *GetMempoolEntryRequestMessage) MessageNumber() uint64
- func (b *GetMempoolEntryRequestMessage) ReceivedAt() time.Time
- func (b *GetMempoolEntryRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetMempoolEntryRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetMempoolEntryResponseMessage
- func (msg *GetMempoolEntryResponseMessage) Command() MessageCommand
- func (b *GetMempoolEntryResponseMessage) MessageNumber() uint64
- func (b *GetMempoolEntryResponseMessage) ReceivedAt() time.Time
- func (b *GetMempoolEntryResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetMempoolEntryResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetPeerAddressesKnownAddressMessage
- type GetPeerAddressesRequestMessage
- func (msg *GetPeerAddressesRequestMessage) Command() MessageCommand
- func (b *GetPeerAddressesRequestMessage) MessageNumber() uint64
- func (b *GetPeerAddressesRequestMessage) ReceivedAt() time.Time
- func (b *GetPeerAddressesRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetPeerAddressesRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetPeerAddressesResponseMessage
- func (msg *GetPeerAddressesResponseMessage) Command() MessageCommand
- func (b *GetPeerAddressesResponseMessage) MessageNumber() uint64
- func (b *GetPeerAddressesResponseMessage) ReceivedAt() time.Time
- func (b *GetPeerAddressesResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetPeerAddressesResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetSelectedTipHashRequestMessage
- func (msg *GetSelectedTipHashRequestMessage) Command() MessageCommand
- func (b *GetSelectedTipHashRequestMessage) MessageNumber() uint64
- func (b *GetSelectedTipHashRequestMessage) ReceivedAt() time.Time
- func (b *GetSelectedTipHashRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetSelectedTipHashRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetSelectedTipHashResponseMessage
- func (msg *GetSelectedTipHashResponseMessage) Command() MessageCommand
- func (b *GetSelectedTipHashResponseMessage) MessageNumber() uint64
- func (b *GetSelectedTipHashResponseMessage) ReceivedAt() time.Time
- func (b *GetSelectedTipHashResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetSelectedTipHashResponseMessage) SetReceivedAt(receivedAt time.Time)
- type GetSubnetworkRequestMessage
- func (msg *GetSubnetworkRequestMessage) Command() MessageCommand
- func (b *GetSubnetworkRequestMessage) MessageNumber() uint64
- func (b *GetSubnetworkRequestMessage) ReceivedAt() time.Time
- func (b *GetSubnetworkRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetSubnetworkRequestMessage) SetReceivedAt(receivedAt time.Time)
- type GetSubnetworkResponseMessage
- func (msg *GetSubnetworkResponseMessage) Command() MessageCommand
- func (b *GetSubnetworkResponseMessage) MessageNumber() uint64
- func (b *GetSubnetworkResponseMessage) ReceivedAt() time.Time
- func (b *GetSubnetworkResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *GetSubnetworkResponseMessage) SetReceivedAt(receivedAt time.Time)
- type KaspaNet
- type Message
- type MessageCommand
- type MessageError
- type MsgAddresses
- func (msg *MsgAddresses) AddAddress(na *NetAddress) error
- func (msg *MsgAddresses) AddAddresses(netAddrs ...*NetAddress) error
- func (msg *MsgAddresses) ClearAddresses()
- func (msg *MsgAddresses) Command() MessageCommand
- func (b *MsgAddresses) MessageNumber() uint64
- func (b *MsgAddresses) ReceivedAt() time.Time
- func (b *MsgAddresses) SetMessageNumber(messageNumber uint64)
- func (b *MsgAddresses) SetReceivedAt(receivedAt time.Time)
- type MsgBlock
- func (msg *MsgBlock) AddTransaction(tx *MsgTx)
- func (msg *MsgBlock) BlockHash() *daghash.Hash
- func (msg *MsgBlock) ClearTransactions()
- func (msg *MsgBlock) Command() MessageCommand
- func (msg *MsgBlock) ConvertToPartial(subnetworkID *subnetworkid.SubnetworkID)
- func (msg *MsgBlock) Deserialize(r io.Reader) error
- func (msg *MsgBlock) DeserializeTxLoc(r *bytes.Buffer) ([]TxLoc, error)
- func (msg *MsgBlock) KaspaDecode(r io.Reader, pver uint32) error
- func (msg *MsgBlock) KaspaEncode(w io.Writer, pver uint32) error
- func (msg *MsgBlock) MaxPayloadLength(pver uint32) uint32
- func (b *MsgBlock) MessageNumber() uint64
- func (b *MsgBlock) ReceivedAt() time.Time
- func (msg *MsgBlock) Serialize(w io.Writer) error
- func (msg *MsgBlock) SerializeSize() int
- func (b *MsgBlock) SetMessageNumber(messageNumber uint64)
- func (b *MsgBlock) SetReceivedAt(receivedAt time.Time)
- type MsgBlockLocator
- type MsgDoneIBDBlocks
- type MsgIBDBlock
- func (msg *MsgIBDBlock) Command() MessageCommand
- func (msg *MsgIBDBlock) MaxPayloadLength(pver uint32) uint32
- func (b *MsgIBDBlock) MessageNumber() uint64
- func (b *MsgIBDBlock) ReceivedAt() time.Time
- func (b *MsgIBDBlock) SetMessageNumber(messageNumber uint64)
- func (b *MsgIBDBlock) SetReceivedAt(receivedAt time.Time)
- type MsgInvRelayBlock
- type MsgInvTransaction
- type MsgPing
- type MsgPong
- type MsgReject
- type MsgRequestAddresses
- type MsgRequestBlockLocator
- func (msg *MsgRequestBlockLocator) Command() MessageCommand
- func (b *MsgRequestBlockLocator) MessageNumber() uint64
- func (b *MsgRequestBlockLocator) ReceivedAt() time.Time
- func (b *MsgRequestBlockLocator) SetMessageNumber(messageNumber uint64)
- func (b *MsgRequestBlockLocator) SetReceivedAt(receivedAt time.Time)
- type MsgRequestIBDBlocks
- type MsgRequestNextIBDBlocks
- func (msg *MsgRequestNextIBDBlocks) Command() MessageCommand
- func (b *MsgRequestNextIBDBlocks) MessageNumber() uint64
- func (b *MsgRequestNextIBDBlocks) ReceivedAt() time.Time
- func (b *MsgRequestNextIBDBlocks) SetMessageNumber(messageNumber uint64)
- func (b *MsgRequestNextIBDBlocks) SetReceivedAt(receivedAt time.Time)
- type MsgRequestRelayBlocks
- func (msg *MsgRequestRelayBlocks) Command() MessageCommand
- func (b *MsgRequestRelayBlocks) MessageNumber() uint64
- func (b *MsgRequestRelayBlocks) ReceivedAt() time.Time
- func (b *MsgRequestRelayBlocks) SetMessageNumber(messageNumber uint64)
- func (b *MsgRequestRelayBlocks) SetReceivedAt(receivedAt time.Time)
- type MsgRequestSelectedTip
- func (msg *MsgRequestSelectedTip) Command() MessageCommand
- func (b *MsgRequestSelectedTip) MessageNumber() uint64
- func (b *MsgRequestSelectedTip) ReceivedAt() time.Time
- func (b *MsgRequestSelectedTip) SetMessageNumber(messageNumber uint64)
- func (b *MsgRequestSelectedTip) SetReceivedAt(receivedAt time.Time)
- type MsgRequestTransactions
- func (msg *MsgRequestTransactions) Command() MessageCommand
- func (b *MsgRequestTransactions) MessageNumber() uint64
- func (b *MsgRequestTransactions) ReceivedAt() time.Time
- func (b *MsgRequestTransactions) SetMessageNumber(messageNumber uint64)
- func (b *MsgRequestTransactions) SetReceivedAt(receivedAt time.Time)
- type MsgSelectedTip
- type MsgTransactionNotFound
- func (msg *MsgTransactionNotFound) Command() MessageCommand
- func (b *MsgTransactionNotFound) MessageNumber() uint64
- func (b *MsgTransactionNotFound) ReceivedAt() time.Time
- func (b *MsgTransactionNotFound) SetMessageNumber(messageNumber uint64)
- func (b *MsgTransactionNotFound) SetReceivedAt(receivedAt time.Time)
- type MsgTx
- func NewNativeMsgTx(version int32, txIn []*TxIn, txOut []*TxOut) *MsgTx
- func NewNativeMsgTxWithLocktime(version int32, txIn []*TxIn, txOut []*TxOut, locktime uint64) *MsgTx
- func NewRegistryMsgTx(version int32, txIn []*TxIn, txOut []*TxOut, gasLimit uint64) *MsgTx
- func NewSubnetworkMsgTx(version int32, txIn []*TxIn, txOut []*TxOut, ...) *MsgTx
- func (msg *MsgTx) AddTxIn(ti *TxIn)
- func (msg *MsgTx) AddTxOut(to *TxOut)
- func (msg *MsgTx) Command() MessageCommand
- func (msg *MsgTx) Copy() *MsgTx
- func (msg *MsgTx) Deserialize(r io.Reader) error
- func (msg *MsgTx) IsCoinBase() bool
- func (msg *MsgTx) IsSubnetworkCompatible(subnetworkID *subnetworkid.SubnetworkID) bool
- func (msg *MsgTx) KaspaDecode(r io.Reader, pver uint32) error
- func (msg *MsgTx) KaspaEncode(w io.Writer, pver uint32) error
- func (msg *MsgTx) MaxPayloadLength(pver uint32) uint32
- func (b *MsgTx) MessageNumber() uint64
- func (b *MsgTx) ReceivedAt() time.Time
- func (msg *MsgTx) ScriptPubKeyLocs() []int
- func (msg *MsgTx) Serialize(w io.Writer) error
- func (msg *MsgTx) SerializeSize() int
- func (b *MsgTx) SetMessageNumber(messageNumber uint64)
- func (b *MsgTx) SetReceivedAt(receivedAt time.Time)
- func (msg *MsgTx) TxHash() *daghash.Hash
- func (msg *MsgTx) TxID() *daghash.TxID
- type MsgVerAck
- type MsgVersion
- func (msg *MsgVersion) AddService(service ServiceFlag)
- func (msg *MsgVersion) AddUserAgent(name string, version string, comments ...string)
- func (msg *MsgVersion) Command() MessageCommand
- func (msg *MsgVersion) HasService(service ServiceFlag) bool
- func (b *MsgVersion) MessageNumber() uint64
- func (b *MsgVersion) ReceivedAt() time.Time
- func (b *MsgVersion) SetMessageNumber(messageNumber uint64)
- func (b *MsgVersion) SetReceivedAt(receivedAt time.Time)
- type NetAddress
- type NotifyBlockAddedRequestMessage
- func (msg *NotifyBlockAddedRequestMessage) Command() MessageCommand
- func (b *NotifyBlockAddedRequestMessage) MessageNumber() uint64
- func (b *NotifyBlockAddedRequestMessage) ReceivedAt() time.Time
- func (b *NotifyBlockAddedRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *NotifyBlockAddedRequestMessage) SetReceivedAt(receivedAt time.Time)
- type NotifyBlockAddedResponseMessage
- func (msg *NotifyBlockAddedResponseMessage) Command() MessageCommand
- func (b *NotifyBlockAddedResponseMessage) MessageNumber() uint64
- func (b *NotifyBlockAddedResponseMessage) ReceivedAt() time.Time
- func (b *NotifyBlockAddedResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *NotifyBlockAddedResponseMessage) SetReceivedAt(receivedAt time.Time)
- type NotifyChainChangedRequestMessage
- func (msg *NotifyChainChangedRequestMessage) Command() MessageCommand
- func (b *NotifyChainChangedRequestMessage) MessageNumber() uint64
- func (b *NotifyChainChangedRequestMessage) ReceivedAt() time.Time
- func (b *NotifyChainChangedRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *NotifyChainChangedRequestMessage) SetReceivedAt(receivedAt time.Time)
- type NotifyChainChangedResponseMessage
- func (msg *NotifyChainChangedResponseMessage) Command() MessageCommand
- func (b *NotifyChainChangedResponseMessage) MessageNumber() uint64
- func (b *NotifyChainChangedResponseMessage) ReceivedAt() time.Time
- func (b *NotifyChainChangedResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *NotifyChainChangedResponseMessage) SetReceivedAt(receivedAt time.Time)
- type NotifyFinalityConflictsRequestMessage
- func (msg *NotifyFinalityConflictsRequestMessage) Command() MessageCommand
- func (b *NotifyFinalityConflictsRequestMessage) MessageNumber() uint64
- func (b *NotifyFinalityConflictsRequestMessage) ReceivedAt() time.Time
- func (b *NotifyFinalityConflictsRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *NotifyFinalityConflictsRequestMessage) SetReceivedAt(receivedAt time.Time)
- type NotifyFinalityConflictsResponseMessage
- func (msg *NotifyFinalityConflictsResponseMessage) Command() MessageCommand
- func (b *NotifyFinalityConflictsResponseMessage) MessageNumber() uint64
- func (b *NotifyFinalityConflictsResponseMessage) ReceivedAt() time.Time
- func (b *NotifyFinalityConflictsResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *NotifyFinalityConflictsResponseMessage) SetReceivedAt(receivedAt time.Time)
- type Outpoint
- type RPCError
- type ResolveFinalityConflictRequestMessage
- func (msg *ResolveFinalityConflictRequestMessage) Command() MessageCommand
- func (b *ResolveFinalityConflictRequestMessage) MessageNumber() uint64
- func (b *ResolveFinalityConflictRequestMessage) ReceivedAt() time.Time
- func (b *ResolveFinalityConflictRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *ResolveFinalityConflictRequestMessage) SetReceivedAt(receivedAt time.Time)
- type ResolveFinalityConflictResponseMessage
- func (msg *ResolveFinalityConflictResponseMessage) Command() MessageCommand
- func (b *ResolveFinalityConflictResponseMessage) MessageNumber() uint64
- func (b *ResolveFinalityConflictResponseMessage) ReceivedAt() time.Time
- func (b *ResolveFinalityConflictResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *ResolveFinalityConflictResponseMessage) SetReceivedAt(receivedAt time.Time)
- type ScriptPubKeyResult
- type ScriptSig
- type ServiceFlag
- type SubmitBlockRequestMessage
- func (msg *SubmitBlockRequestMessage) Command() MessageCommand
- func (b *SubmitBlockRequestMessage) MessageNumber() uint64
- func (b *SubmitBlockRequestMessage) ReceivedAt() time.Time
- func (b *SubmitBlockRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *SubmitBlockRequestMessage) SetReceivedAt(receivedAt time.Time)
- type SubmitBlockResponseMessage
- func (msg *SubmitBlockResponseMessage) Command() MessageCommand
- func (b *SubmitBlockResponseMessage) MessageNumber() uint64
- func (b *SubmitBlockResponseMessage) ReceivedAt() time.Time
- func (b *SubmitBlockResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *SubmitBlockResponseMessage) SetReceivedAt(receivedAt time.Time)
- type SubmitTransactionRequestMessage
- func (msg *SubmitTransactionRequestMessage) Command() MessageCommand
- func (b *SubmitTransactionRequestMessage) MessageNumber() uint64
- func (b *SubmitTransactionRequestMessage) ReceivedAt() time.Time
- func (b *SubmitTransactionRequestMessage) SetMessageNumber(messageNumber uint64)
- func (b *SubmitTransactionRequestMessage) SetReceivedAt(receivedAt time.Time)
- type SubmitTransactionResponseMessage
- func (msg *SubmitTransactionResponseMessage) Command() MessageCommand
- func (b *SubmitTransactionResponseMessage) MessageNumber() uint64
- func (b *SubmitTransactionResponseMessage) ReceivedAt() time.Time
- func (b *SubmitTransactionResponseMessage) SetMessageNumber(messageNumber uint64)
- func (b *SubmitTransactionResponseMessage) SetReceivedAt(receivedAt time.Time)
- type TransactionVerboseData
- type TransactionVerboseInput
- type TransactionVerboseOutput
- type TxIn
- type TxLoc
- type TxOut
Constants ¶
const ( // TxVersion is the current latest supported transaction version. TxVersion = 1 // MaxTxInSequenceNum is the maximum sequence number the sequence field // of a transaction input can be. MaxTxInSequenceNum uint64 = math.MaxUint64 // MaxPrevOutIndex is the maximum index the index field of a previous // outpoint can be. MaxPrevOutIndex uint32 = 0xffffffff // SequenceLockTimeDisabled is a flag that if set on a transaction // input's sequence number, the sequence number will not be interpreted // as a relative locktime. SequenceLockTimeDisabled = 1 << 31 // SequenceLockTimeIsSeconds is a flag that if set on a transaction // input's sequence number, the relative locktime has units of 512 // seconds. SequenceLockTimeIsSeconds = 1 << 22 // SequenceLockTimeMask is a mask that extracts the relative locktime // when masked against the transaction input sequence number. SequenceLockTimeMask = 0x0000ffff // SequenceLockTimeGranularity is the defined time based granularity // for milliseconds-based relative time locks. When converting from milliseconds // to a sequence number, the value is right shifted by this amount, // therefore the granularity of relative time locks in 524288 or 2^19 // seconds. Enforced relative lock times are multiples of 524288 milliseconds. SequenceLockTimeGranularity = 19 // MinTxOutPayload is the minimum payload size for a transaction output. // Value 8 bytes + Varint for ScriptPubKey length 1 byte. MinTxOutPayload = 9 )
const ( // ProtocolVersion is the latest protocol version this package supports. ProtocolVersion uint32 = 1 // DefaultServices describes the default services that are supported by // the server. DefaultServices = SFNodeNetwork | SFNodeBloom | SFNodeCF )
const BaseBlockHeaderPayload = 25 + 3*(daghash.HashSize)
BaseBlockHeaderPayload is the base number of bytes a block header can be, not including the list of parent block headers. Version 4 bytes + Timestamp 8 bytes + Bits 4 bytes + Nonce 8 bytes + + NumParentBlocks 1 byte + HashMerkleRoot hash + + AcceptedIDMerkleRoot hash + UTXOCommitment hash. To get total size of block header len(ParentHashes) * daghash.HashSize should be added to this value
const MaxAddressesPerMsg = 1000
MaxAddressesPerMsg is the maximum number of addresses that can be in a single kaspa Addresses message (MsgAddresses).
const MaxBlockHeaderPayload = BaseBlockHeaderPayload + (MaxNumParentBlocks * daghash.HashSize)
MaxBlockHeaderPayload is the maximum number of bytes a block header can be. BaseBlockHeaderPayload + up to MaxNumParentBlocks hashes of parent blocks
const MaxBlockLocatorsPerMsg = 500
MaxBlockLocatorsPerMsg is the maximum number of block locator hashes allowed per message.
const MaxBlockParents = 10
MaxBlockParents is the maximum allowed number of parents for block.
const MaxInvPerMsg = 1 << 17
MaxInvPerMsg is the maximum number of inventory vectors that can be in any type of kaspa inv message.
const MaxInvPerRequestTransactionsMsg = MaxInvPerMsg
MaxInvPerRequestTransactionsMsg is the maximum number of hashes that can be in a single CmdInvTransaction message.
const MaxInvPerTxInvMsg = MaxInvPerMsg
MaxInvPerTxInvMsg is the maximum number of hashes that can be in a single CmdInvTransaction message.
const MaxMassAcceptedByBlock = 10000000
MaxMassAcceptedByBlock is the maximum total transaction mass a block may accept.
const MaxMassPerTx = MaxMassAcceptedByBlock / 2
MaxMassPerTx is the maximum total mass a transaction may have.
const MaxMessagePayload = 1024 * 1024 * 32 // 32MB
MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves.
const MaxNumParentBlocks = 255
MaxNumParentBlocks is the maximum number of parent blocks a block can reference. Currently set to 255 as the maximum number NumParentBlocks can be due to it being a byte
const MaxTxPerBlock = (MaxMassAcceptedByBlock / minTxPayload) + 1
MaxTxPerBlock is the maximum number of transactions that could possibly fit into a block.
const MaxUserAgentLen = 256
MaxUserAgentLen is the maximum allowed length for the user agent field in a version message (MsgVersion).
const MaxVarIntPayload = 9
MaxVarIntPayload is the maximum payload size for a variable length integer.
const MsgRequestRelayBlocksHashes = MaxInvPerMsg
MsgRequestRelayBlocksHashes is the maximum number of hashes that can be in a single RequestRelayBlocks message.
Variables ¶
var DefaultUserAgent = fmt.Sprintf("/kaspad:%s/", version.Version())
DefaultUserAgent for appmessage in the stack
var ProtocolMessageCommandToString = map[MessageCommand]string{ CmdVersion: "Version", CmdVerAck: "VerAck", CmdRequestAddresses: "RequestAddresses", CmdAddresses: "Addresses", CmdRequestIBDBlocks: "RequestBlocks", CmdBlock: "Block", CmdTx: "Tx", CmdPing: "Ping", CmdPong: "Pong", CmdRequestBlockLocator: "RequestBlockLocator", CmdBlockLocator: "BlockLocator", CmdSelectedTip: "SelectedTip", CmdRequestSelectedTip: "RequestSelectedTip", CmdInvRelayBlock: "InvRelayBlock", CmdRequestRelayBlocks: "RequestRelayBlocks", CmdInvTransaction: "InvTransaction", CmdRequestTransactions: "RequestTransactions", CmdIBDBlock: "IBDBlock", CmdRequestNextIBDBlocks: "RequestNextIBDBlocks", CmdDoneIBDBlocks: "DoneIBDBlocks", CmdTransactionNotFound: "TransactionNotFound", CmdReject: "Reject", }
ProtocolMessageCommandToString maps all MessageCommands to their string representation
var RPCMessageCommandToString = map[MessageCommand]string{ CmdGetCurrentNetworkRequestMessage: "GetCurrentNetworkRequest", CmdGetCurrentNetworkResponseMessage: "GetCurrentNetworkResponse", CmdSubmitBlockRequestMessage: "SubmitBlockRequest", CmdSubmitBlockResponseMessage: "SubmitBlockResponse", CmdGetBlockTemplateRequestMessage: "GetBlockTemplateRequest", CmdGetBlockTemplateResponseMessage: "GetBlockTemplateResponse", CmdGetBlockTemplateTransactionMessage: "CmdGetBlockTemplateTransaction", CmdNotifyBlockAddedRequestMessage: "NotifyBlockAddedRequest", CmdNotifyBlockAddedResponseMessage: "NotifyBlockAddedResponse", CmdBlockAddedNotificationMessage: "BlockAddedNotification", CmdGetPeerAddressesRequestMessage: "GetPeerAddressesRequest", CmdGetPeerAddressesResponseMessage: "GetPeerAddressesResponse", CmdGetSelectedTipHashRequestMessage: "GetSelectedTipHashRequest", CmdGetSelectedTipHashResponseMessage: "GetSelectedTipHashResponse", CmdGetMempoolEntryRequestMessage: "GetMempoolEntryRequest", CmdGetMempoolEntryResponseMessage: "GetMempoolEntryResponse", CmdGetConnectedPeerInfoRequestMessage: "GetConnectedPeerInfoRequest", CmdGetConnectedPeerInfoResponseMessage: "GetConnectedPeerInfoResponse", CmdAddPeerRequestMessage: "AddPeerRequest", CmdAddPeerResponseMessage: "AddPeerResponse", CmdSubmitTransactionRequestMessage: "SubmitTransactionRequest", CmdSubmitTransactionResponseMessage: "SubmitTransactionResponse", CmdNotifyChainChangedRequestMessage: "NotifyChainChangedRequest", CmdNotifyChainChangedResponseMessage: "NotifyChainChangedResponse", CmdChainChangedNotificationMessage: "ChainChangedNotification", CmdGetBlockRequestMessage: "GetBlockRequest", CmdGetBlockResponseMessage: "GetBlockResponse", CmdGetSubnetworkRequestMessage: "GetSubnetworkRequest", CmdGetSubnetworkResponseMessage: "GetSubnetworkResponse", CmdGetChainFromBlockRequestMessage: "GetChainFromBlockRequest", CmdGetChainFromBlockResponseMessage: "GetChainFromBlockResponse", CmdGetBlocksRequestMessage: "GetBlocksRequest", CmdGetBlocksResponseMessage: "GetBlocksResponse", CmdGetBlockCountRequestMessage: "GetBlockCountRequest", CmdGetBlockCountResponseMessage: "GetBlockCountResponse", CmdGetBlockDAGInfoRequestMessage: "GetBlockDAGInfoRequest", CmdGetBlockDAGInfoResponseMessage: "GetBlockDAGInfoResponse", CmdResolveFinalityConflictRequestMessage: "ResolveFinalityConflictRequest", CmdResolveFinalityConflictResponseMessage: "ResolveFinalityConflictResponse", CmdNotifyFinalityConflictsRequestMessage: "NotifyFinalityConflictsRequest", CmdNotifyFinalityConflictsResponseMessage: "NotifyFinalityConflictsResponse", CmdFinalityConflictNotificationMessage: "FinalityConflictNotification", CmdFinalityConflictResolvedNotificationMessage: "FinalityConflictResolvedNotification", }
RPCMessageCommandToString maps all MessageCommands to their string representation
Functions ¶
func ReadElement ¶
ReadElement reads the next sequence of bytes from r using little endian depending on the concrete type of element pointed to.
func ReadVarBytes ¶
ReadVarBytes reads a variable length byte array. A byte array is encoded as a varInt containing the length of the array followed by the bytes themselves. An error is returned if the length is greater than the passed maxAllowed parameter which helps protect against memory exhaustion attacks and forced panics through malformed messages. The fieldName parameter is only used for the error message so it provides more context in the error.
func ReadVarInt ¶
ReadVarInt reads a variable length integer from r and returns it as a uint64.
func ReadVarString ¶
ReadVarString reads a variable length string from r and returns it as a Go string. A variable length string is encoded as a variable length integer containing the length of the string followed by the bytes that represent the string itself. An error is returned if the length is greater than the maximum block payload size since it helps protect against memory exhaustion attacks and forced panics through malformed messages.
func ValidateUserAgent ¶
ValidateUserAgent checks userAgent length against MaxUserAgentLen
func VarIntSerializeSize ¶
VarIntSerializeSize returns the number of bytes it would take to serialize val as a variable length integer.
func WriteElement ¶
WriteElement writes the little endian representation of element to w.
func WriteTxOut ¶
WriteTxOut encodes to into the kaspa protocol encoding for a transaction output (TxOut) to w.
func WriteVarBytes ¶
WriteVarBytes serializes a variable length byte array to w as a varInt containing the number of bytes, followed by the bytes themselves.
func WriteVarInt ¶
WriteVarInt serializes val to w using a variable number of bytes depending on its value.
Types ¶
type AcceptedBlock ¶
AcceptedBlock represents a block accepted into the DAG
type AddPeerRequestMessage ¶
type AddPeerRequestMessage struct { Address string IsPermanent bool // contains filtered or unexported fields }
AddPeerRequestMessage is an appmessage corresponding to its respective RPC message
func NewAddPeerRequestMessage ¶
func NewAddPeerRequestMessage(address string, isPermanent bool) *AddPeerRequestMessage
NewAddPeerRequestMessage returns a instance of the message
func (*AddPeerRequestMessage) Command ¶
func (msg *AddPeerRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*AddPeerRequestMessage) MessageNumber ¶
func (b *AddPeerRequestMessage) MessageNumber() uint64
func (*AddPeerRequestMessage) ReceivedAt ¶
func (*AddPeerRequestMessage) SetMessageNumber ¶
func (b *AddPeerRequestMessage) SetMessageNumber(messageNumber uint64)
func (*AddPeerRequestMessage) SetReceivedAt ¶
type AddPeerResponseMessage ¶
type AddPeerResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
AddPeerResponseMessage is an appmessage corresponding to its respective RPC message
func NewAddPeerResponseMessage ¶
func NewAddPeerResponseMessage() *AddPeerResponseMessage
NewAddPeerResponseMessage returns a instance of the message
func (*AddPeerResponseMessage) Command ¶
func (msg *AddPeerResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*AddPeerResponseMessage) MessageNumber ¶
func (b *AddPeerResponseMessage) MessageNumber() uint64
func (*AddPeerResponseMessage) ReceivedAt ¶
func (*AddPeerResponseMessage) SetMessageNumber ¶
func (b *AddPeerResponseMessage) SetMessageNumber(messageNumber uint64)
func (*AddPeerResponseMessage) SetReceivedAt ¶
type BlockAddedNotificationMessage ¶
type BlockAddedNotificationMessage struct { Block *MsgBlock // contains filtered or unexported fields }
BlockAddedNotificationMessage is an appmessage corresponding to its respective RPC message
func NewBlockAddedNotificationMessage ¶
func NewBlockAddedNotificationMessage(block *MsgBlock) *BlockAddedNotificationMessage
NewBlockAddedNotificationMessage returns a instance of the message
func (*BlockAddedNotificationMessage) Command ¶
func (msg *BlockAddedNotificationMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*BlockAddedNotificationMessage) MessageNumber ¶
func (b *BlockAddedNotificationMessage) MessageNumber() uint64
func (*BlockAddedNotificationMessage) ReceivedAt ¶
func (*BlockAddedNotificationMessage) SetMessageNumber ¶
func (b *BlockAddedNotificationMessage) SetMessageNumber(messageNumber uint64)
func (*BlockAddedNotificationMessage) SetReceivedAt ¶
type BlockHeader ¶
type BlockHeader struct { // Version of the block. This is not the same as the protocol version. Version int32 // Hashes of the parent block headers in the blockDAG. ParentHashes []*daghash.Hash // HashMerkleRoot is the merkle tree reference to hash of all transactions for the block. HashMerkleRoot *daghash.Hash // AcceptedIDMerkleRoot is merkle tree reference to hash all transactions // accepted form the block.Blues AcceptedIDMerkleRoot *daghash.Hash // UTXOCommitment is an ECMH UTXO commitment to the block UTXO. UTXOCommitment *daghash.Hash // Time the block was created. Timestamp mstime.Time // Difficulty target for the block. Bits uint32 // Nonce used to generate the block. Nonce uint64 }
BlockHeader defines information about a block and is used in the kaspa block (MsgBlock) and headers (MsgHeader) messages.
func NewBlockHeader ¶
func NewBlockHeader(version int32, parentHashes []*daghash.Hash, hashMerkleRoot *daghash.Hash, acceptedIDMerkleRoot *daghash.Hash, utxoCommitment *daghash.Hash, bits uint32, nonce uint64) *BlockHeader
NewBlockHeader returns a new BlockHeader using the provided version, previous block hash, hash merkle root, accepted ID merkle root, difficulty bits, and nonce used to generate the block with defaults or calclulated values for the remaining fields.
func (*BlockHeader) BlockHash ¶
func (h *BlockHeader) BlockHash() *daghash.Hash
BlockHash computes the block identifier hash for the given block header.
func (*BlockHeader) Deserialize ¶
func (h *BlockHeader) Deserialize(r io.Reader) error
Deserialize decodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BlockHeader) IsGenesis ¶
func (h *BlockHeader) IsGenesis() bool
IsGenesis returns true iff this block is a genesis block
func (*BlockHeader) KaspaDecode ¶
func (h *BlockHeader) KaspaDecode(r io.Reader, pver uint32) error
KaspaDecode decodes r using the kaspa protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding block headers stored to disk, such as in a database, as opposed to decoding block headers from the appmessage.
func (*BlockHeader) KaspaEncode ¶
func (h *BlockHeader) KaspaEncode(w io.Writer, pver uint32) error
KaspaEncode encodes the receiver to w using the kaspa protocol encoding. This is part of the Message interface implementation. See Serialize for encoding block headers to be stored to disk, such as in a database, as opposed to encoding block headers for the appmessage.
func (*BlockHeader) NumParentBlocks ¶
func (h *BlockHeader) NumParentBlocks() byte
NumParentBlocks return the number of entries in ParentHashes
func (*BlockHeader) Serialize ¶
func (h *BlockHeader) Serialize(w io.Writer) error
Serialize encodes a block header from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field.
func (*BlockHeader) SerializeSize ¶
func (h *BlockHeader) SerializeSize() int
SerializeSize returns the number of bytes it would take to serialize the block header.
type BlockVerboseData ¶
type BlockVerboseData struct { Hash string Confirmations uint64 Size int32 BlueScore uint64 IsChainBlock bool Version int32 VersionHex string HashMerkleRoot string AcceptedIDMerkleRoot string UTXOCommitment string TxIDs []string TransactionVerboseData []*TransactionVerboseData Time int64 Nonce uint64 Bits string Difficulty float64 ParentHashes []string SelectedParentHash string ChildHashes []string AcceptedBlockHashes []string }
BlockVerboseData holds verbose data about a block
type ChainBlock ¶
type ChainBlock struct { Hash string AcceptedBlocks []*AcceptedBlock }
ChainBlock represents a DAG chain-block
type ChainChangedNotificationMessage ¶
type ChainChangedNotificationMessage struct { RemovedChainBlockHashes []string AddedChainBlocks []*ChainBlock // contains filtered or unexported fields }
ChainChangedNotificationMessage is an appmessage corresponding to its respective RPC message
func NewChainChangedNotificationMessage ¶
func NewChainChangedNotificationMessage(removedChainBlockHashes []string, addedChainBlocks []*ChainBlock) *ChainChangedNotificationMessage
NewChainChangedNotificationMessage returns a instance of the message
func (*ChainChangedNotificationMessage) Command ¶
func (msg *ChainChangedNotificationMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*ChainChangedNotificationMessage) MessageNumber ¶
func (b *ChainChangedNotificationMessage) MessageNumber() uint64
func (*ChainChangedNotificationMessage) ReceivedAt ¶
func (*ChainChangedNotificationMessage) SetMessageNumber ¶
func (b *ChainChangedNotificationMessage) SetMessageNumber(messageNumber uint64)
func (*ChainChangedNotificationMessage) SetReceivedAt ¶
type FinalityConflictNotificationMessage ¶
type FinalityConflictNotificationMessage struct { ViolatingBlockHash string // contains filtered or unexported fields }
FinalityConflictNotificationMessage is an appmessage corresponding to its respective RPC message
func NewFinalityConflictNotificationMessage ¶
func NewFinalityConflictNotificationMessage(violatingBlockHash string) *FinalityConflictNotificationMessage
NewFinalityConflictNotificationMessage returns a instance of the message
func (*FinalityConflictNotificationMessage) Command ¶
func (msg *FinalityConflictNotificationMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*FinalityConflictNotificationMessage) MessageNumber ¶
func (b *FinalityConflictNotificationMessage) MessageNumber() uint64
func (*FinalityConflictNotificationMessage) ReceivedAt ¶
func (*FinalityConflictNotificationMessage) SetMessageNumber ¶
func (b *FinalityConflictNotificationMessage) SetMessageNumber(messageNumber uint64)
func (*FinalityConflictNotificationMessage) SetReceivedAt ¶
type FinalityConflictResolvedNotificationMessage ¶
type FinalityConflictResolvedNotificationMessage struct { FinalityBlockHash string // contains filtered or unexported fields }
FinalityConflictResolvedNotificationMessage is an appmessage corresponding to its respective RPC message
func NewFinalityConflictResolvedNotificationMessage ¶
func NewFinalityConflictResolvedNotificationMessage(finalityBlockHash string) *FinalityConflictResolvedNotificationMessage
NewFinalityConflictResolvedNotificationMessage returns a instance of the message
func (*FinalityConflictResolvedNotificationMessage) Command ¶
func (msg *FinalityConflictResolvedNotificationMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*FinalityConflictResolvedNotificationMessage) MessageNumber ¶
func (b *FinalityConflictResolvedNotificationMessage) MessageNumber() uint64
func (*FinalityConflictResolvedNotificationMessage) ReceivedAt ¶
func (*FinalityConflictResolvedNotificationMessage) SetMessageNumber ¶
func (b *FinalityConflictResolvedNotificationMessage) SetMessageNumber(messageNumber uint64)
func (*FinalityConflictResolvedNotificationMessage) SetReceivedAt ¶
type GetBlockCountRequestMessage ¶
type GetBlockCountRequestMessage struct {
// contains filtered or unexported fields
}
GetBlockCountRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockCountRequestMessage ¶
func NewGetBlockCountRequestMessage() *GetBlockCountRequestMessage
NewGetBlockCountRequestMessage returns a instance of the message
func (*GetBlockCountRequestMessage) Command ¶
func (msg *GetBlockCountRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockCountRequestMessage) MessageNumber ¶
func (b *GetBlockCountRequestMessage) MessageNumber() uint64
func (*GetBlockCountRequestMessage) ReceivedAt ¶
func (*GetBlockCountRequestMessage) SetMessageNumber ¶
func (b *GetBlockCountRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockCountRequestMessage) SetReceivedAt ¶
type GetBlockCountResponseMessage ¶
type GetBlockCountResponseMessage struct { BlockCount uint64 Error *RPCError // contains filtered or unexported fields }
GetBlockCountResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockCountResponseMessage ¶
func NewGetBlockCountResponseMessage(blockCount uint64) *GetBlockCountResponseMessage
NewGetBlockCountResponseMessage returns a instance of the message
func (*GetBlockCountResponseMessage) Command ¶
func (msg *GetBlockCountResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockCountResponseMessage) MessageNumber ¶
func (b *GetBlockCountResponseMessage) MessageNumber() uint64
func (*GetBlockCountResponseMessage) ReceivedAt ¶
func (*GetBlockCountResponseMessage) SetMessageNumber ¶
func (b *GetBlockCountResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockCountResponseMessage) SetReceivedAt ¶
type GetBlockDAGInfoRequestMessage ¶
type GetBlockDAGInfoRequestMessage struct {
// contains filtered or unexported fields
}
GetBlockDAGInfoRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockDAGInfoRequestMessage ¶
func NewGetBlockDAGInfoRequestMessage() *GetBlockDAGInfoRequestMessage
NewGetBlockDAGInfoRequestMessage returns a instance of the message
func (*GetBlockDAGInfoRequestMessage) Command ¶
func (msg *GetBlockDAGInfoRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockDAGInfoRequestMessage) MessageNumber ¶
func (b *GetBlockDAGInfoRequestMessage) MessageNumber() uint64
func (*GetBlockDAGInfoRequestMessage) ReceivedAt ¶
func (*GetBlockDAGInfoRequestMessage) SetMessageNumber ¶
func (b *GetBlockDAGInfoRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockDAGInfoRequestMessage) SetReceivedAt ¶
type GetBlockDAGInfoResponseMessage ¶
type GetBlockDAGInfoResponseMessage struct { NetworkName string BlockCount uint64 TipHashes []string VirtualParentHashes []string Difficulty float64 PastMedianTime int64 Error *RPCError // contains filtered or unexported fields }
GetBlockDAGInfoResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockDAGInfoResponseMessage ¶
func NewGetBlockDAGInfoResponseMessage() *GetBlockDAGInfoResponseMessage
NewGetBlockDAGInfoResponseMessage returns a instance of the message
func (*GetBlockDAGInfoResponseMessage) Command ¶
func (msg *GetBlockDAGInfoResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockDAGInfoResponseMessage) MessageNumber ¶
func (b *GetBlockDAGInfoResponseMessage) MessageNumber() uint64
func (*GetBlockDAGInfoResponseMessage) ReceivedAt ¶
func (*GetBlockDAGInfoResponseMessage) SetMessageNumber ¶
func (b *GetBlockDAGInfoResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockDAGInfoResponseMessage) SetReceivedAt ¶
type GetBlockRequestMessage ¶
type GetBlockRequestMessage struct { Hash string SubnetworkID string IncludeBlockHex bool IncludeBlockVerboseData bool IncludeTransactionVerboseData bool // contains filtered or unexported fields }
GetBlockRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockRequestMessage ¶
func NewGetBlockRequestMessage(hash string, subnetworkID string, includeBlockHex bool, includeBlockVerboseData bool, includeTransactionVerboseData bool) *GetBlockRequestMessage
NewGetBlockRequestMessage returns a instance of the message
func (*GetBlockRequestMessage) Command ¶
func (msg *GetBlockRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockRequestMessage) MessageNumber ¶
func (b *GetBlockRequestMessage) MessageNumber() uint64
func (*GetBlockRequestMessage) ReceivedAt ¶
func (*GetBlockRequestMessage) SetMessageNumber ¶
func (b *GetBlockRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockRequestMessage) SetReceivedAt ¶
type GetBlockResponseMessage ¶
type GetBlockResponseMessage struct { BlockHex string BlockVerboseData *BlockVerboseData Error *RPCError // contains filtered or unexported fields }
GetBlockResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockResponseMessage ¶
func NewGetBlockResponseMessage() *GetBlockResponseMessage
NewGetBlockResponseMessage returns a instance of the message
func (*GetBlockResponseMessage) Command ¶
func (msg *GetBlockResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockResponseMessage) MessageNumber ¶
func (b *GetBlockResponseMessage) MessageNumber() uint64
func (*GetBlockResponseMessage) ReceivedAt ¶
func (*GetBlockResponseMessage) SetMessageNumber ¶
func (b *GetBlockResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockResponseMessage) SetReceivedAt ¶
type GetBlockTemplateRequestMessage ¶
type GetBlockTemplateRequestMessage struct { PayAddress string LongPollID string // contains filtered or unexported fields }
GetBlockTemplateRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockTemplateRequestMessage ¶
func NewGetBlockTemplateRequestMessage(payAddress string, longPollID string) *GetBlockTemplateRequestMessage
NewGetBlockTemplateRequestMessage returns a instance of the message
func (*GetBlockTemplateRequestMessage) Command ¶
func (msg *GetBlockTemplateRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockTemplateRequestMessage) MessageNumber ¶
func (b *GetBlockTemplateRequestMessage) MessageNumber() uint64
func (*GetBlockTemplateRequestMessage) ReceivedAt ¶
func (*GetBlockTemplateRequestMessage) SetMessageNumber ¶
func (b *GetBlockTemplateRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockTemplateRequestMessage) SetReceivedAt ¶
type GetBlockTemplateResponseMessage ¶
type GetBlockTemplateResponseMessage struct { Bits string CurrentTime int64 ParentHashes []string MassLimit int Transactions []GetBlockTemplateTransactionMessage HashMerkleRoot string AcceptedIDMerkleRoot string UTXOCommitment string Version int32 LongPollID string TargetDifficulty string MinTime int64 MaxTime int64 MutableFields []string NonceRange string IsSynced bool IsConnected bool Error *RPCError // contains filtered or unexported fields }
GetBlockTemplateResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockTemplateResponseMessage ¶
func NewGetBlockTemplateResponseMessage() *GetBlockTemplateResponseMessage
NewGetBlockTemplateResponseMessage returns a instance of the message
func (*GetBlockTemplateResponseMessage) Command ¶
func (msg *GetBlockTemplateResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockTemplateResponseMessage) MessageNumber ¶
func (b *GetBlockTemplateResponseMessage) MessageNumber() uint64
func (*GetBlockTemplateResponseMessage) ReceivedAt ¶
func (*GetBlockTemplateResponseMessage) SetMessageNumber ¶
func (b *GetBlockTemplateResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockTemplateResponseMessage) SetReceivedAt ¶
type GetBlockTemplateTransactionMessage ¶
type GetBlockTemplateTransactionMessage struct { Data string ID string Depends []int64 Mass uint64 Fee uint64 // contains filtered or unexported fields }
GetBlockTemplateTransactionMessage is an appmessage corresponding to its respective RPC message
func NewGetBlockTemplateTransactionMessage ¶
func NewGetBlockTemplateTransactionMessage() *GetBlockTemplateTransactionMessage
NewGetBlockTemplateTransactionMessage returns a instance of the message
func (*GetBlockTemplateTransactionMessage) Command ¶
func (msg *GetBlockTemplateTransactionMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlockTemplateTransactionMessage) MessageNumber ¶
func (b *GetBlockTemplateTransactionMessage) MessageNumber() uint64
func (*GetBlockTemplateTransactionMessage) ReceivedAt ¶
func (*GetBlockTemplateTransactionMessage) SetMessageNumber ¶
func (b *GetBlockTemplateTransactionMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlockTemplateTransactionMessage) SetReceivedAt ¶
type GetBlocksRequestMessage ¶
type GetBlocksRequestMessage struct { LowHash string IncludeBlockHexes bool IncludeBlockVerboseData bool // contains filtered or unexported fields }
GetBlocksRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetBlocksRequestMessage ¶
func NewGetBlocksRequestMessage(lowHash string, includeBlockHexes bool, includeBlockVerboseData bool) *GetBlocksRequestMessage
NewGetBlocksRequestMessage returns a instance of the message
func (*GetBlocksRequestMessage) Command ¶
func (msg *GetBlocksRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlocksRequestMessage) MessageNumber ¶
func (b *GetBlocksRequestMessage) MessageNumber() uint64
func (*GetBlocksRequestMessage) ReceivedAt ¶
func (*GetBlocksRequestMessage) SetMessageNumber ¶
func (b *GetBlocksRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlocksRequestMessage) SetReceivedAt ¶
type GetBlocksResponseMessage ¶
type GetBlocksResponseMessage struct { BlockHashes []string BlockHexes []string BlockVerboseData []*BlockVerboseData Error *RPCError // contains filtered or unexported fields }
GetBlocksResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetBlocksResponseMessage ¶
func NewGetBlocksResponseMessage(blockHashes []string, blockHexes []string, blockVerboseData []*BlockVerboseData) *GetBlocksResponseMessage
NewGetBlocksResponseMessage returns a instance of the message
func (*GetBlocksResponseMessage) Command ¶
func (msg *GetBlocksResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetBlocksResponseMessage) MessageNumber ¶
func (b *GetBlocksResponseMessage) MessageNumber() uint64
func (*GetBlocksResponseMessage) ReceivedAt ¶
func (*GetBlocksResponseMessage) SetMessageNumber ¶
func (b *GetBlocksResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetBlocksResponseMessage) SetReceivedAt ¶
type GetChainFromBlockRequestMessage ¶
type GetChainFromBlockRequestMessage struct { StartHash string IncludeBlockVerboseData bool // contains filtered or unexported fields }
GetChainFromBlockRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetChainFromBlockRequestMessage ¶
func NewGetChainFromBlockRequestMessage(startHash string, includeBlockVerboseData bool) *GetChainFromBlockRequestMessage
NewGetChainFromBlockRequestMessage returns a instance of the message
func (*GetChainFromBlockRequestMessage) Command ¶
func (msg *GetChainFromBlockRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetChainFromBlockRequestMessage) MessageNumber ¶
func (b *GetChainFromBlockRequestMessage) MessageNumber() uint64
func (*GetChainFromBlockRequestMessage) ReceivedAt ¶
func (*GetChainFromBlockRequestMessage) SetMessageNumber ¶
func (b *GetChainFromBlockRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetChainFromBlockRequestMessage) SetReceivedAt ¶
type GetChainFromBlockResponseMessage ¶
type GetChainFromBlockResponseMessage struct { RemovedChainBlockHashes []string AddedChainBlocks []*ChainBlock BlockVerboseData []*BlockVerboseData Error *RPCError // contains filtered or unexported fields }
GetChainFromBlockResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetChainFromBlockResponseMessage ¶
func NewGetChainFromBlockResponseMessage(removedChainBlockHashes []string, addedChainBlocks []*ChainBlock, blockVerboseData []*BlockVerboseData) *GetChainFromBlockResponseMessage
NewGetChainFromBlockResponseMessage returns a instance of the message
func (*GetChainFromBlockResponseMessage) Command ¶
func (msg *GetChainFromBlockResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetChainFromBlockResponseMessage) MessageNumber ¶
func (b *GetChainFromBlockResponseMessage) MessageNumber() uint64
func (*GetChainFromBlockResponseMessage) ReceivedAt ¶
func (*GetChainFromBlockResponseMessage) SetMessageNumber ¶
func (b *GetChainFromBlockResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetChainFromBlockResponseMessage) SetReceivedAt ¶
type GetConnectedPeerInfoMessage ¶
type GetConnectedPeerInfoMessage struct { ID string Address string LastPingDuration int64 SelectedTipHash string IsSyncNode bool IsOutbound bool TimeOffset int64 UserAgent string AdvertisedProtocolVersion uint32 TimeConnected int64 }
GetConnectedPeerInfoMessage holds information about a connected peer
type GetConnectedPeerInfoRequestMessage ¶
type GetConnectedPeerInfoRequestMessage struct {
// contains filtered or unexported fields
}
GetConnectedPeerInfoRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetConnectedPeerInfoRequestMessage ¶
func NewGetConnectedPeerInfoRequestMessage() *GetConnectedPeerInfoRequestMessage
NewGetConnectedPeerInfoRequestMessage returns a instance of the message
func (*GetConnectedPeerInfoRequestMessage) Command ¶
func (msg *GetConnectedPeerInfoRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetConnectedPeerInfoRequestMessage) MessageNumber ¶
func (b *GetConnectedPeerInfoRequestMessage) MessageNumber() uint64
func (*GetConnectedPeerInfoRequestMessage) ReceivedAt ¶
func (*GetConnectedPeerInfoRequestMessage) SetMessageNumber ¶
func (b *GetConnectedPeerInfoRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetConnectedPeerInfoRequestMessage) SetReceivedAt ¶
type GetConnectedPeerInfoResponseMessage ¶
type GetConnectedPeerInfoResponseMessage struct { Infos []*GetConnectedPeerInfoMessage Error *RPCError // contains filtered or unexported fields }
GetConnectedPeerInfoResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetConnectedPeerInfoResponseMessage ¶
func NewGetConnectedPeerInfoResponseMessage(infos []*GetConnectedPeerInfoMessage) *GetConnectedPeerInfoResponseMessage
NewGetConnectedPeerInfoResponseMessage returns a instance of the message
func (*GetConnectedPeerInfoResponseMessage) Command ¶
func (msg *GetConnectedPeerInfoResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetConnectedPeerInfoResponseMessage) MessageNumber ¶
func (b *GetConnectedPeerInfoResponseMessage) MessageNumber() uint64
func (*GetConnectedPeerInfoResponseMessage) ReceivedAt ¶
func (*GetConnectedPeerInfoResponseMessage) SetMessageNumber ¶
func (b *GetConnectedPeerInfoResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetConnectedPeerInfoResponseMessage) SetReceivedAt ¶
type GetCurrentNetworkRequestMessage ¶
type GetCurrentNetworkRequestMessage struct {
// contains filtered or unexported fields
}
GetCurrentNetworkRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetCurrentNetworkRequestMessage ¶
func NewGetCurrentNetworkRequestMessage() *GetCurrentNetworkRequestMessage
NewGetCurrentNetworkRequestMessage returns a instance of the message
func (*GetCurrentNetworkRequestMessage) Command ¶
func (msg *GetCurrentNetworkRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetCurrentNetworkRequestMessage) MessageNumber ¶
func (b *GetCurrentNetworkRequestMessage) MessageNumber() uint64
func (*GetCurrentNetworkRequestMessage) ReceivedAt ¶
func (*GetCurrentNetworkRequestMessage) SetMessageNumber ¶
func (b *GetCurrentNetworkRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetCurrentNetworkRequestMessage) SetReceivedAt ¶
type GetCurrentNetworkResponseMessage ¶
type GetCurrentNetworkResponseMessage struct { CurrentNetwork string Error *RPCError // contains filtered or unexported fields }
GetCurrentNetworkResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetCurrentNetworkResponseMessage ¶
func NewGetCurrentNetworkResponseMessage(currentNetwork string) *GetCurrentNetworkResponseMessage
NewGetCurrentNetworkResponseMessage returns a instance of the message
func (*GetCurrentNetworkResponseMessage) Command ¶
func (msg *GetCurrentNetworkResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetCurrentNetworkResponseMessage) MessageNumber ¶
func (b *GetCurrentNetworkResponseMessage) MessageNumber() uint64
func (*GetCurrentNetworkResponseMessage) ReceivedAt ¶
func (*GetCurrentNetworkResponseMessage) SetMessageNumber ¶
func (b *GetCurrentNetworkResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetCurrentNetworkResponseMessage) SetReceivedAt ¶
type GetMempoolEntryRequestMessage ¶
type GetMempoolEntryRequestMessage struct { TxID string // contains filtered or unexported fields }
GetMempoolEntryRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetMempoolEntryRequestMessage ¶
func NewGetMempoolEntryRequestMessage(txID string) *GetMempoolEntryRequestMessage
NewGetMempoolEntryRequestMessage returns a instance of the message
func (*GetMempoolEntryRequestMessage) Command ¶
func (msg *GetMempoolEntryRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetMempoolEntryRequestMessage) MessageNumber ¶
func (b *GetMempoolEntryRequestMessage) MessageNumber() uint64
func (*GetMempoolEntryRequestMessage) ReceivedAt ¶
func (*GetMempoolEntryRequestMessage) SetMessageNumber ¶
func (b *GetMempoolEntryRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetMempoolEntryRequestMessage) SetReceivedAt ¶
type GetMempoolEntryResponseMessage ¶
type GetMempoolEntryResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
GetMempoolEntryResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetMempoolEntryResponseMessage ¶
func NewGetMempoolEntryResponseMessage() *GetMempoolEntryResponseMessage
NewGetMempoolEntryResponseMessage returns a instance of the message
func (*GetMempoolEntryResponseMessage) Command ¶
func (msg *GetMempoolEntryResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetMempoolEntryResponseMessage) MessageNumber ¶
func (b *GetMempoolEntryResponseMessage) MessageNumber() uint64
func (*GetMempoolEntryResponseMessage) ReceivedAt ¶
func (*GetMempoolEntryResponseMessage) SetMessageNumber ¶
func (b *GetMempoolEntryResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetMempoolEntryResponseMessage) SetReceivedAt ¶
type GetPeerAddressesKnownAddressMessage ¶
type GetPeerAddressesKnownAddressMessage struct {
Addr string
}
GetPeerAddressesKnownAddressMessage is an appmessage corresponding to its respective RPC message
type GetPeerAddressesRequestMessage ¶
type GetPeerAddressesRequestMessage struct {
// contains filtered or unexported fields
}
GetPeerAddressesRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetPeerAddressesRequestMessage ¶
func NewGetPeerAddressesRequestMessage() *GetPeerAddressesRequestMessage
NewGetPeerAddressesRequestMessage returns a instance of the message
func (*GetPeerAddressesRequestMessage) Command ¶
func (msg *GetPeerAddressesRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetPeerAddressesRequestMessage) MessageNumber ¶
func (b *GetPeerAddressesRequestMessage) MessageNumber() uint64
func (*GetPeerAddressesRequestMessage) ReceivedAt ¶
func (*GetPeerAddressesRequestMessage) SetMessageNumber ¶
func (b *GetPeerAddressesRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetPeerAddressesRequestMessage) SetReceivedAt ¶
type GetPeerAddressesResponseMessage ¶
type GetPeerAddressesResponseMessage struct { Addresses []*GetPeerAddressesKnownAddressMessage Error *RPCError // contains filtered or unexported fields }
GetPeerAddressesResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetPeerAddressesResponseMessage ¶
func NewGetPeerAddressesResponseMessage(addresses []*GetPeerAddressesKnownAddressMessage) *GetPeerAddressesResponseMessage
NewGetPeerAddressesResponseMessage returns a instance of the message
func (*GetPeerAddressesResponseMessage) Command ¶
func (msg *GetPeerAddressesResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetPeerAddressesResponseMessage) MessageNumber ¶
func (b *GetPeerAddressesResponseMessage) MessageNumber() uint64
func (*GetPeerAddressesResponseMessage) ReceivedAt ¶
func (*GetPeerAddressesResponseMessage) SetMessageNumber ¶
func (b *GetPeerAddressesResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetPeerAddressesResponseMessage) SetReceivedAt ¶
type GetSelectedTipHashRequestMessage ¶
type GetSelectedTipHashRequestMessage struct {
// contains filtered or unexported fields
}
GetSelectedTipHashRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetSelectedTipHashRequestMessage ¶
func NewGetSelectedTipHashRequestMessage() *GetSelectedTipHashRequestMessage
NewGetSelectedTipHashRequestMessage returns a instance of the message
func (*GetSelectedTipHashRequestMessage) Command ¶
func (msg *GetSelectedTipHashRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetSelectedTipHashRequestMessage) MessageNumber ¶
func (b *GetSelectedTipHashRequestMessage) MessageNumber() uint64
func (*GetSelectedTipHashRequestMessage) ReceivedAt ¶
func (*GetSelectedTipHashRequestMessage) SetMessageNumber ¶
func (b *GetSelectedTipHashRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetSelectedTipHashRequestMessage) SetReceivedAt ¶
type GetSelectedTipHashResponseMessage ¶
type GetSelectedTipHashResponseMessage struct { SelectedTipHash string Error *RPCError // contains filtered or unexported fields }
GetSelectedTipHashResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetSelectedTipHashResponseMessage ¶
func NewGetSelectedTipHashResponseMessage(selectedTipHash string) *GetSelectedTipHashResponseMessage
NewGetSelectedTipHashResponseMessage returns a instance of the message
func (*GetSelectedTipHashResponseMessage) Command ¶
func (msg *GetSelectedTipHashResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetSelectedTipHashResponseMessage) MessageNumber ¶
func (b *GetSelectedTipHashResponseMessage) MessageNumber() uint64
func (*GetSelectedTipHashResponseMessage) ReceivedAt ¶
func (*GetSelectedTipHashResponseMessage) SetMessageNumber ¶
func (b *GetSelectedTipHashResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetSelectedTipHashResponseMessage) SetReceivedAt ¶
type GetSubnetworkRequestMessage ¶
type GetSubnetworkRequestMessage struct { SubnetworkID string // contains filtered or unexported fields }
GetSubnetworkRequestMessage is an appmessage corresponding to its respective RPC message
func NewGetSubnetworkRequestMessage ¶
func NewGetSubnetworkRequestMessage(subnetworkID string) *GetSubnetworkRequestMessage
NewGetSubnetworkRequestMessage returns a instance of the message
func (*GetSubnetworkRequestMessage) Command ¶
func (msg *GetSubnetworkRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetSubnetworkRequestMessage) MessageNumber ¶
func (b *GetSubnetworkRequestMessage) MessageNumber() uint64
func (*GetSubnetworkRequestMessage) ReceivedAt ¶
func (*GetSubnetworkRequestMessage) SetMessageNumber ¶
func (b *GetSubnetworkRequestMessage) SetMessageNumber(messageNumber uint64)
func (*GetSubnetworkRequestMessage) SetReceivedAt ¶
type GetSubnetworkResponseMessage ¶
type GetSubnetworkResponseMessage struct { GasLimit uint64 Error *RPCError // contains filtered or unexported fields }
GetSubnetworkResponseMessage is an appmessage corresponding to its respective RPC message
func NewGetSubnetworkResponseMessage ¶
func NewGetSubnetworkResponseMessage(gasLimit uint64) *GetSubnetworkResponseMessage
NewGetSubnetworkResponseMessage returns a instance of the message
func (*GetSubnetworkResponseMessage) Command ¶
func (msg *GetSubnetworkResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*GetSubnetworkResponseMessage) MessageNumber ¶
func (b *GetSubnetworkResponseMessage) MessageNumber() uint64
func (*GetSubnetworkResponseMessage) ReceivedAt ¶
func (*GetSubnetworkResponseMessage) SetMessageNumber ¶
func (b *GetSubnetworkResponseMessage) SetMessageNumber(messageNumber uint64)
func (*GetSubnetworkResponseMessage) SetReceivedAt ¶
type KaspaNet ¶
type KaspaNet uint32
KaspaNet represents which kaspa network a message belongs to.
const ( // Mainnet represents the main kaspa network. Mainnet KaspaNet = 0x3ddcf71d // Testnet represents the test network. Testnet KaspaNet = 0xddb8af8f // Simnet represents the simulation test network. Simnet KaspaNet = 0x374dcf1c // Devnet represents the development test network. Devnet KaspaNet = 0x732d87e1 )
Constants used to indicate the message kaspa network. They can also be used to seek to the next message when a stream's state is unknown, but this package does not provide that functionality since it's generally a better idea to simply disconnect clients that are misbehaving over TCP.
type Message ¶
type Message interface { Command() MessageCommand MessageNumber() uint64 SetMessageNumber(index uint64) ReceivedAt() time.Time SetReceivedAt(receivedAt time.Time) }
Message is an interface that describes a kaspa message. A type that implements Message has complete control over the representation of its data and may therefore contain additional or fewer fields than those which are used directly in the protocol encoded message.
type MessageCommand ¶
type MessageCommand uint32
MessageCommand is a number in the header of a message that represents its type.
const ( // protocol CmdVersion MessageCommand = iota CmdVerAck CmdRequestAddresses CmdAddresses CmdRequestIBDBlocks CmdBlock CmdTx CmdPing CmdPong CmdRequestBlockLocator CmdBlockLocator CmdSelectedTip CmdRequestSelectedTip CmdInvRelayBlock CmdRequestRelayBlocks CmdInvTransaction CmdRequestTransactions CmdIBDBlock CmdRequestNextIBDBlocks CmdDoneIBDBlocks CmdTransactionNotFound CmdReject // rpc CmdGetCurrentNetworkRequestMessage CmdGetCurrentNetworkResponseMessage CmdSubmitBlockRequestMessage CmdSubmitBlockResponseMessage CmdGetBlockTemplateRequestMessage CmdGetBlockTemplateResponseMessage CmdGetBlockTemplateTransactionMessage CmdNotifyBlockAddedRequestMessage CmdNotifyBlockAddedResponseMessage CmdBlockAddedNotificationMessage CmdGetPeerAddressesRequestMessage CmdGetPeerAddressesResponseMessage CmdGetSelectedTipHashRequestMessage CmdGetSelectedTipHashResponseMessage CmdGetMempoolEntryRequestMessage CmdGetMempoolEntryResponseMessage CmdGetConnectedPeerInfoRequestMessage CmdGetConnectedPeerInfoResponseMessage CmdAddPeerRequestMessage CmdAddPeerResponseMessage CmdSubmitTransactionRequestMessage CmdSubmitTransactionResponseMessage CmdNotifyChainChangedRequestMessage CmdNotifyChainChangedResponseMessage CmdChainChangedNotificationMessage CmdGetBlockRequestMessage CmdGetBlockResponseMessage CmdGetSubnetworkRequestMessage CmdGetSubnetworkResponseMessage CmdGetChainFromBlockRequestMessage CmdGetChainFromBlockResponseMessage CmdGetBlocksRequestMessage CmdGetBlocksResponseMessage CmdGetBlockCountRequestMessage CmdGetBlockCountResponseMessage CmdGetBlockDAGInfoRequestMessage CmdGetBlockDAGInfoResponseMessage CmdResolveFinalityConflictRequestMessage CmdResolveFinalityConflictResponseMessage CmdNotifyFinalityConflictsRequestMessage CmdNotifyFinalityConflictsResponseMessage CmdFinalityConflictNotificationMessage CmdFinalityConflictResolvedNotificationMessage )
Commands used in kaspa message headers which describe the type of message.
func (MessageCommand) String ¶
func (cmd MessageCommand) String() string
type MessageError ¶
type MessageError struct { Func string // Function name Description string // Human readable description of the issue }
MessageError describes an issue with a message. An example of some potential issues are messages from the wrong kaspa network, invalid commands, mismatched checksums, and exceeding max payloads.
This provides a mechanism for the caller to type assert the error to differentiate between general io errors such as io.EOF and issues that resulted from malformed messages.
func (*MessageError) Error ¶
func (e *MessageError) Error() string
Error satisfies the error interface and prints human-readable errors.
type MsgAddresses ¶
type MsgAddresses struct { IncludeAllSubnetworks bool SubnetworkID *subnetworkid.SubnetworkID AddrList []*NetAddress // contains filtered or unexported fields }
MsgAddresses implements the Message interface and represents a kaspa Addresses message. It is used to provide a list of known active peers on the network. An active peer is considered one that has transmitted a message within the last 3 hours. Nodes which have not transmitted in that time frame should be forgotten. Each message is limited to a maximum number of addresses, which is currently 1000. As a result, multiple messages must be used to relay the full list.
Use the AddAddress function to build up the list of known addresses when sending an Addresses message to another peer.
func NewMsgAddresses ¶
func NewMsgAddresses(includeAllSubnetworks bool, subnetworkID *subnetworkid.SubnetworkID) *MsgAddresses
NewMsgAddresses returns a new kaspa Addresses message that conforms to the Message interface. See MsgAddresses for details.
func (*MsgAddresses) AddAddress ¶
func (msg *MsgAddresses) AddAddress(na *NetAddress) error
AddAddress adds a known active peer to the message.
func (*MsgAddresses) AddAddresses ¶
func (msg *MsgAddresses) AddAddresses(netAddrs ...*NetAddress) error
AddAddresses adds multiple known active peers to the message.
func (*MsgAddresses) ClearAddresses ¶
func (msg *MsgAddresses) ClearAddresses()
ClearAddresses removes all addresses from the message.
func (*MsgAddresses) Command ¶
func (msg *MsgAddresses) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgAddresses) MessageNumber ¶
func (b *MsgAddresses) MessageNumber() uint64
func (*MsgAddresses) ReceivedAt ¶
func (*MsgAddresses) SetMessageNumber ¶
func (b *MsgAddresses) SetMessageNumber(messageNumber uint64)
func (*MsgAddresses) SetReceivedAt ¶
type MsgBlock ¶
type MsgBlock struct { Header BlockHeader Transactions []*MsgTx // contains filtered or unexported fields }
MsgBlock implements the Message interface and represents a kaspa block message. It is used to deliver block and transaction information in response to a getdata message (MsgGetData) for a given block hash.
func NewMsgBlock ¶
func NewMsgBlock(blockHeader *BlockHeader) *MsgBlock
NewMsgBlock returns a new kaspa block message that conforms to the Message interface. See MsgBlock for details.
func (*MsgBlock) AddTransaction ¶
AddTransaction adds a transaction to the message.
func (*MsgBlock) ClearTransactions ¶
func (msg *MsgBlock) ClearTransactions()
ClearTransactions removes all transactions from the message.
func (*MsgBlock) Command ¶
func (msg *MsgBlock) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgBlock) ConvertToPartial ¶
func (msg *MsgBlock) ConvertToPartial(subnetworkID *subnetworkid.SubnetworkID)
ConvertToPartial clears out all the payloads of the subnetworks that are incompatible with the given subnetwork ID. Note: this operation modifies the block in place.
func (*MsgBlock) Deserialize ¶
Deserialize decodes a block from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from KaspaDecode in that KaspaDecode decodes from the kaspa appmessage protocol as it was sent across the network. The appmessage encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) DeserializeTxLoc ¶
DeserializeTxLoc decodes r in the same manner Deserialize does, but it takes a byte buffer instead of a generic reader and returns a slice containing the start and length of each transaction within the raw data that is being deserialized.
func (*MsgBlock) KaspaDecode ¶
KaspaDecode decodes r using the kaspa protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding blocks stored to disk, such as in a database, as opposed to decoding blocks from the appmessage.
func (*MsgBlock) KaspaEncode ¶
KaspaEncode encodes the receiver to w using the kaspa protocol encoding. This is part of the Message interface implementation. See Serialize for encoding blocks to be stored to disk, such as in a database, as opposed to encoding blocks for the appmessage.
func (*MsgBlock) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgBlock) MessageNumber ¶
func (b *MsgBlock) MessageNumber() uint64
func (*MsgBlock) ReceivedAt ¶
func (*MsgBlock) Serialize ¶
Serialize encodes the block to w using a format that suitable for long-term storage such as a database while respecting the Version field in the block. This function differs from KaspaEncode in that KaspaEncode encodes the block to the kaspa appmessage protocol in order to be sent across the network. The appmessage encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored block at all. As of the time this comment was written, the encoded block is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgBlock) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the block.
func (*MsgBlock) SetMessageNumber ¶
func (b *MsgBlock) SetMessageNumber(messageNumber uint64)
func (*MsgBlock) SetReceivedAt ¶
type MsgBlockLocator ¶
type MsgBlockLocator struct { BlockLocatorHashes []*daghash.Hash // contains filtered or unexported fields }
MsgBlockLocator implements the Message interface and represents a kaspa locator message. It is used to find the blockLocator of a peer that is syncing with you.
func NewMsgBlockLocator ¶
func NewMsgBlockLocator(locatorHashes []*daghash.Hash) *MsgBlockLocator
NewMsgBlockLocator returns a new kaspa locator message that conforms to the Message interface. See MsgBlockLocator for details.
func (*MsgBlockLocator) Command ¶
func (msg *MsgBlockLocator) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgBlockLocator) MessageNumber ¶
func (b *MsgBlockLocator) MessageNumber() uint64
func (*MsgBlockLocator) ReceivedAt ¶
func (*MsgBlockLocator) SetMessageNumber ¶
func (b *MsgBlockLocator) SetMessageNumber(messageNumber uint64)
func (*MsgBlockLocator) SetReceivedAt ¶
type MsgDoneIBDBlocks ¶
type MsgDoneIBDBlocks struct {
// contains filtered or unexported fields
}
MsgDoneIBDBlocks implements the Message interface and represents a kaspa DoneIBDBlocks message. It is used to notify the IBD syncing peer that the syncer sent all the requested blocks.
This message has no payload.
func NewMsgDoneIBDBlocks ¶
func NewMsgDoneIBDBlocks() *MsgDoneIBDBlocks
NewMsgDoneIBDBlocks returns a new kaspa DoneIBDBlocks message that conforms to the Message interface.
func (*MsgDoneIBDBlocks) Command ¶
func (msg *MsgDoneIBDBlocks) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgDoneIBDBlocks) MessageNumber ¶
func (b *MsgDoneIBDBlocks) MessageNumber() uint64
func (*MsgDoneIBDBlocks) ReceivedAt ¶
func (*MsgDoneIBDBlocks) SetMessageNumber ¶
func (b *MsgDoneIBDBlocks) SetMessageNumber(messageNumber uint64)
func (*MsgDoneIBDBlocks) SetReceivedAt ¶
type MsgIBDBlock ¶
type MsgIBDBlock struct { *MsgBlock // contains filtered or unexported fields }
MsgIBDBlock implements the Message interface and represents a kaspa ibdblock message. It is used to deliver block and transaction information in response to a RequestIBDBlocks message (MsgRequestIBDBlocks).
func NewMsgIBDBlock ¶
func NewMsgIBDBlock(msgBlock *MsgBlock) *MsgIBDBlock
NewMsgIBDBlock returns a new kaspa ibdblock message that conforms to the Message interface. See MsgIBDBlock for details.
func (*MsgIBDBlock) Command ¶
func (msg *MsgIBDBlock) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgIBDBlock) MaxPayloadLength ¶
func (msg *MsgIBDBlock) MaxPayloadLength(pver uint32) uint32
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgIBDBlock) MessageNumber ¶
func (b *MsgIBDBlock) MessageNumber() uint64
func (*MsgIBDBlock) ReceivedAt ¶
func (*MsgIBDBlock) SetMessageNumber ¶
func (b *MsgIBDBlock) SetMessageNumber(messageNumber uint64)
func (*MsgIBDBlock) SetReceivedAt ¶
type MsgInvRelayBlock ¶
MsgInvRelayBlock implements the Message interface and represents a kaspa block inventory message. It is used to notify the network about new block by sending their hash, and let the receiving node decide if it needs it.
func NewMsgInvBlock ¶
func NewMsgInvBlock(hash *daghash.Hash) *MsgInvRelayBlock
NewMsgInvBlock returns a new kaspa invrelblk message that conforms to the Message interface. See MsgInvRelayBlock for details.
func (*MsgInvRelayBlock) Command ¶
func (msg *MsgInvRelayBlock) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgInvRelayBlock) MessageNumber ¶
func (b *MsgInvRelayBlock) MessageNumber() uint64
func (*MsgInvRelayBlock) ReceivedAt ¶
func (*MsgInvRelayBlock) SetMessageNumber ¶
func (b *MsgInvRelayBlock) SetMessageNumber(messageNumber uint64)
func (*MsgInvRelayBlock) SetReceivedAt ¶
type MsgInvTransaction ¶
MsgInvTransaction implements the Message interface and represents a kaspa TxInv message. It is used to notify the network about new transactions by sending their ID, and let the receiving node decide if it needs it.
func NewMsgInvTransaction ¶
func NewMsgInvTransaction(ids []*daghash.TxID) *MsgInvTransaction
NewMsgInvTransaction returns a new kaspa TxInv message that conforms to the Message interface. See MsgInvTransaction for details.
func (*MsgInvTransaction) Command ¶
func (msg *MsgInvTransaction) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgInvTransaction) MessageNumber ¶
func (b *MsgInvTransaction) MessageNumber() uint64
func (*MsgInvTransaction) ReceivedAt ¶
func (*MsgInvTransaction) SetMessageNumber ¶
func (b *MsgInvTransaction) SetMessageNumber(messageNumber uint64)
func (*MsgInvTransaction) SetReceivedAt ¶
type MsgPing ¶
type MsgPing struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 // contains filtered or unexported fields }
MsgPing implements the Message interface and represents a kaspa ping message.
For versions BIP0031Version and earlier, it is used primarily to confirm that a connection is still valid. A transmission error is typically interpreted as a closed connection and that the peer should be removed. For versions AFTER BIP0031Version it contains an identifier which can be returned in the pong message to determine network timing.
The payload for this message just consists of a nonce used for identifying it later.
func NewMsgPing ¶
NewMsgPing returns a new kaspa ping message that conforms to the Message interface. See MsgPing for details.
func (*MsgPing) Command ¶
func (msg *MsgPing) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPing) MessageNumber ¶
func (b *MsgPing) MessageNumber() uint64
func (*MsgPing) ReceivedAt ¶
func (*MsgPing) SetMessageNumber ¶
func (b *MsgPing) SetMessageNumber(messageNumber uint64)
func (*MsgPing) SetReceivedAt ¶
type MsgPong ¶
type MsgPong struct { // Unique value associated with message that is used to identify // specific ping message. Nonce uint64 // contains filtered or unexported fields }
MsgPong implements the Message interface and represents a kaspa pong message which is used primarily to confirm that a connection is still valid in response to a kaspa ping message (MsgPing).
This message was not added until protocol versions AFTER BIP0031Version.
func NewMsgPong ¶
NewMsgPong returns a new kaspa pong message that conforms to the Message interface. See MsgPong for details.
func (*MsgPong) Command ¶
func (msg *MsgPong) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgPong) MessageNumber ¶
func (b *MsgPong) MessageNumber() uint64
func (*MsgPong) ReceivedAt ¶
func (*MsgPong) SetMessageNumber ¶
func (b *MsgPong) SetMessageNumber(messageNumber uint64)
func (*MsgPong) SetReceivedAt ¶
type MsgReject ¶
type MsgReject struct { Reason string // contains filtered or unexported fields }
MsgReject implements the Message interface and represents a kaspa Reject message. It is used to notify peers why they are banned.
func NewMsgReject ¶
NewMsgReject returns a new kaspa Reject message that conforms to the Message interface.
func (*MsgReject) Command ¶
func (msg *MsgReject) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgReject) MessageNumber ¶
func (b *MsgReject) MessageNumber() uint64
func (*MsgReject) ReceivedAt ¶
func (*MsgReject) SetMessageNumber ¶
func (b *MsgReject) SetMessageNumber(messageNumber uint64)
func (*MsgReject) SetReceivedAt ¶
type MsgRequestAddresses ¶
type MsgRequestAddresses struct { IncludeAllSubnetworks bool SubnetworkID *subnetworkid.SubnetworkID // contains filtered or unexported fields }
MsgRequestAddresses implements the Message interface and represents a kaspa RequestAddresses message. It is used to request a list of known active peers on the network from a peer to help identify potential nodes. The list is returned via one or more addr messages (MsgAddresses).
This message has no payload.
func NewMsgRequestAddresses ¶
func NewMsgRequestAddresses(includeAllSubnetworks bool, subnetworkID *subnetworkid.SubnetworkID) *MsgRequestAddresses
NewMsgRequestAddresses returns a new kaspa RequestAddresses message that conforms to the Message interface. See MsgRequestAddresses for details.
func (*MsgRequestAddresses) Command ¶
func (msg *MsgRequestAddresses) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestAddresses) MessageNumber ¶
func (b *MsgRequestAddresses) MessageNumber() uint64
func (*MsgRequestAddresses) ReceivedAt ¶
func (*MsgRequestAddresses) SetMessageNumber ¶
func (b *MsgRequestAddresses) SetMessageNumber(messageNumber uint64)
func (*MsgRequestAddresses) SetReceivedAt ¶
type MsgRequestBlockLocator ¶
type MsgRequestBlockLocator struct { HighHash *daghash.Hash LowHash *daghash.Hash // contains filtered or unexported fields }
MsgRequestBlockLocator implements the Message interface and represents a kaspa RequestBlockLocator message. It is used to request a block locator between high and low hash. The locator is returned via a locator message (MsgBlockLocator).
func NewMsgRequestBlockLocator ¶
func NewMsgRequestBlockLocator(highHash, lowHash *daghash.Hash) *MsgRequestBlockLocator
NewMsgRequestBlockLocator returns a new RequestBlockLocator message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgRequestBlockLocator) Command ¶
func (msg *MsgRequestBlockLocator) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestBlockLocator) MessageNumber ¶
func (b *MsgRequestBlockLocator) MessageNumber() uint64
func (*MsgRequestBlockLocator) ReceivedAt ¶
func (*MsgRequestBlockLocator) SetMessageNumber ¶
func (b *MsgRequestBlockLocator) SetMessageNumber(messageNumber uint64)
func (*MsgRequestBlockLocator) SetReceivedAt ¶
type MsgRequestIBDBlocks ¶
type MsgRequestIBDBlocks struct { LowHash *daghash.Hash HighHash *daghash.Hash // contains filtered or unexported fields }
MsgRequestIBDBlocks implements the Message interface and represents a kaspa RequestIBDBlocks message. It is used to request a list of blocks starting after the low hash and until the high hash.
func NewMsgRequstIBDBlocks ¶
func NewMsgRequstIBDBlocks(lowHash, highHash *daghash.Hash) *MsgRequestIBDBlocks
NewMsgRequstIBDBlocks returns a new kaspa RequestIBDBlocks message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgRequestIBDBlocks) Command ¶
func (msg *MsgRequestIBDBlocks) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestIBDBlocks) MessageNumber ¶
func (b *MsgRequestIBDBlocks) MessageNumber() uint64
func (*MsgRequestIBDBlocks) ReceivedAt ¶
func (*MsgRequestIBDBlocks) SetMessageNumber ¶
func (b *MsgRequestIBDBlocks) SetMessageNumber(messageNumber uint64)
func (*MsgRequestIBDBlocks) SetReceivedAt ¶
type MsgRequestNextIBDBlocks ¶
type MsgRequestNextIBDBlocks struct {
// contains filtered or unexported fields
}
MsgRequestNextIBDBlocks implements the Message interface and represents a kaspa RequestNextIBDBlocks message. It is used to notify the IBD syncer peer to send more blocks.
This message has no payload.
func NewMsgRequestNextIBDBlocks ¶
func NewMsgRequestNextIBDBlocks() *MsgRequestNextIBDBlocks
NewMsgRequestNextIBDBlocks returns a new kaspa RequestNextIBDBlocks message that conforms to the Message interface.
func (*MsgRequestNextIBDBlocks) Command ¶
func (msg *MsgRequestNextIBDBlocks) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestNextIBDBlocks) MessageNumber ¶
func (b *MsgRequestNextIBDBlocks) MessageNumber() uint64
func (*MsgRequestNextIBDBlocks) ReceivedAt ¶
func (*MsgRequestNextIBDBlocks) SetMessageNumber ¶
func (b *MsgRequestNextIBDBlocks) SetMessageNumber(messageNumber uint64)
func (*MsgRequestNextIBDBlocks) SetReceivedAt ¶
type MsgRequestRelayBlocks ¶
type MsgRequestRelayBlocks struct { Hashes []*daghash.Hash // contains filtered or unexported fields }
MsgRequestRelayBlocks implements the Message interface and represents a kaspa RequestRelayBlocks message. It is used to request blocks as part of the block relay protocol.
func NewMsgRequestRelayBlocks ¶
func NewMsgRequestRelayBlocks(hashes []*daghash.Hash) *MsgRequestRelayBlocks
NewMsgRequestRelayBlocks returns a new kaspa RequestRelayBlocks message that conforms to the Message interface. See MsgRequestRelayBlocks for details.
func (*MsgRequestRelayBlocks) Command ¶
func (msg *MsgRequestRelayBlocks) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestRelayBlocks) MessageNumber ¶
func (b *MsgRequestRelayBlocks) MessageNumber() uint64
func (*MsgRequestRelayBlocks) ReceivedAt ¶
func (*MsgRequestRelayBlocks) SetMessageNumber ¶
func (b *MsgRequestRelayBlocks) SetMessageNumber(messageNumber uint64)
func (*MsgRequestRelayBlocks) SetReceivedAt ¶
type MsgRequestSelectedTip ¶
type MsgRequestSelectedTip struct {
// contains filtered or unexported fields
}
MsgRequestSelectedTip implements the Message interface and represents a kaspa RequestSelectedTip message. It is used to request the selected tip of another peer.
This message has no payload.
func NewMsgRequestSelectedTip ¶
func NewMsgRequestSelectedTip() *MsgRequestSelectedTip
NewMsgRequestSelectedTip returns a new kaspa RequestSelectedTip message that conforms to the Message interface.
func (*MsgRequestSelectedTip) Command ¶
func (msg *MsgRequestSelectedTip) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestSelectedTip) MessageNumber ¶
func (b *MsgRequestSelectedTip) MessageNumber() uint64
func (*MsgRequestSelectedTip) ReceivedAt ¶
func (*MsgRequestSelectedTip) SetMessageNumber ¶
func (b *MsgRequestSelectedTip) SetMessageNumber(messageNumber uint64)
func (*MsgRequestSelectedTip) SetReceivedAt ¶
type MsgRequestTransactions ¶
type MsgRequestTransactions struct { IDs []*daghash.TxID // contains filtered or unexported fields }
MsgRequestTransactions implements the Message interface and represents a kaspa RequestTransactions message. It is used to request transactions as part of the transactions relay protocol.
func NewMsgRequestTransactions ¶
func NewMsgRequestTransactions(ids []*daghash.TxID) *MsgRequestTransactions
NewMsgRequestTransactions returns a new kaspa RequestTransactions message that conforms to the Message interface. See MsgRequestTransactions for details.
func (*MsgRequestTransactions) Command ¶
func (msg *MsgRequestTransactions) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgRequestTransactions) MessageNumber ¶
func (b *MsgRequestTransactions) MessageNumber() uint64
func (*MsgRequestTransactions) ReceivedAt ¶
func (*MsgRequestTransactions) SetMessageNumber ¶
func (b *MsgRequestTransactions) SetMessageNumber(messageNumber uint64)
func (*MsgRequestTransactions) SetReceivedAt ¶
type MsgSelectedTip ¶
type MsgSelectedTip struct { // The selected tip hash of the generator of the message. SelectedTipHash *daghash.Hash // contains filtered or unexported fields }
MsgSelectedTip implements the Message interface and represents a kaspa selectedtip message. It is used to answer getseltip messages and tell the asking peer what is the selected tip of this peer.
func NewMsgSelectedTip ¶
func NewMsgSelectedTip(selectedTipHash *daghash.Hash) *MsgSelectedTip
NewMsgSelectedTip returns a new kaspa selectedtip message that conforms to the Message interface.
func (*MsgSelectedTip) Command ¶
func (msg *MsgSelectedTip) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgSelectedTip) MessageNumber ¶
func (b *MsgSelectedTip) MessageNumber() uint64
func (*MsgSelectedTip) ReceivedAt ¶
func (*MsgSelectedTip) SetMessageNumber ¶
func (b *MsgSelectedTip) SetMessageNumber(messageNumber uint64)
func (*MsgSelectedTip) SetReceivedAt ¶
type MsgTransactionNotFound ¶
MsgTransactionNotFound defines a kaspa TransactionNotFound message which is sent in response to a RequestTransactions message if any of the requested data in not available on the peer.
func NewMsgTransactionNotFound ¶
func NewMsgTransactionNotFound(id *daghash.TxID) *MsgTransactionNotFound
NewMsgTransactionNotFound returns a new kaspa transactionsnotfound message that conforms to the Message interface. See MsgTransactionNotFound for details.
func (*MsgTransactionNotFound) Command ¶
func (msg *MsgTransactionNotFound) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgTransactionNotFound) MessageNumber ¶
func (b *MsgTransactionNotFound) MessageNumber() uint64
func (*MsgTransactionNotFound) ReceivedAt ¶
func (*MsgTransactionNotFound) SetMessageNumber ¶
func (b *MsgTransactionNotFound) SetMessageNumber(messageNumber uint64)
func (*MsgTransactionNotFound) SetReceivedAt ¶
type MsgTx ¶
type MsgTx struct { Version int32 TxIn []*TxIn TxOut []*TxOut LockTime uint64 SubnetworkID subnetworkid.SubnetworkID Gas uint64 PayloadHash *daghash.Hash Payload []byte // contains filtered or unexported fields }
MsgTx implements the Message interface and represents a kaspa tx message. It is used to deliver transaction information in response to a getdata message (MsgGetData) for a given transaction.
Use the AddTxIn and AddTxOut functions to build up the list of transaction inputs and outputs.
func NewNativeMsgTx ¶
NewNativeMsgTx returns a new tx message in the native subnetwork
func NewNativeMsgTxWithLocktime ¶
func NewNativeMsgTxWithLocktime(version int32, txIn []*TxIn, txOut []*TxOut, locktime uint64) *MsgTx
NewNativeMsgTxWithLocktime returns a new tx message in the native subnetwork with a locktime.
See newMsgTx for further documntation of the parameters
func NewRegistryMsgTx ¶
NewRegistryMsgTx creates a new MsgTx that registers a new subnetwork
func NewSubnetworkMsgTx ¶
func NewSubnetworkMsgTx(version int32, txIn []*TxIn, txOut []*TxOut, subnetworkID *subnetworkid.SubnetworkID, gas uint64, payload []byte) *MsgTx
NewSubnetworkMsgTx returns a new tx message in the specified subnetwork with specified gas and payload
func (*MsgTx) Command ¶
func (msg *MsgTx) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgTx) Copy ¶
Copy creates a deep copy of a transaction so that the original does not get modified when the copy is manipulated.
func (*MsgTx) Deserialize ¶
Deserialize decodes a transaction from r into the receiver using a format that is suitable for long-term storage such as a database while respecting the Version field in the transaction. This function differs from KaspaDecode in that KaspaDecode decodes from the kaspa appmessage protocol as it was sent across the network. The appmessage encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored transaction at all. As of the time this comment was written, the encoded transaction is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgTx) IsCoinBase ¶
IsCoinBase determines whether or not a transaction is a coinbase transaction. A coinbase transaction is a special transaction created by miners that distributes fees and block subsidy to the previous blocks' miners, and to specify the scriptPubKey that will be used to pay the current miner in future blocks. Each input of the coinbase transaction should set index to maximum value and reference the relevant block id, instead of previous transaction id.
func (*MsgTx) IsSubnetworkCompatible ¶
func (msg *MsgTx) IsSubnetworkCompatible(subnetworkID *subnetworkid.SubnetworkID) bool
IsSubnetworkCompatible return true iff subnetworkID is one or more of the following: 1. The SupportsAll subnetwork (full node) 2. The native subnetwork 3. The transaction's subnetwork
func (*MsgTx) KaspaDecode ¶
KaspaDecode decodes r using the kaspa protocol encoding into the receiver. This is part of the Message interface implementation. See Deserialize for decoding transactions stored to disk, such as in a database, as opposed to decoding transactions from the appmessage.
func (*MsgTx) KaspaEncode ¶
KaspaEncode encodes the receiver to w using the kaspa protocol encoding. This is part of the Message interface implementation. See Serialize for encoding transactions to be stored to disk, such as in a database, as opposed to encoding transactions for the appmessage.
func (*MsgTx) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*MsgTx) MessageNumber ¶
func (b *MsgTx) MessageNumber() uint64
func (*MsgTx) ReceivedAt ¶
func (*MsgTx) ScriptPubKeyLocs ¶
ScriptPubKeyLocs returns a slice containing the start of each public key script within the raw serialized transaction. The caller can easily obtain the length of each script by using len on the script available via the appropriate transaction output entry.
func (*MsgTx) Serialize ¶
Serialize encodes the transaction to w using a format that suitable for long-term storage such as a database while respecting the Version field in the transaction. This function differs from KaspaEncode in that KaspaEncode encodes the transaction to the kaspa appmessage protocol in order to be sent across the network. The appmessage encoding can technically differ depending on the protocol version and doesn't even really need to match the format of a stored transaction at all. As of the time this comment was written, the encoded transaction is the same in both instances, but there is a distinct difference and separating the two allows the API to be flexible enough to deal with changes.
func (*MsgTx) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the transaction.
func (*MsgTx) SetMessageNumber ¶
func (b *MsgTx) SetMessageNumber(messageNumber uint64)
func (*MsgTx) SetReceivedAt ¶
type MsgVerAck ¶
type MsgVerAck struct {
// contains filtered or unexported fields
}
MsgVerAck defines a kaspa verack message which is used for a peer to acknowledge a version message (MsgVersion) after it has used the information to negotiate parameters. It implements the Message interface.
This message has no payload.
func NewMsgVerAck ¶
func NewMsgVerAck() *MsgVerAck
NewMsgVerAck returns a new kaspa verack message that conforms to the Message interface.
func (*MsgVerAck) Command ¶
func (msg *MsgVerAck) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVerAck) MessageNumber ¶
func (b *MsgVerAck) MessageNumber() uint64
func (*MsgVerAck) ReceivedAt ¶
func (*MsgVerAck) SetMessageNumber ¶
func (b *MsgVerAck) SetMessageNumber(messageNumber uint64)
func (*MsgVerAck) SetReceivedAt ¶
type MsgVersion ¶
type MsgVersion struct { // Version of the protocol the node is using. ProtocolVersion uint32 // The peer's network (mainnet, testnet, etc.) Network string // Bitfield which identifies the enabled services. Services ServiceFlag // Time the message was generated. This is encoded as an int64 on the appmessage. Timestamp mstime.Time // Address of the local peer. Address *NetAddress // The peer unique ID ID *id.ID // The user agent that generated messsage. This is a encoded as a varString // on the appmessage. This has a max length of MaxUserAgentLen. UserAgent string // The selected tip hash of the generator of the version message. SelectedTipHash *daghash.Hash // Don't announce transactions to peer. DisableRelayTx bool // The subnetwork of the generator of the version message. Should be nil in full nodes SubnetworkID *subnetworkid.SubnetworkID // contains filtered or unexported fields }
MsgVersion implements the Message interface and represents a kaspa version message. It is used for a peer to advertise itself as soon as an outbound connection is made. The remote peer then uses this information along with its own to negotiate. The remote peer must then respond with a version message of its own containing the negotiated values followed by a verack message (MsgVerAck). This exchange must take place before any further communication is allowed to proceed.
func NewMsgVersion ¶
func NewMsgVersion(addr *NetAddress, id *id.ID, network string, selectedTipHash *daghash.Hash, subnetworkID *subnetworkid.SubnetworkID) *MsgVersion
NewMsgVersion returns a new kaspa version message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*MsgVersion) AddService ¶
func (msg *MsgVersion) AddService(service ServiceFlag)
AddService adds service as a supported service by the peer generating the message.
func (*MsgVersion) AddUserAgent ¶
func (msg *MsgVersion) AddUserAgent(name string, version string, comments ...string)
AddUserAgent adds a user agent to the user agent string for the version message. The version string is not defined to any strict format, although it is recommended to use the form "major.minor.revision" e.g. "2.6.41".
func (*MsgVersion) Command ¶
func (msg *MsgVersion) Command() MessageCommand
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*MsgVersion) HasService ¶
func (msg *MsgVersion) HasService(service ServiceFlag) bool
HasService returns whether the specified service is supported by the peer that generated the message.
func (*MsgVersion) MessageNumber ¶
func (b *MsgVersion) MessageNumber() uint64
func (*MsgVersion) ReceivedAt ¶
func (*MsgVersion) SetMessageNumber ¶
func (b *MsgVersion) SetMessageNumber(messageNumber uint64)
func (*MsgVersion) SetReceivedAt ¶
type NetAddress ¶
type NetAddress struct { // Last time the address was seen. Timestamp mstime.Time // Bitfield which identifies the services supported by the address. Services ServiceFlag // IP address of the peer. IP net.IP // Port the peer is using. This is encoded in big endian on the appmessage // which differs from most everything else. Port uint16 }
NetAddress defines information about a peer on the network including the time it was last seen, the services it supports, its IP address, and port.
func NewNetAddress ¶
func NewNetAddress(addr *net.TCPAddr, services ServiceFlag) *NetAddress
NewNetAddress returns a new NetAddress using the provided TCP address and supported services with defaults for the remaining fields.
func NewNetAddressIPPort ¶
func NewNetAddressIPPort(ip net.IP, port uint16, services ServiceFlag) *NetAddress
NewNetAddressIPPort returns a new NetAddress using the provided IP, port, and supported services with defaults for the remaining fields.
func NewNetAddressTimestamp ¶
func NewNetAddressTimestamp( timestamp mstime.Time, services ServiceFlag, ip net.IP, port uint16) *NetAddress
NewNetAddressTimestamp returns a new NetAddress using the provided timestamp, IP, port, and supported services. The timestamp is rounded to single millisecond precision.
func (*NetAddress) AddService ¶
func (na *NetAddress) AddService(service ServiceFlag)
AddService adds service as a supported service by the peer generating the message.
func (*NetAddress) HasService ¶
func (na *NetAddress) HasService(service ServiceFlag) bool
HasService returns whether the specified service is supported by the address.
func (*NetAddress) TCPAddress ¶
func (na *NetAddress) TCPAddress() *net.TCPAddr
TCPAddress converts the NetAddress to *net.TCPAddr
type NotifyBlockAddedRequestMessage ¶
type NotifyBlockAddedRequestMessage struct {
// contains filtered or unexported fields
}
NotifyBlockAddedRequestMessage is an appmessage corresponding to its respective RPC message
func NewNotifyBlockAddedRequestMessage ¶
func NewNotifyBlockAddedRequestMessage() *NotifyBlockAddedRequestMessage
NewNotifyBlockAddedRequestMessage returns a instance of the message
func (*NotifyBlockAddedRequestMessage) Command ¶
func (msg *NotifyBlockAddedRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*NotifyBlockAddedRequestMessage) MessageNumber ¶
func (b *NotifyBlockAddedRequestMessage) MessageNumber() uint64
func (*NotifyBlockAddedRequestMessage) ReceivedAt ¶
func (*NotifyBlockAddedRequestMessage) SetMessageNumber ¶
func (b *NotifyBlockAddedRequestMessage) SetMessageNumber(messageNumber uint64)
func (*NotifyBlockAddedRequestMessage) SetReceivedAt ¶
type NotifyBlockAddedResponseMessage ¶
type NotifyBlockAddedResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
NotifyBlockAddedResponseMessage is an appmessage corresponding to its respective RPC message
func NewNotifyBlockAddedResponseMessage ¶
func NewNotifyBlockAddedResponseMessage() *NotifyBlockAddedResponseMessage
NewNotifyBlockAddedResponseMessage returns a instance of the message
func (*NotifyBlockAddedResponseMessage) Command ¶
func (msg *NotifyBlockAddedResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*NotifyBlockAddedResponseMessage) MessageNumber ¶
func (b *NotifyBlockAddedResponseMessage) MessageNumber() uint64
func (*NotifyBlockAddedResponseMessage) ReceivedAt ¶
func (*NotifyBlockAddedResponseMessage) SetMessageNumber ¶
func (b *NotifyBlockAddedResponseMessage) SetMessageNumber(messageNumber uint64)
func (*NotifyBlockAddedResponseMessage) SetReceivedAt ¶
type NotifyChainChangedRequestMessage ¶
type NotifyChainChangedRequestMessage struct {
// contains filtered or unexported fields
}
NotifyChainChangedRequestMessage is an appmessage corresponding to its respective RPC message
func NewNotifyChainChangedRequestMessage ¶
func NewNotifyChainChangedRequestMessage() *NotifyChainChangedRequestMessage
NewNotifyChainChangedRequestMessage returns a instance of the message
func (*NotifyChainChangedRequestMessage) Command ¶
func (msg *NotifyChainChangedRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*NotifyChainChangedRequestMessage) MessageNumber ¶
func (b *NotifyChainChangedRequestMessage) MessageNumber() uint64
func (*NotifyChainChangedRequestMessage) ReceivedAt ¶
func (*NotifyChainChangedRequestMessage) SetMessageNumber ¶
func (b *NotifyChainChangedRequestMessage) SetMessageNumber(messageNumber uint64)
func (*NotifyChainChangedRequestMessage) SetReceivedAt ¶
type NotifyChainChangedResponseMessage ¶
type NotifyChainChangedResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
NotifyChainChangedResponseMessage is an appmessage corresponding to its respective RPC message
func NewNotifyChainChangedResponseMessage ¶
func NewNotifyChainChangedResponseMessage() *NotifyChainChangedResponseMessage
NewNotifyChainChangedResponseMessage returns a instance of the message
func (*NotifyChainChangedResponseMessage) Command ¶
func (msg *NotifyChainChangedResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*NotifyChainChangedResponseMessage) MessageNumber ¶
func (b *NotifyChainChangedResponseMessage) MessageNumber() uint64
func (*NotifyChainChangedResponseMessage) ReceivedAt ¶
func (*NotifyChainChangedResponseMessage) SetMessageNumber ¶
func (b *NotifyChainChangedResponseMessage) SetMessageNumber(messageNumber uint64)
func (*NotifyChainChangedResponseMessage) SetReceivedAt ¶
type NotifyFinalityConflictsRequestMessage ¶
type NotifyFinalityConflictsRequestMessage struct {
// contains filtered or unexported fields
}
NotifyFinalityConflictsRequestMessage is an appmessage corresponding to its respective RPC message
func NewNotifyFinalityConflictsRequestMessage ¶
func NewNotifyFinalityConflictsRequestMessage() *NotifyFinalityConflictsRequestMessage
NewNotifyFinalityConflictsRequestMessage returns a instance of the message
func (*NotifyFinalityConflictsRequestMessage) Command ¶
func (msg *NotifyFinalityConflictsRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*NotifyFinalityConflictsRequestMessage) MessageNumber ¶
func (b *NotifyFinalityConflictsRequestMessage) MessageNumber() uint64
func (*NotifyFinalityConflictsRequestMessage) ReceivedAt ¶
func (*NotifyFinalityConflictsRequestMessage) SetMessageNumber ¶
func (b *NotifyFinalityConflictsRequestMessage) SetMessageNumber(messageNumber uint64)
func (*NotifyFinalityConflictsRequestMessage) SetReceivedAt ¶
type NotifyFinalityConflictsResponseMessage ¶
type NotifyFinalityConflictsResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
NotifyFinalityConflictsResponseMessage is an appmessage corresponding to its respective RPC message
func NewNotifyFinalityConflictsResponseMessage ¶
func NewNotifyFinalityConflictsResponseMessage() *NotifyFinalityConflictsResponseMessage
NewNotifyFinalityConflictsResponseMessage returns a instance of the message
func (*NotifyFinalityConflictsResponseMessage) Command ¶
func (msg *NotifyFinalityConflictsResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*NotifyFinalityConflictsResponseMessage) MessageNumber ¶
func (b *NotifyFinalityConflictsResponseMessage) MessageNumber() uint64
func (*NotifyFinalityConflictsResponseMessage) ReceivedAt ¶
func (*NotifyFinalityConflictsResponseMessage) SetMessageNumber ¶
func (b *NotifyFinalityConflictsResponseMessage) SetMessageNumber(messageNumber uint64)
func (*NotifyFinalityConflictsResponseMessage) SetReceivedAt ¶
type Outpoint ¶
Outpoint defines a kaspa data type that is used to track previous transaction outputs.
func NewOutpoint ¶
NewOutpoint returns a new kaspa transaction outpoint point with the provided hash and index.
type RPCError ¶
type RPCError struct {
Message string
}
RPCError represents an error arriving from the RPC
type ResolveFinalityConflictRequestMessage ¶
type ResolveFinalityConflictRequestMessage struct { FinalityBlockHash string // contains filtered or unexported fields }
ResolveFinalityConflictRequestMessage is an appmessage corresponding to its respective RPC message
func NewResolveFinalityConflictRequestMessage ¶
func NewResolveFinalityConflictRequestMessage(finalityBlockHash string) *ResolveFinalityConflictRequestMessage
NewResolveFinalityConflictRequestMessage returns a instance of the message
func (*ResolveFinalityConflictRequestMessage) Command ¶
func (msg *ResolveFinalityConflictRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*ResolveFinalityConflictRequestMessage) MessageNumber ¶
func (b *ResolveFinalityConflictRequestMessage) MessageNumber() uint64
func (*ResolveFinalityConflictRequestMessage) ReceivedAt ¶
func (*ResolveFinalityConflictRequestMessage) SetMessageNumber ¶
func (b *ResolveFinalityConflictRequestMessage) SetMessageNumber(messageNumber uint64)
func (*ResolveFinalityConflictRequestMessage) SetReceivedAt ¶
type ResolveFinalityConflictResponseMessage ¶
type ResolveFinalityConflictResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
ResolveFinalityConflictResponseMessage is an appmessage corresponding to its respective RPC message
func NewResolveFinalityConflictResponseMessage ¶
func NewResolveFinalityConflictResponseMessage() *ResolveFinalityConflictResponseMessage
NewResolveFinalityConflictResponseMessage returns a instance of the message
func (*ResolveFinalityConflictResponseMessage) Command ¶
func (msg *ResolveFinalityConflictResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*ResolveFinalityConflictResponseMessage) MessageNumber ¶
func (b *ResolveFinalityConflictResponseMessage) MessageNumber() uint64
func (*ResolveFinalityConflictResponseMessage) ReceivedAt ¶
func (*ResolveFinalityConflictResponseMessage) SetMessageNumber ¶
func (b *ResolveFinalityConflictResponseMessage) SetMessageNumber(messageNumber uint64)
func (*ResolveFinalityConflictResponseMessage) SetReceivedAt ¶
type ScriptPubKeyResult ¶
ScriptPubKeyResult holds data about a script public key
type ServiceFlag ¶
type ServiceFlag uint64
ServiceFlag identifies services supported by a kaspa peer.
const ( // SFNodeNetwork is a flag used to indicate a peer is a full node. SFNodeNetwork ServiceFlag = 1 << iota // SFNodeGetUTXO is a flag used to indicate a peer supports the // getutxos and utxos commands (BIP0064). SFNodeGetUTXO // SFNodeBloom is a flag used to indicate a peer supports bloom // filtering. SFNodeBloom // SFNodeXthin is a flag used to indicate a peer supports xthin blocks. SFNodeXthin // SFNodeBit5 is a flag used to indicate a peer supports a service // defined by bit 5. SFNodeBit5 // SFNodeCF is a flag used to indicate a peer supports committed // filters (CFs). SFNodeCF )
func (ServiceFlag) String ¶
func (f ServiceFlag) String() string
String returns the ServiceFlag in human-readable form.
type SubmitBlockRequestMessage ¶
type SubmitBlockRequestMessage struct { BlockHex string // contains filtered or unexported fields }
SubmitBlockRequestMessage is an appmessage corresponding to its respective RPC message
func NewSubmitBlockRequestMessage ¶
func NewSubmitBlockRequestMessage(blockHex string) *SubmitBlockRequestMessage
NewSubmitBlockRequestMessage returns a instance of the message
func (*SubmitBlockRequestMessage) Command ¶
func (msg *SubmitBlockRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*SubmitBlockRequestMessage) MessageNumber ¶
func (b *SubmitBlockRequestMessage) MessageNumber() uint64
func (*SubmitBlockRequestMessage) ReceivedAt ¶
func (*SubmitBlockRequestMessage) SetMessageNumber ¶
func (b *SubmitBlockRequestMessage) SetMessageNumber(messageNumber uint64)
func (*SubmitBlockRequestMessage) SetReceivedAt ¶
type SubmitBlockResponseMessage ¶
type SubmitBlockResponseMessage struct { Error *RPCError // contains filtered or unexported fields }
SubmitBlockResponseMessage is an appmessage corresponding to its respective RPC message
func NewSubmitBlockResponseMessage ¶
func NewSubmitBlockResponseMessage() *SubmitBlockResponseMessage
NewSubmitBlockResponseMessage returns a instance of the message
func (*SubmitBlockResponseMessage) Command ¶
func (msg *SubmitBlockResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*SubmitBlockResponseMessage) MessageNumber ¶
func (b *SubmitBlockResponseMessage) MessageNumber() uint64
func (*SubmitBlockResponseMessage) ReceivedAt ¶
func (*SubmitBlockResponseMessage) SetMessageNumber ¶
func (b *SubmitBlockResponseMessage) SetMessageNumber(messageNumber uint64)
func (*SubmitBlockResponseMessage) SetReceivedAt ¶
type SubmitTransactionRequestMessage ¶
type SubmitTransactionRequestMessage struct { TransactionHex string // contains filtered or unexported fields }
SubmitTransactionRequestMessage is an appmessage corresponding to its respective RPC message
func NewSubmitTransactionRequestMessage ¶
func NewSubmitTransactionRequestMessage(transactionHex string) *SubmitTransactionRequestMessage
NewSubmitTransactionRequestMessage returns a instance of the message
func (*SubmitTransactionRequestMessage) Command ¶
func (msg *SubmitTransactionRequestMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*SubmitTransactionRequestMessage) MessageNumber ¶
func (b *SubmitTransactionRequestMessage) MessageNumber() uint64
func (*SubmitTransactionRequestMessage) ReceivedAt ¶
func (*SubmitTransactionRequestMessage) SetMessageNumber ¶
func (b *SubmitTransactionRequestMessage) SetMessageNumber(messageNumber uint64)
func (*SubmitTransactionRequestMessage) SetReceivedAt ¶
type SubmitTransactionResponseMessage ¶
type SubmitTransactionResponseMessage struct { TxID string Error *RPCError // contains filtered or unexported fields }
SubmitTransactionResponseMessage is an appmessage corresponding to its respective RPC message
func NewSubmitTransactionResponseMessage ¶
func NewSubmitTransactionResponseMessage(txID string) *SubmitTransactionResponseMessage
NewSubmitTransactionResponseMessage returns a instance of the message
func (*SubmitTransactionResponseMessage) Command ¶
func (msg *SubmitTransactionResponseMessage) Command() MessageCommand
Command returns the protocol command string for the message
func (*SubmitTransactionResponseMessage) MessageNumber ¶
func (b *SubmitTransactionResponseMessage) MessageNumber() uint64
func (*SubmitTransactionResponseMessage) ReceivedAt ¶
func (*SubmitTransactionResponseMessage) SetMessageNumber ¶
func (b *SubmitTransactionResponseMessage) SetMessageNumber(messageNumber uint64)
func (*SubmitTransactionResponseMessage) SetReceivedAt ¶
type TransactionVerboseData ¶
type TransactionVerboseData struct { Hex string TxID string Hash string Size int32 Version int32 LockTime uint64 SubnetworkID string Gas uint64 PayloadHash string Payload string TransactionVerboseInputs []*TransactionVerboseInput TransactionVerboseOutputs []*TransactionVerboseOutput BlockHash string AcceptedBy string IsInMempool bool Time uint64 BlockTime uint64 }
TransactionVerboseData holds verbose data about a transaction
type TransactionVerboseInput ¶
type TransactionVerboseInput struct { TxID string OutputIndex uint32 ScriptSig *ScriptSig Sequence uint64 }
TransactionVerboseInput holds data about a transaction input
type TransactionVerboseOutput ¶
type TransactionVerboseOutput struct { Value uint64 Index uint32 ScriptPubKey *ScriptPubKeyResult }
TransactionVerboseOutput holds data about a transaction output
type TxIn ¶
TxIn defines a kaspa transaction input.
func NewTxIn ¶
NewTxIn returns a new kaspa transaction input with the provided previous outpoint point and signature script with a default sequence of MaxTxInSequenceNum.
func (*TxIn) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction input.
type TxLoc ¶
TxLoc holds locator data for the offset and length of where a transaction is located within a MsgBlock data buffer.
type TxOut ¶
TxOut defines a kaspa transaction output.
func NewTxOut ¶
NewTxOut returns a new kaspa transaction output with the provided transaction value and public key script.
func (*TxOut) SerializeSize ¶
SerializeSize returns the number of bytes it would take to serialize the the transaction output.
Source Files ¶
- base_message.go
- common.go
- doc.go
- error.go
- message.go
- p2p_blockheader.go
- p2p_msgaddresses.go
- p2p_msgblock.go
- p2p_msgblocklocator.go
- p2p_msgdoneibdblocks.go
- p2p_msgibdblock.go
- p2p_msginvrelayblock.go
- p2p_msginvtransaction.go
- p2p_msgping.go
- p2p_msgpong.go
- p2p_msgreject.go
- p2p_msgrequestaddresses.go
- p2p_msgrequestblocklocator.go
- p2p_msgrequestibdblocks.go
- p2p_msgrequestnextibdblocks.go
- p2p_msgrequestrelayblocks.go
- p2p_msgrequestselectedtip.go
- p2p_msgrequesttransactions.go
- p2p_msgselectedtip.go
- p2p_msgtransactionnotfound.go
- p2p_msgtx.go
- p2p_msgverack.go
- p2p_msgversion.go
- p2p_netaddress.go
- protocol.go
- rpc_add_peer.go
- rpc_get_block.go
- rpc_get_block_count.go
- rpc_get_block_dag_info.go
- rpc_get_block_template.go
- rpc_get_blocks.go
- rpc_get_chain_from_block.go
- rpc_get_connected_peer_info.go
- rpc_get_current_network.go
- rpc_get_mempool_entry.go
- rpc_get_peer_addresses.go
- rpc_get_selected_tip_hash.go
- rpc_get_subnetwork.go
- rpc_notify_block_added.go
- rpc_notify_chain_changed.go
- rpc_notify_finality_conflicts.go
- rpc_resolve_finality_conflict.go
- rpc_submit_block.go
- rpc_submit_transaction.go