mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-13 01:26:43 +00:00

* [NOD-1225] Rename wire to domainmessage * [NOD-1225] Get rid of references to package wire in the code, and get rid of InvType
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package protowire
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domainmessage"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func (x *KaspadMessage_InvTransactions) toDomainMessage() (domainmessage.Message, error) {
|
|
if len(x.InvTransactions.Ids) > domainmessage.MaxInvPerTxInvMsg {
|
|
return nil, errors.Errorf("too many hashes for message "+
|
|
"[count %d, max %d]", len(x.InvTransactions.Ids), domainmessage.MaxInvPerTxInvMsg)
|
|
}
|
|
|
|
ids, err := protoTransactionIDsToWire(x.InvTransactions.Ids)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &domainmessage.MsgInvTransaction{TxIDs: ids}, nil
|
|
}
|
|
|
|
func (x *KaspadMessage_InvTransactions) fromDomainMessage(msgInvTransaction *domainmessage.MsgInvTransaction) error {
|
|
if len(msgInvTransaction.TxIDs) > domainmessage.MaxInvPerTxInvMsg {
|
|
return errors.Errorf("too many hashes for message "+
|
|
"[count %d, max %d]", len(msgInvTransaction.TxIDs), domainmessage.MaxInvPerTxInvMsg)
|
|
}
|
|
|
|
x.InvTransactions = &InvTransactionsMessage{
|
|
Ids: wireTransactionIDsToProto(msgInvTransaction.TxIDs),
|
|
}
|
|
return nil
|
|
}
|