Added db.BlocksBySlot and db.BlockRootsBySlot (#8184)

* Added blockBySlot and blockRootBySlot

* Changed to BlocksBySlot and BlockRootsBySlot

* Updated to use BlocksBySlot and BlockRootsBySlot

* Added missing passthrough to karfa exporter

* Return hasBlocks/hasBlockRoots in the new getters

* Fixed CI lint

* Replace call to bytes.Compare with bytes.Equal

* Reordered the returns of the new getters

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
pinglamb
2021-01-13 02:31:15 +08:00
committed by GitHub
parent 015102c2d5
commit 9f423617cb
11 changed files with 156 additions and 19 deletions

View File

@@ -69,8 +69,7 @@ func main() {
// If the state is not available, roll back
for state == nil {
slot--
filter := filters.NewFilter().SetStartSlot(slot).SetEndSlot(slot)
rts, err := db.BlockRoots(context.Background(), filter)
_, rts, err := db.BlockRootsBySlot(context.Background(), slot)
if err != nil {
panic(err)
}

View File

@@ -9,7 +9,6 @@ go_library(
deps = [
"//beacon-chain/core/state/interop:go_default_library",
"//beacon-chain/db:go_default_library",
"//beacon-chain/db/filters:go_default_library",
"//shared/featureconfig:go_default_library",
],
)

View File

@@ -7,7 +7,6 @@ import (
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/db/filters"
"github.com/prysmaticlabs/prysm/shared/featureconfig"
)
@@ -29,7 +28,7 @@ func main() {
}
ctx := context.Background()
slot := uint64(*state)
roots, err := d.BlockRoots(ctx, filters.NewFilter().SetStartSlot(slot).SetEndSlot(slot))
_, roots, err := d.BlockRootsBySlot(ctx, slot)
if err != nil {
panic(err)
}