Commit 6dbb9293 authored by Mark Tyneway's avatar Mark Tyneway

l2geth: remove dead code in `blockchain.go` and `miner/worker.go`

This PR removes dead code that was responsible for timestamp management.
This codepath is no longer used so removing it will reduce the diff.
parent b4d98828
---
'@eth-optimism/l2geth': patch
---
Remove dead code in `blockchain.go` and `miner/worker.go`
......@@ -151,8 +151,6 @@ type BlockChain struct {
chainmu sync.RWMutex // blockchain insertion lock
currentTimestamp atomic.Value // Timestamp to be used when mining the current block.
currentBlock atomic.Value // Current head of the block chain
currentFastBlock atomic.Value // Current head of the fast-sync chain (may be above the block chain!)
......@@ -249,13 +247,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
// it in advance.
bc.engine.VerifyHeader(bc, bc.CurrentHeader(), true)
if currentHeader := bc.CurrentHeader(); currentHeader != nil {
log.Debug("Read timestamp from last block. ", "timestamp", bc.CurrentHeader().Time)
bc.SetCurrentTimestamp(int64(bc.CurrentHeader().Time))
} else {
bc.SetCurrentTimestamp(int64(0))
}
if frozen, err := bc.db.Ancients(); err == nil && frozen > 0 {
var (
needRewind bool
......@@ -504,17 +495,6 @@ func (bc *BlockChain) GasLimit() uint64 {
return bc.CurrentBlock().GasLimit()
}
// SetCurrentTimestamp sets the timestamp for blocks added to the canonical chain.
func (bc *BlockChain) SetCurrentTimestamp(timestamp int64) {
bc.currentTimestamp.Store(&timestamp)
}
// CurrentTimestamp retrieves the timestamp used for blocks added to the canonical chain.
func (bc *BlockChain) CurrentTimestamp() int64 {
// Note: Can never be nil
return *bc.currentTimestamp.Load().(*int64)
}
// CurrentBlock retrieves the current head block of the canonical chain. The
// block is retrieved from the blockchain's internal cache.
func (bc *BlockChain) CurrentBlock() *types.Block {
......
......@@ -323,10 +323,6 @@ func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction)
return b.eth.txPool.AddLocal(signedTx)
}
func (b *EthAPIBackend) SetTimestamp(timestamp int64) {
b.eth.blockchain.SetCurrentTimestamp(timestamp)
}
func (b *EthAPIBackend) GetPoolTransactions() (types.Transactions, error) {
pending, err := b.eth.txPool.Pending()
if err != nil {
......
......@@ -86,7 +86,6 @@ type Backend interface {
CurrentBlock() *types.Block
// Optimism-specific API
SetTimestamp(timestamp int64)
IsVerifier() bool
IsSyncing() bool
GetEthContext() (uint64, uint64)
......
......@@ -352,7 +352,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
select {
case <-w.startCh:
clearPending(w.chain.CurrentBlock().NumberU64())
timestamp = w.chain.CurrentTimestamp()
commit(false, commitInterruptNewHead)
case <-timer.C:
......@@ -364,7 +363,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timer.Reset(recommit)
continue
}
timestamp = w.chain.CurrentTimestamp()
commit(true, commitInterruptResubmit)
}
......@@ -510,7 +508,7 @@ func (w *worker) mainLoop() {
// If clique is running in dev mode(period is 0), disable
// advance sealing here.
if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 {
w.commitNewWork(nil, true, w.chain.CurrentTimestamp())
w.commitNewWork(nil, true, time.Now().Unix())
}
}
atomic.AddInt32(&w.newTxs, int32(len(ev.Txs)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment