Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1001 Bytes

README.md

File metadata and controls

46 lines (31 loc) · 1001 Bytes

drlp

Build Status GoDoc Go Report

Short for Direct-RLP: A fast in-place RLP encoder

Installation

It requires Go 1.19 or newer.

go get github.com/qianbin/drlp

Usage

Number and string

var buf []byte
buf = drlp.AppendUint(buf, 10)
buf = drlp.AppendString(buf, []byte("hello drlp"))

fmt.Printf("%x\n", buf)
// Output: 0a8a68656c6c6f2064726c70

List

var buf []byte
buf = drlp.AppendString(buf, []byte("followed by a list"))

offset := len(buf)
buf = drlp.AppendString(buf, []byte("list content"))
buf = drlp.EndList(buf, offset)

fmt.Printf("%x\n", buf[offset:])
// Output: cd8c6c69737420636f6e74656e74

License

The MIT License