aboutsummaryrefslogtreecommitdiff
path: root/core/state
diff options
context:
space:
mode:
Diffstat (limited to 'core/state')
-rw-r--r--core/state/journal.go2
-rw-r--r--core/state/state_object.go32
-rw-r--r--core/state/statedb.go57
3 files changed, 47 insertions, 44 deletions
diff --git a/core/state/journal.go b/core/state/journal.go
index 0cc556b..be27493 100644
--- a/core/state/journal.go
+++ b/core/state/journal.go
@@ -185,7 +185,7 @@ func (ch balanceChange) dirtied() *common.Address {
}
func (ch multiCoinEnable) revert(s *StateDB) {
- s.getStateObject(*ch.account).data.IsMultiCoin = false
+ //s.getStateObject(*ch.account).data.IsMultiCoin = false
}
func (ch multiCoinEnable) dirtied() *common.Address {
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 2893f80..9772859 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -438,9 +438,9 @@ func (s *stateObject) setBalance(amount *big.Int) {
s.data.Balance = amount
}
-func (s *stateObject) enableMultiCoin() {
- s.data.IsMultiCoin = true
-}
+//func (s *stateObject) enableMultiCoin() {
+// s.data.IsMultiCoin = true
+//}
// Return the gas back to the origin. Used by the Virtual machine or Closures
func (s *stateObject) ReturnGas(gas *big.Int) {}
@@ -538,9 +538,9 @@ func (s *stateObject) Balance() *big.Int {
return s.data.Balance
}
-func IsMultiCoinKey(key common.Hash) bool {
- return key[0]&0x01 == 0x01
-}
+//func IsMultiCoinKey(key common.Hash) bool {
+// return key[0]&0x01 == 0x01
+//}
func NormalizeCoinID(coinID *common.Hash) {
coinID[0] |= 0x01
@@ -555,16 +555,16 @@ func (s *stateObject) BalanceMultiCoin(coinID common.Hash, db Database) *big.Int
return s.GetState(db, coinID).Big()
}
-func (s *stateObject) EnableMultiCoin() bool {
- if s.data.IsMultiCoin {
- return false
- }
- s.db.journal.append(multiCoinEnable{
- account: &s.address,
- })
- s.enableMultiCoin()
- return true
-}
+//func (s *stateObject) EnableMultiCoin() bool {
+// if s.data.IsMultiCoin {
+// return false
+// }
+// s.db.journal.append(multiCoinEnable{
+// account: &s.address,
+// })
+// s.enableMultiCoin()
+// return true
+//}
func (s *stateObject) IsMultiCoin() bool {
return s.data.IsMultiCoin
diff --git a/core/state/statedb.go b/core/state/statedb.go
index dbf0870..c4d926d 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -267,29 +267,30 @@ func (self *StateDB) GetBalanceMultiCoin(addr common.Address, coinID common.Hash
return common.Big0
}
-func (self *StateDB) EnableMultiCoin(addr common.Address) error {
- stateObject := self.GetOrNewStateObject(addr)
- if stateObject.data.Root != emptyRoot && stateObject.data.Root != zeroRoot {
- return errors.New(fmt.Sprintf("not a fresh account: %s", stateObject.data.Root.Hex()))
- }
- if !stateObject.EnableMultiCoin() {
- return errors.New("multi-coin mode already enabled")
- }
- log.Debug(fmt.Sprintf("enabled MC for %s", addr.Hex()))
- return nil
-}
-
-func (self *StateDB) ForceEnableMultiCoin(addr common.Address) {
- stateObject := self.GetOrNewStateObject(addr)
- stateObject.EnableMultiCoin()
-}
+//func (self *StateDB) EnableMultiCoin(addr common.Address) error {
+// stateObject := self.GetOrNewStateObject(addr)
+// if stateObject.data.Root != emptyRoot && stateObject.data.Root != zeroRoot {
+// return errors.New(fmt.Sprintf("not a fresh account: %s", stateObject.data.Root.Hex()))
+// }
+// if !stateObject.EnableMultiCoin() {
+// return errors.New("multi-coin mode already enabled")
+// }
+// log.Debug(fmt.Sprintf("enabled MC for %s", addr.Hex()))
+// return nil
+//}
+//
+//func (self *StateDB) ForceEnableMultiCoin(addr common.Address) {
+// stateObject := self.GetOrNewStateObject(addr)
+// stateObject.EnableMultiCoin()
+//}
func (self *StateDB) IsMultiCoin(addr common.Address) bool {
- stateObject := self.getStateObject(addr)
- if stateObject != nil {
- return stateObject.IsMultiCoin()
- }
- return false
+ return true
+ //stateObject := self.getStateObject(addr)
+ //if stateObject != nil {
+ // return stateObject.IsMultiCoin()
+ //}
+ //return false
}
func (s *StateDB) GetNonce(addr common.Address) uint64 {
@@ -339,6 +340,10 @@ func (s *StateDB) GetCodeHash(addr common.Address) common.Hash {
func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash {
stateObject := s.getStateObject(addr)
if stateObject != nil {
+ // NOTE: last-minute fix: just universally enable MC
+ //if stateObject.data.IsMultiCoin {
+ NormalizeStateKey(&hash)
+ //}
return stateObject.GetState(s.db, hash)
}
return common.Hash{}
@@ -425,9 +430,6 @@ func (s *StateDB) SetBalance(addr common.Address, amount *big.Int) {
// AddBalance adds amount to the account associated with addr.
func (s *StateDB) AddBalanceMultiCoin(addr common.Address, coinID common.Hash, amount *big.Int) {
- if !s.IsMultiCoin(addr) {
- s.EnableMultiCoin(addr)
- }
stateObject := s.GetOrNewStateObject(addr)
if stateObject != nil {
stateObject.AddBalanceMultiCoin(coinID, amount, s.db)
@@ -467,9 +469,10 @@ func (s *StateDB) SetState(addr common.Address, key, value common.Hash) (res err
res = nil
stateObject := s.GetOrNewStateObject(addr)
if stateObject != nil {
- if stateObject.data.IsMultiCoin {
- NormalizeStateKey(&key)
- }
+ // NOTE: last-minute fix: just universally enable MC
+ //if stateObject.data.IsMultiCoin {
+ NormalizeStateKey(&key)
+ //}
stateObject.SetState(s.db, key, value)
}
return