MCPcopy Create free account
hub / github.com/chain/Core / ReadExtensibleString

Function ReadExtensibleString

encoding/blockchain/blockchain.go:125–137  ·  view source on GitHub ↗

ReadExtensibleString reads a varint31 length prefix and that many bytes from r. It then calls the given function to consume those bytes, returning any unconsumed suffix.

(r *Reader, f func(*Reader) error)

Source from the content-addressed store, hash-verified

123// bytes from r. It then calls the given function to consume those
124// bytes, returning any unconsumed suffix.
125func ReadExtensibleString(r *Reader, f func(*Reader) error) (suffix []byte, err error) {
126 s, err := ReadVarstr31(r)
127 if err != nil {
128 return nil, err
129 }
130
131 sr := NewReader(s)
132 err = f(sr)
133 if err != nil {
134 return nil, err
135 }
136 return sr.buf, nil
137}
138
139func WriteVarint31(w io.Writer, val uint64) (int, error) {
140 if val > math.MaxInt32 {

Callers 1

TestExtensibleStringFunction · 0.85

Calls 3

ReadVarstr31Function · 0.85
NewReaderFunction · 0.85
fFunction · 0.85

Tested by 1

TestExtensibleStringFunction · 0.68