Merge pull request #1681 from obscuren/miner-receipt-fix

core, miner: write miner receipts
This commit is contained in:
Jeffrey Wilcke 2015-08-18 12:53:26 -07:00
commit d0dc1b4a60
4 changed files with 14 additions and 9 deletions

@ -349,11 +349,9 @@ func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) types.Receipts {
// the depricated way by re-processing the block. // the depricated way by re-processing the block.
func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error) { func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error) {
receipts := GetBlockReceipts(sm.chainDb, block.Hash()) receipts := GetBlockReceipts(sm.chainDb, block.Hash())
if len(receipts) > 0 { // coalesce logs
// coalesce logs for _, receipt := range receipts {
for _, receipt := range receipts { logs = append(logs, receipt.Logs()...)
logs = append(logs, receipt.Logs()...)
}
} }
return logs, nil return logs, nil
} }

@ -647,7 +647,9 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
queue[i] = ChainSplitEvent{block, logs} queue[i] = ChainSplitEvent{block, logs}
queueEvent.splitCount++ queueEvent.splitCount++
} }
PutBlockReceipts(self.chainDb, block, receipts) if err := PutBlockReceipts(self.chainDb, block, receipts); err != nil {
glog.V(logger.Warn).Infoln("error writing block receipts:", err)
}
stats.processed++ stats.processed++
} }

@ -22,6 +22,8 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
) )
type AccountChange struct { type AccountChange struct {
@ -111,7 +113,7 @@ done:
// Get the logs of the block // Get the logs of the block
unfiltered, err := self.eth.BlockProcessor().GetLogs(block) unfiltered, err := self.eth.BlockProcessor().GetLogs(block)
if err != nil { if err != nil {
chainlogger.Warnln("err: filter get logs ", err) glog.V(logger.Warn).Infoln("err: filter get logs ", err)
break break
} }

@ -297,14 +297,17 @@ func (self *worker) wait() {
} }
// broadcast before waiting for validation // broadcast before waiting for validation
go func(block *types.Block, logs state.Logs) { go func(block *types.Block, logs state.Logs, receipts []*types.Receipt) {
self.mux.Post(core.NewMinedBlockEvent{block}) self.mux.Post(core.NewMinedBlockEvent{block})
self.mux.Post(core.ChainEvent{block, block.Hash(), logs}) self.mux.Post(core.ChainEvent{block, block.Hash(), logs})
if stat == core.CanonStatTy { if stat == core.CanonStatTy {
self.mux.Post(core.ChainHeadEvent{block}) self.mux.Post(core.ChainHeadEvent{block})
self.mux.Post(logs) self.mux.Post(logs)
} }
}(block, work.state.Logs()) if err := core.PutBlockReceipts(self.chainDb, block, receipts); err != nil {
glog.V(logger.Warn).Infoln("error writing block receipts:", err)
}
}(block, work.state.Logs(), work.receipts)
} }
// check staleness and display confirmation // check staleness and display confirmation