-
Notifications
You must be signed in to change notification settings - Fork 202
/
metaJournalEntries.go
143 lines (114 loc) · 3.76 KB
/
metaJournalEntries.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
package state
import "math/big"
//------- MetaJournalEntryRound
// MetaJournalEntryRound is used to revert a round change
type MetaJournalEntryRound struct {
account *MetaAccount
oldRound uint64
}
// NewMetaJournalEntryRound outputs a new JournalEntry implementation used to revert a round change
func NewMetaJournalEntryRound(account *MetaAccount, oldRound uint64) (*MetaJournalEntryRound, error) {
if account == nil {
return nil, ErrNilAccountHandler
}
return &MetaJournalEntryRound{
account: account,
oldRound: oldRound,
}, nil
}
// Revert applies undo operation
func (jen *MetaJournalEntryRound) Revert() (AccountHandler, error) {
jen.account.Round = jen.oldRound
return jen.account, nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (jen *MetaJournalEntryRound) IsInterfaceNil() bool {
if jen == nil {
return true
}
return false
}
//------- MetaJournalEntryTxCount
// MetaJournalEntryTxCount is used to revert a round change
type MetaJournalEntryTxCount struct {
account *MetaAccount
oldTxCount *big.Int
}
// NewMetaJournalEntryTxCount outputs a new JournalEntry implementation used to revert a TxCount change
func NewMetaJournalEntryTxCount(account *MetaAccount, oldTxCount *big.Int) (*MetaJournalEntryTxCount, error) {
if account == nil {
return nil, ErrNilAccountHandler
}
return &MetaJournalEntryTxCount{
account: account,
oldTxCount: oldTxCount,
}, nil
}
// Revert applies undo operation
func (jen *MetaJournalEntryTxCount) Revert() (AccountHandler, error) {
jen.account.TxCount = jen.oldTxCount
return jen.account, nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (jen *MetaJournalEntryTxCount) IsInterfaceNil() bool {
if jen == nil {
return true
}
return false
}
//------- MetaJournalEntryMiniBlocksData
// MetaJournalEntryMiniBlocksData is used to revert a round change
type MetaJournalEntryMiniBlocksData struct {
account *MetaAccount
oldMiniBlocksData []*MiniBlockData
}
// NewMetaJournalEntryMiniBlocksData outputs a new JournalEntry implementation used to revert a MiniBlocksData change
func NewMetaJournalEntryMiniBlocksData(account *MetaAccount, oldMiniBlocksData []*MiniBlockData) (*MetaJournalEntryMiniBlocksData, error) {
if account == nil {
return nil, ErrNilAccountHandler
}
return &MetaJournalEntryMiniBlocksData{
account: account,
oldMiniBlocksData: oldMiniBlocksData,
}, nil
}
// Revert applies undo operation
func (jen *MetaJournalEntryMiniBlocksData) Revert() (AccountHandler, error) {
jen.account.MiniBlocks = jen.oldMiniBlocksData
return jen.account, nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (jen *MetaJournalEntryMiniBlocksData) IsInterfaceNil() bool {
if jen == nil {
return true
}
return false
}
//------- MetaJournalEntryShardRootHash
// MetaJournalEntryShardRootHash is used to revert a round change
type MetaJournalEntryShardRootHash struct {
account *MetaAccount
oldShardRootHash []byte
}
// NewMetaJournalEntryShardRootHash outputs a new JournalEntry implementation used to revert a ShardRootHash change
func NewMetaJournalEntryShardRootHash(account *MetaAccount, oldShardRootHash []byte) (*MetaJournalEntryShardRootHash, error) {
if account == nil {
return nil, ErrNilAccountHandler
}
return &MetaJournalEntryShardRootHash{
account: account,
oldShardRootHash: oldShardRootHash,
}, nil
}
// Revert applies undo operation
func (jen *MetaJournalEntryShardRootHash) Revert() (AccountHandler, error) {
jen.account.ShardRootHash = jen.oldShardRootHash
return jen.account, nil
}
// IsInterfaceNil returns true if there is no value under the interface
func (jen *MetaJournalEntryShardRootHash) IsInterfaceNil() bool {
if jen == nil {
return true
}
return false
}