go-pulse/rlp
Felix Lange 9b93564e21
rlp/rlpgen: RLP encoder code generator (#24251)
This change adds a code generator tool for creating EncodeRLP method
implementations. The generated methods will behave identically to the
reflect-based encoder, but run faster because there is no reflection overhead.

Package rlp now provides the EncoderBuffer type for incremental encoding. This
is used by generated code, but the new methods can also be useful for
hand-written encoders.

There is also experimental support for generating DecodeRLP, and some new
methods have been added to the existing Stream type to support this. Creating
decoders with rlpgen is not recommended at this time because the generated
methods create very poor error reporting.

More detail about package rlp changes:

* rlp: externalize struct field processing / validation

This adds a new package, rlp/internal/rlpstruct, in preparation for the
RLP encoder generator.

I think the struct field rules are subtle enough to warrant extracting
this into their own package, even though it means that a bunch of
adapter code is needed for converting to/from rlpstruct.Type.

* rlp: add more decoder methods (for rlpgen)

This adds new methods on rlp.Stream:

- Uint64, Uint32, Uint16, Uint8, BigInt
- ReadBytes for decoding into []byte
- MoreDataInList - useful for optional list elements

* rlp: expose encoder buffer (for rlpgen)

This exposes the internal encoder buffer type for use in EncodeRLP
implementations.

The new EncoderBuffer type is a sort-of 'opaque handle' for a pointer to
encBuffer. It is implemented this way to ensure the global encBuffer pool
is handled correctly.
2022-02-16 18:14:12 +01:00
..
internal/rlpstruct rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
rlpgen rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
decode_tail_test.go all: update license information 2016-04-15 09:48:05 +02:00
decode_test.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
decode.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
doc.go rlp: add support for optional struct fields (#22832) 2021-05-07 14:37:13 +02:00
encbuffer_example_test.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
encbuffer.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
encode_test.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
encode.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
encoder_example_test.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
iterator_test.go cmd, core, eth: background transaction indexing (#20302) 2020-05-11 18:58:43 +03:00
iterator.go core/rawdb: fix transaction indexing/unindexing hashing error (#22457) 2021-03-16 12:15:14 +02:00
raw_test.go all: fix warning flagging the use of DeepEqual on error (#23624) 2021-10-19 17:06:47 +02:00
raw.go p2p/rlpx: reduce allocation and syscalls (#22899) 2021-05-27 10:19:13 +02:00
safe.go rlp: minor optimizations for slice/array encoding (#23467) 2021-08-25 19:01:10 +02:00
typecache.go rlp/rlpgen: RLP encoder code generator (#24251) 2022-02-16 18:14:12 +01:00
unsafe.go rlp: minor optimizations for slice/array encoding (#23467) 2021-08-25 19:01:10 +02:00