MCPcopy
hub / github.com/canopy-network/canopy / Marshal

Function Marshal

lib/util.go:258–268  ·  view source on GitHub ↗

Marshal() serializes a proto.Message into a byte slice

(message any)

Source from the content-addressed store, hash-verified

256
257// Marshal() serializes a proto.Message into a byte slice
258func Marshal(message any) ([]byte, ErrorI) {
259 // convert the message into proto bytes using the proto marshaller
260 protoBytes, err := marshaller.Marshal(message.(proto.Message))
261 // if an error occurred during the conversion process
262 if err != nil {
263 // exit with a wrapped error
264 return nil, ErrMarshal(err)
265 }
266 // exit
267 return protoBytes, nil
268}
269
270// Unmarshal() deserializes a byte slice into a proto.Message
271func Unmarshal(protoBytes []byte, ptr any) ErrorI {

Callers 15

ProduceProposalMethod · 0.92
TestGetTxByHashFunction · 0.92
TestGetTxByHeightFunction · 0.92
setCommitIDMethod · 0.92
bytesMethod · 0.92
IndexBlockMethod · 0.92
IndexQCMethod · 0.92
GetQCByHeightMethod · 0.92
IndexTxMethod · 0.92
indexEventByHashMethod · 0.92
getBlockMethod · 0.92
SetOrderBookMethod · 0.92

Calls 2

ErrMarshalFunction · 0.70
MarshalMethod · 0.65

Tested by 15

TestGetTxByHashFunction · 0.74
TestGetTxByHeightFunction · 0.74
TestApplyTransactionFunction · 0.74
TestCheckTxFunction · 0.74
TestIncrementNonSignersFunction · 0.74
TestApplyBlockFunction · 0.74
TestRLPStakingFunction · 0.74
TestMaxPacketSizeFunction · 0.74
TestGetInboxStatsFunction · 0.74