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

Function WriteVarint63

encoding/blockchain/blockchain.go:150–159  ·  view source on GitHub ↗
(w io.Writer, val uint64)

Source from the content-addressed store, hash-verified

148}
149
150func WriteVarint63(w io.Writer, val uint64) (int, error) {
151 if val > math.MaxInt64 {
152 return 0, ErrRange
153 }
154 buf := bufPool.Get().(*[9]byte)
155 n := binary.PutUvarint(buf[:], val)
156 b, err := w.Write(buf[:n])
157 bufPool.Put(buf)
158 return b, err
159}
160
161func WriteVarstr31(w io.Writer, str []byte) (int, error) {
162 n, err := WriteVarint31(w, uint64(len(str)))

Callers 3

BenchmarkWriteVarint63Function · 0.85
TestVarint63Function · 0.85
TestReadWriteVarint63Function · 0.85

Calls 2

GetMethod · 0.65
WriteMethod · 0.45

Tested by 3

BenchmarkWriteVarint63Function · 0.68
TestVarint63Function · 0.68
TestReadWriteVarint63Function · 0.68