mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
core: pass the coinbase directly instead of the header
This commit is contained in:
parent
d056824683
commit
60b05b8780
4 changed files with 12 additions and 10 deletions
|
|
@ -89,7 +89,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the state with pending changes
|
// Update the state with pending changes
|
||||||
statedb.SyncIntermediate(header.Coinbase, header.GasLimit)
|
statedb.SyncIntermediate(coinbase)
|
||||||
|
|
||||||
usedGas.Add(usedGas, gas)
|
usedGas.Add(usedGas, gas)
|
||||||
receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas)
|
receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ func (b *BlockGen) AddTx(tx *types.Transaction) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
b.statedb.SyncIntermediate(common.Address{}, b.header.GasLimit)
|
b.statedb.SyncIntermediate(b.coinbase)
|
||||||
b.header.GasUsed.Add(b.header.GasUsed, gas)
|
b.header.GasUsed.Add(b.header.GasUsed, gas)
|
||||||
receipt := types.NewReceipt(b.statedb.Root().Bytes(), b.header.GasUsed)
|
receipt := types.NewReceipt(b.statedb.Root().Bytes(), b.header.GasUsed)
|
||||||
logs := b.statedb.GetLogs(tx.Hash())
|
logs := b.statedb.GetLogs(tx.Hash())
|
||||||
|
|
@ -151,7 +151,7 @@ func GenerateChain(parent *types.Block, db common.Database, n int, gen func(int,
|
||||||
gen(i, b)
|
gen(i, b)
|
||||||
}
|
}
|
||||||
AccumulateRewards(statedb, h, b.uncles)
|
AccumulateRewards(statedb, h, b.uncles)
|
||||||
statedb.SyncIntermediate(h.Coinbase, h.GasLimit)
|
statedb.SyncIntermediate(b.coinbase)
|
||||||
h.Root = statedb.Root()
|
h.Root = statedb.Root()
|
||||||
return types.NewBlock(h, b.txs, b.uncles, b.receipts)
|
return types.NewBlock(h, b.txs, b.uncles, b.receipts)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ func TestNull(t *testing.T) {
|
||||||
//value := common.FromHex("0x823140710bf13990e4500136726d8b55")
|
//value := common.FromHex("0x823140710bf13990e4500136726d8b55")
|
||||||
var value common.Hash
|
var value common.Hash
|
||||||
state.SetState(address, common.Hash{}, value)
|
state.SetState(address, common.Hash{}, value)
|
||||||
state.SyncIntermediate()
|
state.SyncIntermediate(nil)
|
||||||
state.Sync()
|
state.Sync()
|
||||||
value = state.GetState(address, common.Hash{})
|
value = state.GetState(address, common.Hash{})
|
||||||
if !common.EmptyHash(value) {
|
if !common.EmptyHash(value) {
|
||||||
|
|
|
||||||
|
|
@ -349,18 +349,20 @@ func (self *StateDB) Refunds() *big.Int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncIntermediate updates the intermediate state and all mid steps
|
// SyncIntermediate updates the intermediate state and all mid steps
|
||||||
func (self *StateDB) SyncIntermediate(headerCoinbase common.Address, headerGasLimit *big.Int) {
|
func (self *StateDB) SyncIntermediate(coinbase *StateObject) {
|
||||||
self.refund = new(big.Int)
|
self.refund = new(big.Int)
|
||||||
|
|
||||||
for _, stateObject := range self.stateObjects {
|
for _, stateObject := range self.stateObjects {
|
||||||
if stateObject.dirty {
|
if stateObject.dirty {
|
||||||
if stateObject.remove {
|
if stateObject.remove {
|
||||||
if stateObject.address == headerCoinbase {
|
if stateObject == coinbase {
|
||||||
gasPoolCopy := new(big.Int).Set(stateObject.gasPool)
|
// Save the original address and remaining gas
|
||||||
|
address, gas := coinbase.Address(), new(big.Int).Set(coinbase.gasPool)
|
||||||
self.DeleteStateObject(stateObject)
|
self.DeleteStateObject(stateObject)
|
||||||
coinbase := self.CreateAccount(headerCoinbase)
|
|
||||||
coinbase.SetGasLimit(headerGasLimit)
|
// Resurrect the coinbase and restore the gas allowance
|
||||||
coinbase.gasPool = gasPoolCopy
|
*coinbase = *self.CreateAccount(address)
|
||||||
|
coinbase.SetGasLimit(gas)
|
||||||
} else {
|
} else {
|
||||||
self.DeleteStateObject(stateObject)
|
self.DeleteStateObject(stateObject)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue