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

Function WriteExtensibleString

encoding/blockchain/blockchain.go:189–203  ·  view source on GitHub ↗

WriteExtensibleString sends the output of the given function, plus the given suffix, to w, together with a varint31 length prefix.

(w io.Writer, suffix []byte, f func(io.Writer) error)

Source from the content-addressed store, hash-verified

187// WriteExtensibleString sends the output of the given function, plus
188// the given suffix, to w, together with a varint31 length prefix.
189func WriteExtensibleString(w io.Writer, suffix []byte, f func(io.Writer) error) (int, error) {
190 buf := bufpool.Get()
191 defer bufpool.Put(buf)
192 err := f(buf)
193 if err != nil {
194 return 0, err
195 }
196 if len(suffix) > 0 {
197 _, err := buf.Write(suffix)
198 if err != nil {
199 return 0, err
200 }
201 }
202 return WriteVarstr31(w, buf.Bytes())
203}

Callers 1

TestExtensibleStringFunction · 0.85

Calls 5

fFunction · 0.85
WriteVarstr31Function · 0.85
GetMethod · 0.65
WriteMethod · 0.45
BytesMethod · 0.45

Tested by 1

TestExtensibleStringFunction · 0.68