diff --git a/light/lightchain.go b/light/lightchain.go index c0344129f9..7d415bac73 100644 --- a/light/lightchain.go +++ b/light/lightchain.go @@ -143,7 +143,7 @@ func (bc *LightChain) Odr() OdrBackend { // loadLastState loads the last known chain state from the database. This method // assumes that the chain manager mutex is held. func (bc *LightChain) loadLastState() error { - if head := core.GetHeadHeaderHash(bc.chainDb); head == (common.Hash{}) { + if head := rawdb.ReadHeadHeaderHash(bc.chainDb); head == (common.Hash{}) { // Corrupt or empty database, init from scratch bc.Reset() } else { @@ -221,7 +221,11 @@ func (bc *LightChain) GetBody(ctx context.Context, hash common.Hash) (*types.Bod body := cached.(*types.Body) return body, nil } - body, err := GetBody(ctx, bc.odr, hash, bc.hc.GetBlockNumber(hash)) + number := bc.hc.GetBlockNumber(hash) + if number == nil { + return nil, errors.New("unknown block") + } + body, err := GetBody(ctx, bc.odr, hash, *number) if err != nil { return nil, err } @@ -237,7 +241,11 @@ func (bc *LightChain) GetBodyRLP(ctx context.Context, hash common.Hash) (rlp.Raw if cached, ok := bc.bodyRLPCache.Get(hash); ok { return cached.(rlp.RawValue), nil } - body, err := GetBodyRLP(ctx, bc.odr, hash, bc.hc.GetBlockNumber(hash)) + number := bc.hc.GetBlockNumber(hash) + if number == nil { + return nil, errors.New("unknown block") + } + body, err := GetBodyRLP(ctx, bc.odr, hash, *number) if err != nil { return nil, err } diff --git a/light/txpool.go b/light/txpool.go index b63f3c2e1c..6ba4292fbf 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -412,7 +412,7 @@ func (pool *TxPool) add(ctx context.Context, tx *types.Transaction) error { // Notify the subscribers. This event is posted in a goroutine // because it's possible that somewhere during the post "Remove transaction" // gets called which will then wait for the global tx pool lock and deadlock. - go pool.txFeed.Send(core.TxPreEvent{Tx: tx}) + go pool.txFeed.Send(core.NewTxsEvent{Txs: types.Transactions{tx}}) } // Print a log message if low enough level is set