-
Notifications
You must be signed in to change notification settings - Fork 0
/
receipt.go
64 lines (54 loc) · 1.38 KB
/
receipt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2020 The Meter.io developers
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>
package tx
import (
"math/big"
"github.com/saolacoincom/saolacoin/meter"
"github.com/saolacoincom/saolacoin/trie"
"github.com/ethereum/go-ethereum/rlp"
)
// Receipt represents the results of a transaction.
type Receipt struct {
// gas used by this tx
GasUsed uint64
// the one who paid for gas
GasPayer meter.Address
// energy paid for used gas
Paid *big.Int
// energy reward given to block proposer
Reward *big.Int
// if the tx reverted
Reverted bool
// outputs of clauses in tx
Outputs []*Output
}
// Output output of clause execution.
type Output struct {
// events produced by the clause
Events Events
// transfer occurred in clause
Transfers Transfers
}
// Receipts slice of receipts.
type Receipts []*Receipt
// RootHash computes merkle root hash of receipts.
func (rs Receipts) RootHash() meter.Bytes32 {
if len(rs) == 0 {
// optimized
return emptyRoot
}
return trie.DeriveRoot(derivableReceipts(rs))
}
// implements DerivableList
type derivableReceipts Receipts
func (rs derivableReceipts) Len() int {
return len(rs)
}
func (rs derivableReceipts) GetRlp(i int) []byte {
data, err := rlp.EncodeToBytes(rs[i])
if err != nil {
panic(err)
}
return data
}