MCPcopy Create free account
hub / github.com/chain/txvm / MarshalText

Method MarshalText

protocol/bc/hash.go:49–54  ·  view source on GitHub ↗

MarshalText satisfies the TextMarshaler interface. It returns the bytes of h encoded in hex, for formats that can't hold arbitrary binary data. It never returns an error.

()

Source from the content-addressed store, hash-verified

47// for formats that can't hold arbitrary binary data.
48// It never returns an error.
49func (h Hash) MarshalText() ([]byte, error) {
50 b := h.Byte32()
51 v := make([]byte, 64)
52 hex.Encode(v, b[:])
53 return v, nil
54}
55
56// UnmarshalText satisfies the TextUnmarshaler interface.
57// It decodes hex data from b into h.

Callers 2

TestHashMarshalTextFunction · 0.95
TestBlockMarshalFunction · 0.45

Calls 2

Byte32Method · 0.95
EncodeMethod · 0.80

Tested by 2

TestHashMarshalTextFunction · 0.76
TestBlockMarshalFunction · 0.36