mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
fix: way to determine fork
Signed-off-by: Isma <71719097+Doozers@users.noreply.github.com>
This commit is contained in:
parent
2b7eccf7d0
commit
959741f6ec
1 changed files with 5 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
|
|
||||||
"github.com/attestantio/go-eth2-client/http"
|
"github.com/attestantio/go-eth2-client/http"
|
||||||
|
"github.com/attestantio/go-eth2-client/spec"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
@ -76,7 +77,6 @@ func Start(pt *toolkit.PluginToolkit, cfg map[string]interface{}, ctx context.Co
|
||||||
me := NewMonitoringEngine(pt, rdb, client, beaconEndpoint, errChan)
|
me := NewMonitoringEngine(pt, rdb, client, beaconEndpoint, errChan)
|
||||||
|
|
||||||
me.Start(ctx)
|
me.Start(ctx)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MonitoringEngine is the main plugin struct
|
// MonitoringEngine is the main plugin struct
|
||||||
|
|
@ -136,7 +136,6 @@ func (me *MonitoringEngine) Start(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *MonitoringEngine) update(ctx context.Context, parent *types.Block) {
|
func (me *MonitoringEngine) update(ctx context.Context, parent *types.Block) {
|
||||||
|
|
||||||
state, _, err := me.backend.StateAndHeaderByNumberOrHash(ctx, rpc.BlockNumberOrHashWithHash(parent.Hash(), true))
|
state, _, err := me.backend.StateAndHeaderByNumberOrHash(ctx, rpc.BlockNumberOrHashWithHash(parent.Hash(), true))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
me.errChan <- err
|
me.errChan <- err
|
||||||
|
|
@ -163,7 +162,6 @@ func (me *MonitoringEngine) encodeAndBroadcastCallTrace(ctx context.Context, at
|
||||||
topic = fmt.Sprintf("/%s/tx/%s/%s/null/%s", channel, at.Transaction.Hash(), at.From, encodeActionCalls(at.Traces))
|
topic = fmt.Sprintf("/%s/tx/%s/%s/null/%s", channel, at.Transaction.Hash(), at.From, encodeActionCalls(at.Traces))
|
||||||
} else {
|
} else {
|
||||||
topic = fmt.Sprintf("/%s/tx/%s/%s/%s/%s", channel, at.Transaction.Hash(), at.From, at.Transaction.To(), encodeActionCalls(at.Traces))
|
topic = fmt.Sprintf("/%s/tx/%s/%s/%s/%s", channel, at.Transaction.Hash(), at.From, at.Transaction.To(), encodeActionCalls(at.Traces))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
jsoned, err := json.Marshal(*at)
|
jsoned, err := json.Marshal(*at)
|
||||||
|
|
@ -279,7 +277,6 @@ func (me *MonitoringEngine) analyzePending(ctx context.Context, txs []*types.Tra
|
||||||
}
|
}
|
||||||
|
|
||||||
func (me *MonitoringEngine) startHeadListener(ctx context.Context) {
|
func (me *MonitoringEngine) startHeadListener(ctx context.Context) {
|
||||||
|
|
||||||
headChan := make(chan core.ChainHeadEvent)
|
headChan := make(chan core.ChainHeadEvent)
|
||||||
headSubscription := me.backend.SubscribeChainHeadEvent(headChan)
|
headSubscription := me.backend.SubscribeChainHeadEvent(headChan)
|
||||||
pendingChan := make(chan core.NewTxsEvent)
|
pendingChan := make(chan core.NewTxsEvent)
|
||||||
|
|
@ -348,10 +345,12 @@ func (me *MonitoringEngine) startHeadListener(ctx context.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block := res.Data
|
||||||
var blockHeight uint64
|
var blockHeight uint64
|
||||||
if me.chainConfig.CancunTime != nil {
|
switch block.Version {
|
||||||
|
case spec.DataVersionDeneb:
|
||||||
blockHeight = res.Data.Deneb.Message.Body.ExecutionPayload.BlockNumber
|
blockHeight = res.Data.Deneb.Message.Body.ExecutionPayload.BlockNumber
|
||||||
} else {
|
case spec.DataVersionCapella:
|
||||||
blockHeight = res.Data.Capella.Message.Body.ExecutionPayload.BlockNumber
|
blockHeight = res.Data.Capella.Message.Body.ExecutionPayload.BlockNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue