tlv+record+routing: add payload size calculation
This commit is contained in:
4 files changed
+121
-1
No files matched your search
@@ -4,6 +4,8 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
|
||||
// ErrVarIntNotCanonical signals that the decoded varint was not minimally encoded.
|
||||
@@ -107,3 +109,8 @@ func WriteVarInt(w io.Writer, val uint64, buf *[8]byte) error {
|
||||
_, err := w.Write(buf[:length])
|
||||
return err
|
||||
}
|
||||
|
||||
// VarIntSize returns the required number of bytes to encode a var int.
|
||||
func VarIntSize(val uint64) uint64 {
|
||||
return uint64(wire.VarIntSerializeSize(val))
|
||||
}
|
||||
Reference in new issue
Block a user