瀏覽代碼

rlp: add ListSize

Felix Lange 10 年之前
父節點
當前提交
8743cc1c1c
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      rlp/encode.go

+ 6 - 0
rlp/encode.go

@@ -29,6 +29,12 @@ type Encoder interface {
 	EncodeRLP(io.Writer) error
 }
 
+// ListSize returns the encoded size of an RLP list with the given
+// content size.
+func ListSize(contentSize uint64) uint64 {
+	return uint64(headsize(contentSize)) + contentSize
+}
+
 // Encode writes the RLP encoding of val to w. Note that Encode may
 // perform many small writes in some cases. Consider making w
 // buffered.