From 39eeae83a68629a5876251bef5ea0adf621088da Mon Sep 17 00:00:00 2001 From: Abdul Rabbani Date: Fri, 13 May 2022 09:51:51 -0400 Subject: [PATCH] Utilize the MHkey --- pkg/beaconclient/databasewrite.go | 9 ++++++--- pkg/beaconclient/multihash.go | 5 ++++- pkg/beaconclient/processslot.go | 4 +--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg/beaconclient/databasewrite.go b/pkg/beaconclient/databasewrite.go index 51eb983..f065f62 100644 --- a/pkg/beaconclient/databasewrite.go +++ b/pkg/beaconclient/databasewrite.go @@ -58,10 +58,13 @@ type DatabaseWriter struct { rawSignedBeaconBlock []byte } -func CreateDatabaseWrite(db sql.Database, slot int, stateRoot string, blockRoot string, parentBlockRoot string, eth1BlockHash string, status string, metrics *BeaconClientMetrics) (*DatabaseWriter, error) { +func CreateDatabaseWrite(db sql.Database, slot int, stateRoot string, blockRoot string, parentBlockRoot string, + eth1BlockHash string, status string, rawSignedBeaconBlock []byte, rawBeaconState []byte, metrics *BeaconClientMetrics) (*DatabaseWriter, error) { dw := &DatabaseWriter{ - Db: db, - Metrics: metrics, + Db: db, + rawBeaconState: rawBeaconState, + rawSignedBeaconBlock: rawSignedBeaconBlock, + Metrics: metrics, } dw.prepareSlotsModel(slot, stateRoot, blockRoot, status) err := dw.prepareSignedBeaconBlockModel(slot, blockRoot, parentBlockRoot, eth1BlockHash) diff --git a/pkg/beaconclient/multihash.go b/pkg/beaconclient/multihash.go index d88ca2b..4a4d8e6 100644 --- a/pkg/beaconclient/multihash.go +++ b/pkg/beaconclient/multihash.go @@ -4,6 +4,7 @@ import ( blockstore "github.com/ipfs/go-ipfs-blockstore" dshelp "github.com/ipfs/go-ipfs-ds-help" "github.com/multiformats/go-multihash" + log "github.com/sirupsen/logrus" "github.com/vulcanize/ipld-ethcl-indexer/pkg/loghelper" ) @@ -17,5 +18,7 @@ func MultihashKeyFromSSZRoot(root []byte) (string, error) { return "", err } dbKey := dshelp.MultihashToDsKey(mh) - return blockstore.BlockPrefix.String() + dbKey.String(), nil + mhKey := blockstore.BlockPrefix.String() + dbKey.String() + log.WithFields(log.Fields{"mhKey": mhKey, "len": len(root)}).Debug("The MHKEY") + return mhKey, nil } diff --git a/pkg/beaconclient/processslot.go b/pkg/beaconclient/processslot.go index 94a4349..8915db2 100644 --- a/pkg/beaconclient/processslot.go +++ b/pkg/beaconclient/processslot.go @@ -259,12 +259,10 @@ func (ps *ProcessSlot) createWriteObjects(blockRootEndpoint string) (*DatabaseWr status = "proposed" } - dw, err := CreateDatabaseWrite(ps.Db, ps.Slot, stateRoot, blockRoot, ps.ParentBlockRoot, eth1BlockHash, status, ps.Metrics) + dw, err := CreateDatabaseWrite(ps.Db, ps.Slot, stateRoot, blockRoot, ps.ParentBlockRoot, eth1BlockHash, status, ps.SszSignedBeaconBlock, ps.SszBeaconState, ps.Metrics) if err != nil { return dw, err } - dw.rawSignedBeaconBlock = ps.SszSignedBeaconBlock - dw.rawBeaconState = ps.SszBeaconState return dw, nil }