aboutsummaryrefslogtreecommitdiffstats
path: root/core/state
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-11-13 19:47:27 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-01-03 20:45:35 +0800
commit6f69cdd109b1dd692b8dfb15e7c53d2051fbc946 (patch)
treec92974f8b82209073ad1ee3faec6e149f834bf69 /core/state
parentb8caba97099ee5eed33c3b80dd4ea540722e7d8f (diff)
downloadgo-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.gz
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.bz2
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.lz
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.xz
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.tar.zst
go-tangerine-6f69cdd109b1dd692b8dfb15e7c53d2051fbc946.zip
all: switch gas limits from big.Int to uint64
Diffstat (limited to 'core/state')
-rw-r--r--core/state/journal.go2
-rw-r--r--core/state/statedb.go17
-rw-r--r--core/state/statedb_test.go4
3 files changed, 10 insertions, 13 deletions
diff --git a/core/state/journal.go b/core/state/journal.go
index ddc819fe5..a89bb3d13 100644
--- a/core/state/journal.go
+++ b/core/state/journal.go
@@ -62,7 +62,7 @@ type (
// Changes to other state values.
refundChange struct {
- prev *big.Int
+ prev uint64
}
addLogChange struct {
txhash common.Hash
diff --git a/core/state/statedb.go b/core/state/statedb.go
index de9fb367d..8e29104d5 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -57,7 +57,7 @@ type StateDB struct {
dbErr error
// The refund counter, also used by state transitioning.
- refund *big.Int
+ refund uint64
thash, bhash common.Hash
txIndex int
@@ -86,7 +86,6 @@ func New(root common.Hash, db Database) (*StateDB, error) {
trie: tr,
stateObjects: make(map[common.Address]*stateObject),
stateObjectsDirty: make(map[common.Address]struct{}),
- refund: new(big.Int),
logs: make(map[common.Hash][]*types.Log),
preimages: make(map[common.Hash][]byte),
}, nil
@@ -161,9 +160,9 @@ func (self *StateDB) Preimages() map[common.Hash][]byte {
return self.preimages
}
-func (self *StateDB) AddRefund(gas *big.Int) {
- self.journal = append(self.journal, refundChange{prev: new(big.Int).Set(self.refund)})
- self.refund.Add(self.refund, gas)
+func (self *StateDB) AddRefund(gas uint64) {
+ self.journal = append(self.journal, refundChange{prev: self.refund})
+ self.refund += gas
}
// Exist reports whether the given account address exists in the state.
@@ -456,7 +455,7 @@ func (self *StateDB) Copy() *StateDB {
trie: self.db.CopyTrie(self.trie),
stateObjects: make(map[common.Address]*stateObject, len(self.stateObjectsDirty)),
stateObjectsDirty: make(map[common.Address]struct{}, len(self.stateObjectsDirty)),
- refund: new(big.Int).Set(self.refund),
+ refund: self.refund,
logs: make(map[common.Hash][]*types.Log, len(self.logs)),
logSize: self.logSize,
preimages: make(map[common.Hash][]byte),
@@ -506,9 +505,7 @@ func (self *StateDB) RevertToSnapshot(revid int) {
}
// GetRefund returns the current value of the refund counter.
-// The return value must not be modified by the caller and will become
-// invalid at the next call to AddRefund.
-func (self *StateDB) GetRefund() *big.Int {
+func (self *StateDB) GetRefund() uint64 {
return self.refund
}
@@ -568,7 +565,7 @@ func (s *StateDB) DeleteSuicides() {
func (s *StateDB) clearJournalAndRefund() {
s.journal = nil
s.validRevisions = s.validRevisions[:0]
- s.refund = new(big.Int)
+ s.refund = 0
}
// CommitTo writes the state to the given database.
diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go
index e9944cd74..5c80e3aa5 100644
--- a/core/state/statedb_test.go
+++ b/core/state/statedb_test.go
@@ -263,7 +263,7 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
{
name: "AddRefund",
fn: func(a testAction, s *StateDB) {
- s.AddRefund(big.NewInt(a.args[0]))
+ s.AddRefund(uint64(a.args[0]))
},
args: make([]int64, 1),
noAddr: true,
@@ -396,7 +396,7 @@ func (test *snapshotTest) checkEqual(state, checkstate *StateDB) error {
}
}
- if state.GetRefund().Cmp(checkstate.GetRefund()) != 0 {
+ if state.GetRefund() != checkstate.GetRefund() {
return fmt.Errorf("got GetRefund() == %d, want GetRefund() == %d",
state.GetRefund(), checkstate.GetRefund())
}