aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-10-21 17:34:00 -0400
committerDeterminant <[email protected]>2019-10-21 17:34:00 -0400
commitf0fdb5dfb215bebc54d2a62e54f0c7ae3e71ff91 (patch)
treed435d2b2e0ca3e8b6255c3b12b49e8a9ac7f0575
parent190b04fcbcadf4807c5c2bb0ef9e528bbff62e32 (diff)
...
-rw-r--r--core/blockchain.go30
-rw-r--r--core/events.go2
-rw-r--r--core/tx_pool.go2
-rw-r--r--miner/worker.go1
4 files changed, 15 insertions, 20 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 046e1d4..dddca62 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -825,7 +825,6 @@ func (bc *BlockChain) Stop() {
for _, offset := range []uint64{0, 1, TriesInMemory - 1} {
if number := bc.CurrentBlock().NumberU64(); number > offset {
- log.Info(".....", "number", number, "offset", offset)
recent := bc.GetBlockByNumber(number - offset)
log.Info("Writing cached state to disk", "block", recent.Number(), "hash", recent.Hash(), "root", recent.Root())
@@ -1356,7 +1355,6 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
reorg := externTd.Cmp(localTd) > 0
currentBlock = bc.CurrentBlock()
if !bc.manualCanonical && (!reorg && externTd.Cmp(localTd) == 0) {
- //if (!reorg && externTd.Cmp(localTd) == 0) {
// Split same-difficulty blocks by number, then preferentially select
// the block generated by the local miner as the canonical block.
if block.NumberU64() < currentBlock.NumberU64() {
@@ -1369,24 +1367,20 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
reorg = !currentPreserve && (blockPreserve || mrand.Float64() < 0.5)
}
}
- if bc.manualCanonical {
- status = CanonStatTy
- } else {
- if reorg {
- // Reorganise the chain if the parent is not the head block
- if block.ParentHash() != currentBlock.Hash() {
- if err := bc.reorg(currentBlock, block); err != nil {
- return NonStatTy, err
- }
+ if reorg {
+ // Reorganise the chain if the parent is not the head block
+ if !bc.manualCanonical && block.ParentHash() != currentBlock.Hash() {
+ if err := bc.reorg(currentBlock, block); err != nil {
+ return NonStatTy, err
}
- // Write the positional metadata for transaction/receipt lookups and preimages
- rawdb.WriteTxLookupEntries(batch, block)
- rawdb.WritePreimages(batch, state.Preimages())
-
- status = CanonStatTy
- } else {
- status = SideStatTy
}
+ // Write the positional metadata for transaction/receipt lookups and preimages
+ rawdb.WriteTxLookupEntries(batch, block)
+ rawdb.WritePreimages(batch, state.Preimages())
+
+ status = CanonStatTy
+ } else {
+ status = SideStatTy
}
if err := batch.Write(); err != nil {
return NonStatTy, err
diff --git a/core/events.go b/core/events.go
index aa58d08..135d07f 100644
--- a/core/events.go
+++ b/core/events.go
@@ -25,7 +25,7 @@ import (
type NewTxsEvent struct{ Txs []*types.Transaction }
// NewTxPoolHeadEvent is posted when the pool head is updated.
-type NewTxPoolHeadEvent struct{ block *types.Block }
+type NewTxPoolHeadEvent struct{ Block *types.Block }
// PendingLogsEvent is posted pre mining and notifies of pending logs.
type PendingLogsEvent struct {
diff --git a/core/tx_pool.go b/core/tx_pool.go
index 3454936..c6178bb 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -329,7 +329,7 @@ func (pool *TxPool) loop() {
if ev.Block != nil {
pool.requestReset(head.Header(), ev.Block.Header())
head = ev.Block
- pool.headFeed.Send(NewTxPoolHeadEvent{head})
+ pool.headFeed.Send(NewTxPoolHeadEvent{Block: head})
}
// System shutdown.
diff --git a/miner/worker.go b/miner/worker.go
index 19234ee..df1c601 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -637,6 +637,7 @@ func (w *worker) resultLoop() {
// Commit block and state to database.
//fmt.Printf("parent1: %s\n", w.chain.CurrentBlock().Hash().String())
stat, err := w.chain.WriteBlockWithState(block, receipts, task.state)
+ stat = core.CanonStatTy
//fmt.Printf("parent2: %s\n", w.chain.CurrentBlock().Hash().String())
if err != nil {
log.Error("Failed writing block to chain", "err", err)