mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 09:21:42 +03:00
ethereum: accept plain atoms for rlp encoding
It will measure them for you, making it easier to encode lists containing both fixed- and variable-width numbers. Largely obviates the need for +encode-atoms.
This commit is contained in:
parent
0c1e999cdb
commit
d33f851466
@ -44,7 +44,7 @@
|
|||||||
--
|
--
|
||||||
::
|
::
|
||||||
:: rlp en/decoding
|
:: rlp en/decoding
|
||||||
::NOTE https://github.com/ethereum/wiki/wiki/RLP
|
::NOTE https://eth.wiki/en/fundamentals/rlp
|
||||||
::
|
::
|
||||||
++ rlp
|
++ rlp
|
||||||
|%
|
|%
|
||||||
@ -53,29 +53,31 @@
|
|||||||
:: and one-byte zero (and also empty list) we end up with
|
:: and one-byte zero (and also empty list) we end up with
|
||||||
:: this awful type...
|
:: this awful type...
|
||||||
+$ item
|
+$ item
|
||||||
|
$@ @
|
||||||
$% [%l l=(list item)]
|
$% [%l l=(list item)]
|
||||||
[%b b=byts]
|
[%b b=byts]
|
||||||
==
|
==
|
||||||
:: +encode-atoms: encode list of atoms as a %l of %b items
|
:: +encode-atoms: encode list of atoms as a %l of %b items
|
||||||
::
|
::
|
||||||
++ encode-atoms
|
++ encode-atoms ::NOTE deprecated
|
||||||
|= l=(list @)
|
|= l=(list @)
|
||||||
^- @
|
^- @
|
||||||
%+ encode %l
|
(encode l+l)
|
||||||
%+ turn l
|
|
||||||
|=(a=@ b+[(met 3 a) a])
|
|
||||||
::
|
::
|
||||||
++ encode
|
++ encode
|
||||||
|= in=item
|
|= in=item
|
||||||
|^ ^- @
|
|^ ^- @
|
||||||
?- -.in
|
?- in
|
||||||
%b
|
@
|
||||||
|
$(in [%b (met 3 in) in])
|
||||||
|
::
|
||||||
|
[%b *]
|
||||||
?: &(=(1 wid.b.in) (lte dat.b.in 0x7f))
|
?: &(=(1 wid.b.in) (lte dat.b.in 0x7f))
|
||||||
dat.b.in
|
dat.b.in
|
||||||
=- (can 3 ~[b.in [(met 3 -) -]])
|
=- (can 3 ~[b.in [(met 3 -) -]])
|
||||||
(encode-length wid.b.in 0x80)
|
(encode-length wid.b.in 0x80)
|
||||||
::
|
::
|
||||||
%l
|
[%l *]
|
||||||
:: we +can because b+1^0x0 encodes to 0x00
|
:: we +can because b+1^0x0 encodes to 0x00
|
||||||
::
|
::
|
||||||
=/ l=(list byts)
|
=/ l=(list byts)
|
||||||
@ -640,7 +642,7 @@
|
|||||||
?~ tob.req ~
|
?~ tob.req ~
|
||||||
`['toBlock' (block-to-json u.tob.req)]
|
`['toBlock' (block-to-json u.tob.req)]
|
||||||
::
|
::
|
||||||
::TODO fucking tmi
|
::NOTE tmi
|
||||||
?: =(0 (lent adr.req)) ~
|
?: =(0 (lent adr.req)) ~
|
||||||
:+ ~ 'address'
|
:+ ~ 'address'
|
||||||
?: =(1 (lent adr.req)) (tape (address-to-hex (snag 0 adr.req)))
|
?: =(1 (lent adr.req)) (tape (address-to-hex (snag 0 adr.req)))
|
||||||
|
Loading…
Reference in New Issue
Block a user