# README
FastRlp
FastRlp is a high performant encoding/decoding library for the RLP Ethereum format. This library is based on fastjson.
Usage
FastRlp does not uses reflect to avoid bottlenecks. It provides a single value primitive that can be encoded or decoded into any specific type.
Encode:
a := &fastrlp.Arena{}
// Encode a uint
v := a.NewUint(300)
buf := v.MarshalTo(nil)
// Encode an array
v = a.NewArray()
v.Set(a.NewUint(300))
buf = v.MarshalTo(nil)
You can find more examples here.
Decode:
p := &fastrlp.Parser{}
v, err := p.Parse([]byte{0x01})
if err != nil {
panic(err)
}
num, err := v.GetUint64()
if err != nil {
panic(err)
}
fmt.Println(num)
Benchmark
$ go-rlp-test go test -v ./. -run=XX -bench=.
goos: linux
goarch: amd64
pkg: github.com/ferranbt/go-rlp-test
BenchmarkDecode100HeadersGeth-8 10000 196183 ns/op 32638 B/op 1002 allocs/op
BenchmarkEncode100HeadersGeth-8 10000 179328 ns/op 88471 B/op 1003 allocs/op
BenchmarkDecode100HeadersFastRlp-8 30000 57179 ns/op 16 B/op 0 allocs/op
BenchmarkEncode100HeadersFastRlp-8 30000 43967 ns/op 23 B/op 0 allocs/op
PASS
ok github.com/ferranbt/go-rlp-test 7.890s
# Functions
No description provided by the author
MarshalRLP marshals an RLP object.
No description provided by the author
UnmarshalRLP unmarshals an RLP object.
No description provided by the author
No description provided by the author
# Constants
TypeArray is an RLP array value.
TypeArrayNull is an RLP array null (0xC0).
TypeBytes is an RLP bytes value.
TypeNull is an RLP bytes null (0x80).
# Variables
DefaultArenaPool is a default ArenaPool.
DefaultParserPool is a default ParserPool.
# Structs
Arena is a pool of RLP values.
ArenaPool may be used for pooling Arenas for similarly typed RLPs.
No description provided by the author
No description provided by the author
Keccak is the sha256 keccak hash.
Parser is a RLP parser.
ParserPool may be used for pooling Parsers for similarly typed RLPs.
Value is an RLP value.
# Interfaces
No description provided by the author
Marshaler is the interface implemented by types that can marshal themselves into valid RLP messages.
Unmarshaler is the interface implemented by types that can unmarshal a RLP description of themselves.