kaspad/netadapter/server/grpcserver/protowire/message_inv_transactions.go
Ori Newman 8e170cf327
[NOD-1225] Rename wire to domainmessage and get rid of InvType (#853)
* [NOD-1225] Rename wire to domainmessage

* [NOD-1225] Get rid of references to package wire in the code, and get rid of InvType
2020-08-09 12:39:15 +03:00

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
}