aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/block_processor.go7
-rw-r--r--core/chain_manager.go2
-rw-r--r--eth/protocol.go2
-rw-r--r--state/state_object.go10
4 files changed, 13 insertions, 8 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index a9795385f..bfd9d4560 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -296,16 +296,13 @@ func (sm *BlockProcessor) AccumulateRewards(statedb *state.StateDB, block, paren
r := new(big.Int)
r.Mul(BlockReward, big.NewInt(15)).Div(r, big.NewInt(16))
- uncleAccount := statedb.GetAccount(uncle.Coinbase)
- uncleAccount.AddAmount(r)
+ statedb.AddBalance(uncle.Coinbase, r)
reward.Add(reward, new(big.Int).Div(BlockReward, big.NewInt(32)))
}
// Get the account associated with the coinbase
- account := statedb.GetAccount(block.Header().Coinbase)
- // Reward amount of ether to the coinbase address
- account.AddAmount(reward)
+ statedb.AddBalance(block.Header().Coinbase, reward)
return nil
}
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 003781791..dd0dd3cbe 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -397,7 +397,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
if chain {
//self.setTransState(state.New(block.Root(), self.db))
- self.eventMux.Post(ChainEvent{block, td})
+ //self.eventMux.Post(ChainEvent{block, td})
}
if split {
diff --git a/eth/protocol.go b/eth/protocol.go
index fb694c877..44a1184f2 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -13,7 +13,7 @@ import (
)
const (
- ProtocolVersion = 52
+ ProtocolVersion = 53
NetworkId = 0
ProtocolLength = uint64(8)
ProtocolMaxMsgSize = 10 * 1024 * 1024
diff --git a/state/state_object.go b/state/state_object.go
index d50c9fd7a..226c25299 100644
--- a/state/state_object.go
+++ b/state/state_object.go
@@ -65,7 +65,7 @@ func NewStateObject(addr []byte, db ethutil.Database) *StateObject {
// This to ensure that it has 20 bytes (and not 0 bytes), thus left or right pad doesn't matter.
address := ethutil.Address(addr)
- object := &StateObject{db: db, address: address, balance: new(big.Int), gasPool: new(big.Int)}
+ object := &StateObject{db: db, address: address, balance: new(big.Int), gasPool: new(big.Int), dirty: true}
object.State = New(nil, db) //New(trie.New(ethutil.Config.Db, ""))
object.storage = make(Storage)
object.gasPool = new(big.Int)
@@ -118,6 +118,7 @@ func (self *StateObject) GetStorage(key *big.Int) *ethutil.Value {
}
func (self *StateObject) SetStorage(key *big.Int, value *ethutil.Value) {
self.SetState(key.Bytes(), value)
+ self.dirty = true
}
func (self *StateObject) Storage() map[string]*ethutil.Value {
@@ -142,6 +143,7 @@ func (self *StateObject) GetState(k []byte) *ethutil.Value {
func (self *StateObject) SetState(k []byte, value *ethutil.Value) {
key := ethutil.LeftPadBytes(k, 32)
self.storage[string(key)] = value.Copy()
+ self.dirty = true
}
func (self *StateObject) Sync() {
@@ -166,6 +168,7 @@ func (c *StateObject) GetInstr(pc *big.Int) *ethutil.Value {
func (c *StateObject) AddBalance(amount *big.Int) {
c.SetBalance(new(big.Int).Add(c.balance, amount))
+ c.dirty = true
statelogger.Debugf("%x: #%d %v (+ %v)\n", c.Address(), c.Nonce, c.balance, amount)
}
@@ -180,6 +183,7 @@ func (c *StateObject) SubAmount(amount *big.Int) { c.SubBalance(amount) }
func (c *StateObject) SetBalance(amount *big.Int) {
c.balance = amount
+ c.dirty = true
}
func (self *StateObject) Balance() *big.Int { return self.balance }
@@ -198,6 +202,8 @@ func (c *StateObject) ConvertGas(gas, price *big.Int) error {
c.SubAmount(total)
+ c.dirty = true
+
return nil
}
@@ -219,6 +225,8 @@ func (self *StateObject) BuyGas(gas, price *big.Int) error {
self.AddAmount(rGas)
+ self.dirty = true
+
return nil
}