MCPcopy Create free account
hub / github.com/MinterTeam/minter-go-node / Encode

Function Encode

rlp/encode.go:53–66  ·  view source on GitHub ↗

Encode writes the RLP encoding of val to w. Note that Encode may perform many small writes in some cases. Consider making w buffered. Please see package-level documentation of encoding rules.

(w io.Writer, val interface{})

Source from the content-addressed store, hash-verified

51//
52// Please see package-level documentation of encoding rules.
53func Encode(w io.Writer, val interface{}) error {
54 if outer, ok := w.(*encbuf); ok {
55 // Encode was called by some type's EncodeRLP.
56 // Avoid copying by writing to the outer encbuf directly.
57 return outer.encode(val)
58 }
59 eb := encbufPool.Get().(*encbuf)
60 defer encbufPool.Put(eb)
61 eb.reset()
62 if err := eb.encode(val); err != nil {
63 return err
64 }
65 return eb.toWriter(w)
66}
67
68// EncodeToBytes returns the RLP encoding of val.
69// Please see package-level documentation for the encoding rules.

Calls 5

resetMethod · 0.80
toWriterMethod · 0.80
GetMethod · 0.65
encodeMethod · 0.45
PutMethod · 0.45