From 967626b0759e0d0ebec4d09a00244db2d94adf61 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 22 Aug 2022 11:48:26 -0700 Subject: [PATCH] Updates to reflect comments on original merge. --- core/rawdb/plugin_hooks.go | 114 +++++++++--------- go.mod | 2 - .../wrappers/backendwrapper/backendwrapper.go | 5 +- 3 files changed, 60 insertions(+), 61 deletions(-) diff --git a/core/rawdb/plugin_hooks.go b/core/rawdb/plugin_hooks.go index 017bcd7cf..05a0b36d3 100644 --- a/core/rawdb/plugin_hooks.go +++ b/core/rawdb/plugin_hooks.go @@ -4,7 +4,7 @@ package rawdb import ( "github.com/ethereum/go-ethereum/plugins" "github.com/ethereum/go-ethereum/log" - // "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rlp" "sync" ) @@ -57,64 +57,64 @@ func PluginCommitUpdate(pl *plugins.PluginLoader, num uint64) { fn(i, update) } } - _ = pl.Lookup("AppendAncient", func(item interface{}) bool { + appendAncientFnList := pl.Lookup("AppendAncient", func(item interface{}) bool { _, ok := item.(func(number uint64, hash, header, body, receipts, td []byte)) - if ok { log.Warn("PlugEth's AppendAncient is deprecated. Please update to ModifyAncients.") } + if ok { log.Warn("PluGeth's AppendAncient is deprecated. Please update to ModifyAncients.") } return ok }) - // if len(appendAncientFnList) > 0 { - // var ( - // hash []byte - // header []byte - // body []byte - // receipts []byte - // td []byte - // ) - // if hashi, ok := update[freezerHashTable]; ok { - // switch v := hashi.(type) { - // case []byte: - // hash = v - // default: - // hash, _ = rlp.EncodeToBytes(v) - // } - // } - // if headeri, ok := update[freezerHeaderTable]; ok { - // switch v := headeri.(type) { - // case []byte: - // header = v - // default: - // header, _ = rlp.EncodeToBytes(v) - // } - // } - // if bodyi, ok := update[freezerBodiesTable]; ok { - // switch v := bodyi.(type) { - // case []byte: - // body = v - // default: - // body, _ = rlp.EncodeToBytes(v) - // } - // } - // if receiptsi, ok := update[freezerReceiptTable]; ok { - // switch v := receiptsi.(type) { - // case []byte: - // receipts = v - // default: - // receipts, _ = rlp.EncodeToBytes(v) - // } - // } - // if tdi, ok := update[freezerDifficultyTable]; ok { - // switch v := tdi.(type) { - // case []byte: - // td = v - // default: - // td, _ = rlp.EncodeToBytes(v) - // } - // } - // for _, fni := range appendAncientFnList { - // if fn, ok := fni.(func(number uint64, hash, header, body, receipts, td []byte)); ok { - // fn(i, hash, header, body, receipts, td) - // } - // } - // } + if len(appendAncientFnList) > 0 { + var ( + hash []byte + header []byte + body []byte + receipts []byte + td []byte + ) + if hashi, ok := update[chainFreezerHashTable]; ok { + switch v := hashi.(type) { + case []byte: + hash = v + default: + hash, _ = rlp.EncodeToBytes(v) + } + } + if headeri, ok := update[chainFreezerHeaderTable]; ok { + switch v := headeri.(type) { + case []byte: + header = v + default: + header, _ = rlp.EncodeToBytes(v) + } + } + if bodyi, ok := update[chainFreezerBodiesTable]; ok { + switch v := bodyi.(type) { + case []byte: + body = v + default: + body, _ = rlp.EncodeToBytes(v) + } + } + if receiptsi, ok := update[chainFreezerReceiptTable]; ok { + switch v := receiptsi.(type) { + case []byte: + receipts = v + default: + receipts, _ = rlp.EncodeToBytes(v) + } + } + if tdi, ok := update[chainFreezerDifficultyTable]; ok { + switch v := tdi.(type) { + case []byte: + td = v + default: + td, _ = rlp.EncodeToBytes(v) + } + } + for _, fni := range appendAncientFnList { + if fn, ok := fni.(func(number uint64, hash, header, body, receipts, td []byte)); ok { + fn(i, hash, header, body, receipts, td) + } + } + } } } diff --git a/go.mod b/go.mod index cf0ba4ff2..1c9a8dbe1 100644 --- a/go.mod +++ b/go.mod @@ -105,5 +105,3 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - -replace github.com/openrelayxyz/plugeth-utils v0.0.18 => ../plugeth-utils diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index a88ed8cac..0027ac223 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -173,8 +173,9 @@ func (b *Backend) TxPoolContent() (map[core.Address][][]byte, map[core.Address][ func (b *Backend) BloomStatus() (uint64, uint64) { return b.b.BloomStatus() } -func (b *Backend) GetLogs(ctx context.Context, blockHash core.Hash, number uint64) ([][]byte, error) { - logs, err := b.b.GetLogs(ctx, common.Hash(blockHash), number) +func (b *Backend) GetLogs(ctx context.Context, blockHash core.Hash) ([][]byte, error) { + header, _ := b.b.HeaderByHash(ctx, common.Hash(blockHash)) + logs, err := b.b.GetLogs(ctx, common.Hash(blockHash), uint64(header.Number.Uint64())) if err != nil { return nil, err }