mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core, eth, internal/cli: chain event fixes
This commit is contained in:
parent
0d1f96960e
commit
c65177c035
4 changed files with 13 additions and 9 deletions
|
|
@ -23,6 +23,9 @@ import (
|
|||
// NewTxsEvent is posted when a batch of transactions enter the transaction pool.
|
||||
type NewTxsEvent struct{ Txs []*types.Transaction }
|
||||
|
||||
// NewMinedBlockEvent is posted when a block has been imported.
|
||||
type NewMinedBlockEvent struct{ Block *types.Block }
|
||||
|
||||
// RemovedLogsEvent is posted when a reorg happens
|
||||
type RemovedLogsEvent struct{ Logs []*types.Log }
|
||||
|
||||
|
|
|
|||
|
|
@ -158,11 +158,11 @@ func (oracle *Oracle) ProcessCache() {
|
|||
go func() {
|
||||
var lastHead common.Hash
|
||||
for ev := range headEvent {
|
||||
if ev.Block.ParentHash() != lastHead {
|
||||
if ev.Header.ParentHash != lastHead {
|
||||
oracle.historyCache.Purge()
|
||||
}
|
||||
|
||||
lastHead = ev.Block.Hash()
|
||||
lastHead = ev.Header.Hash()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package tracers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ func BenchmarkTransactionTrace(b *testing.B) {
|
|||
snap := state.StateDB.Snapshot()
|
||||
tracer.OnTxStart(evm.GetVMContext(), tx, msg.From)
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.Gas()))
|
||||
res, err := st.TransitionDb()
|
||||
res, err := st.TransitionDb(context.Background())
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -311,13 +311,13 @@ func gatherForks(configList ...interface{}) []*proto.StatusResponse_Fork {
|
|||
return forks
|
||||
}
|
||||
|
||||
func convertBlockToBlockStub(blocks []*types.Block) []*proto.BlockStub {
|
||||
func convertHeaderToBlockStub(headers []*types.Header) []*proto.BlockStub {
|
||||
var blockStubs []*proto.BlockStub
|
||||
|
||||
for _, block := range blocks {
|
||||
for _, header := range headers {
|
||||
blockStub := &proto.BlockStub{
|
||||
Hash: block.Hash().String(),
|
||||
Number: block.NumberU64(),
|
||||
Hash: header.Hash().String(),
|
||||
Number: header.Number.Uint64(),
|
||||
}
|
||||
blockStubs = append(blockStubs, blockStub)
|
||||
}
|
||||
|
|
@ -337,8 +337,8 @@ func (s *Server) ChainWatch(req *proto.ChainWatchRequest, reply proto.Bor_ChainW
|
|||
msg := <-chain2HeadCh
|
||||
|
||||
err := reply.Send(&proto.ChainWatchResponse{Type: msg.Type,
|
||||
Newchain: convertBlockToBlockStub(msg.NewChain),
|
||||
Oldchain: convertBlockToBlockStub(msg.OldChain),
|
||||
Newchain: convertHeaderToBlockStub(msg.NewChain),
|
||||
Oldchain: convertHeaderToBlockStub(msg.OldChain),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in a new issue