mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08: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"
|
|
)
|
|
|
|
// MaxInvPerGetTransactionsMsg is the maximum number of hashes that can
|
|
// be in a single CmdInvTransaction message.
|
|
const MaxInvPerGetTransactionsMsg = MaxInvPerMsg
|
|
|
|
// MsgGetTransactions implements the Message interface and represents a kaspa
|
|
// GetTransactions message. It is used to request transactions as part of the
|
|
// transactions relay protocol.
|
|
type MsgGetTransactions struct {
|
|
IDs []*daghash.TxID
|
|
}
|
|
|
|
// KaspaDecode decodes r using the kaspa protocol encoding into the receiver.
|
|
// This is part of the Message interface implementation.
|
|
func (msg *MsgGetTransactions) KaspaDecode(r io.Reader, pver uint32) error {
|
|
return ReadElement(r, &msg.IDs)
|
|
}
|
|
|
|
// KaspaEncode encodes the receiver to w using the kaspa protocol encoding.
|
|
// This is part of the Message interface implementation.
|
|
func (msg *MsgGetTransactions) KaspaEncode(w io.Writer, pver uint32) error {
|
|
return WriteElement(w, msg.IDs)
|
|
}
|
|
|
|
// Command returns the protocol command string for the message. This is part
|
|
// of the Message interface implementation.
|
|
func (msg *MsgGetTransactions) Command() MessageCommand {
|
|
return CmdGetTransactions
|
|
}
|
|
|
|
// MaxPayloadLength returns the maximum length the payload can be for the
|
|
// receiver. This is part of the Message interface implementation.
|
|
func (msg *MsgGetTransactions) MaxPayloadLength(pver uint32) uint32 {
|
|
return daghash.TxIDSize*MaxInvPerGetTransactionsMsg + uint32(VarIntSerializeSize(MaxInvPerGetTransactionsMsg))
|
|
}
|
|
|
|
// NewMsgGetTransactions returns a new kaspa GetTransactions message that conforms to
|
|
// the Message interface. See MsgGetTransactions for details.
|
|
func NewMsgGetTransactions(ids []*daghash.TxID) *MsgGetTransactions {
|
|
return &MsgGetTransactions{
|
|
IDs: ids,
|
|
}
|
|
}
|