32ae696

commit: 32ae696
comment: 1. Moved string util 2.Make Serializing block 3.Changed Tx serialization to return bytes instead of a string

封裝(pack)與解封裝(unpack)這筆資料(另一個常用的稱呼為 "marshal"與 "unmarshal") 這邊架構還有些混亂,serialization.go負責的RlpEncode與block.go中的MarshalRlp及transaction.go中的MarshalRlp,這三者概念容易混淆。 RlpEncode中負責將傳入的列表按造Rlp編碼定義來編碼,因為編碼不會破壞列表中元素的先後順序,所以可以說是序列化(serialization)。 而MarshalRlp像是定義一個序列化的結構,在MarshalRlp中定義一個struct,列如 {A,B,C},然後透過RlpEncode變成binary,binary可用於儲存或傳輸,然後再經由反向的RlpDecode與Unmarshal還原成struct {A,B,C}。

這邊還沒有RlpDecode與Unmarshal,但是已經有預留伏筆,

result:

init Ethereum VM
stack size = 256

# processing Tx (8fee28c5311d91212d92cbf14548e9e96ab39a)
# fee = 0.000000, ops = 12, sender = 1234567890, value = 20

# processing Tx (3ab78afb9e495acc6eabd8982730dbb679db2f)
# fee = 0.000000, ops = 2, sender = 1234567890, value = 20
0   67 [10 6 0 0 0 0]
1   67 [10 6 0 0 0 0]
# finished processing Tx

2   66 [10 10 0 0 0 0]
3   67 [255 7 0 0 0 0]
4   81 [20 255 0 0 0 0]
... JMP 7 ...
7   66 [30 31 0 0 0 0]
8   67 [255 22 0 0 0 0]
9   81 [31 255 0 0 0 0]
... JMP 22 ...
# finished processing Tx

rlp encoded Tx "\x01\x00\x010\x00\n1234567890\x00\x010\x00\x0220\x00\x010\x01\x00\x06395843\x00\x06657986\x00\t335612448\x00\x06524099\x00\b16716881\x00\x010\x00\b13114947\x00\a2039362\x00\a1507139\x00\b16719697\x00\a1048387\x00\x0565360"
block enc "\x01\x00\x010\x00\x00\x00\x00\x00 mi\u007f\xb0\b\x91A\xd0P\x1f\xb7\xf9\x1cd\xb1ӑ{\xc2ѕ&X\xa4\u007f\xad\xea\x95\v\xed\xc8="
block hash "39e507d0bc23032af0fc1ad2d979c27d31968fc9ed69c4e3000fed172305e24d"

Process finished with exit code 0