-
Notifications
You must be signed in to change notification settings - Fork 0
/
receipt.go
65 lines (55 loc) · 1.45 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
65
// Copyright (c) 2018 The VeChainThor developers
// Copyright (c) 2019 The PlayMaker 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/ethereum/go-ethereum/rlp"
"github.com/playmakerchain/powerplay/powerplay"
"github.com/playmakerchain/powerplay/trie"
)
// Receipt represents the results of a transaction.
type Receipt struct {
// gas used by this tx
GasUsed uint64
// the one who paid for gas
GasPayer powerplay.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() powerplay.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
}