mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00

* [NOD-1128] Add all flows to a directory names flows * [NOD-1128] Make everything in protocol package a manager method * [NOD-1128] Add AddTransaction mechanism to protocol manager * [NOD-1128] Add mempool related flows * [NOD-1128] Add mempool related flows * [NOD-1128] Add mempool related flows * [NOD-1127] Fix router message types * [NOD-1127] Inline updateQueues * [NOD-1127] Rename acceptedTxs->transactionsAcceptedToMempool * [NOD-1127] Add TODOs to notify transactions to RPC * [NOD-1127] Fix comment * [NOD-1127] Rename acceptedTxs->transactionsAcceptedToMempool * [NOD-1127] Rename MsgTxInv->MsgInvTransaction * [NOD-1127] Rename MsgTxInv.TXIDs->TxIDS * [NOD-1127] Change flow name * [NOD-1127] Call m.addTransactionRelayFlow * [NOD-1127] Remove redundant line * [NOD-1127] Use common.DefaultTimeout * [NOD-1127] Return early if len(idsToRequest) == 0 * [NOD-1127] Add NewBlockHandler to IBD
50 lines
1.7 KiB
Go
50 lines
1.7 KiB
Go
package wire
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/util/daghash"
|
|
"io"
|
|
)
|
|
|
|
// MsgGetRelayBlocksHashes is the maximum number of hashes that can
|
|
// be in a single getrelblks message.
|
|
const MsgGetRelayBlocksHashes = MaxInvPerMsg
|
|
|
|
// MsgGetRelayBlocks implements the Message interface and represents a kaspa
|
|
// getrelblks message. It is used to request blocks as part of the block
|
|
// relay protocol.
|
|
type MsgGetRelayBlocks struct {
|
|
Hashes []*daghash.Hash
|
|
}
|
|
|
|
// KaspaDecode decodes r using the kaspa protocol encoding into the receiver.
|
|
// This is part of the Message interface implementation.
|
|
func (msg *MsgGetRelayBlocks) KaspaDecode(r io.Reader, pver uint32) error {
|
|
return ReadElement(r, &msg.Hashes)
|
|
}
|
|
|
|
// KaspaEncode encodes the receiver to w using the kaspa protocol encoding.
|
|
// This is part of the Message interface implementation.
|
|
func (msg *MsgGetRelayBlocks) KaspaEncode(w io.Writer, pver uint32) error {
|
|
return WriteElement(w, msg.Hashes)
|
|
}
|
|
|
|
// Command returns the protocol command string for the message. This is part
|
|
// of the Message interface implementation.
|
|
func (msg *MsgGetRelayBlocks) Command() MessageCommand {
|
|
return CmdGetRelayBlocks
|
|
}
|
|
|
|
// MaxPayloadLength returns the maximum length the payload can be for the
|
|
// receiver. This is part of the Message interface implementation.
|
|
func (msg *MsgGetRelayBlocks) MaxPayloadLength(pver uint32) uint32 {
|
|
return daghash.HashSize*MsgGetRelayBlocksHashes + uint32(VarIntSerializeSize(MsgGetRelayBlocksHashes))
|
|
}
|
|
|
|
// NewMsgGetRelayBlocks returns a new kaspa getrelblks message that conforms to
|
|
// the Message interface. See MsgGetRelayBlocks for details.
|
|
func NewMsgGetRelayBlocks(hashes []*daghash.Hash) *MsgGetRelayBlocks {
|
|
return &MsgGetRelayBlocks{
|
|
Hashes: hashes,
|
|
}
|
|
}
|