web3.eth.getTransactionReceipt gibt ein Objekt mit einer root
Eigenschaft zurück und ist derzeit im Wiki nicht dokumentiert .
Result: {
...
"root": "7583254379574ee8eb2943c3ee41582a0041156215e2c7d82e363098c89fe21b",
"to": "0x91067b439e1be22196a5f64ee61e803670ba5be9",
"transactionHash": "0xad62c939b2e865f13c61eebcb221d2c9737955e506b69fb624210d3fd4e0035b",
"transactionIndex": 0
}
Was ist das root
? Es ist nicht dasselbe wie das receiptRoot
von web3.eth.getBlock
.
Welche Beziehung besteht zwischen diesen Wurzeln?
Es ist der Hash der Wurzel des State Trie, während receiptRoot
es sich um den Hash des Quittungsarrays für einen bestimmten Block handelt.
Darin gibt GetTransactionReceipt()
es api.go
eine Reihe von Zuordnungen, von denen eine ist:
"root": common.Bytes2Hex(receipt.PostState),
Betrachtet man receipt.go
, PostState
ist ein byte
Array:
// Receipt represents the results of a transaction.
type Receipt struct {
// Consensus fields
PostState []byte
CumulativeGasUsed *big.Int
Bloom Bloom
Logs vm.Logs
Dies wird NewReceipt()
auf einen Wert gesetzt, der von übergeben wird state_processor.go
:
receipt := types.NewReceipt(statedb.IntermediateRoot().Bytes(), usedGas)
...und IntermediateRoot()
ist definiert statedb.go
als:
// IntermediateRoot computes the current root hash of the state trie.
// It is called in between transactions to get the root hash that
// goes into transaction receipts.
Im block.go
:
// The values of TxHash, UncleHash, ReceiptHash and Bloom in header
// are ignored and set to values derived from the given txs, uncles
// and receipts.
Der entsprechende Code in dieser Funktion lautet:
b.header.ReceiptHash = DeriveSha(Receipts(receipts))
Und darin api.go
:
"receiptRoot": b.ReceiptHash(),
eth