mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-13 13:43:30 +00:00
Unmarshal Block instead of State (#5246)
* unmarshal block instead of state * add fallback * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal * Merge refs/heads/master into dontUnmarshal
This commit is contained in:
parent
3e81afd7ab
commit
c8f8e3f1e0
@ -308,20 +308,34 @@ func slotByBlockRoot(ctx context.Context, tx *bolt.Tx, blockRoot []byte) (uint64
|
||||
return stateSummary.Slot, nil
|
||||
}
|
||||
|
||||
bkt := tx.Bucket(stateBucket)
|
||||
bkt := tx.Bucket(blocksBucket)
|
||||
enc := bkt.Get(blockRoot)
|
||||
if enc == nil {
|
||||
return 0, errors.New("state enc can't be nil")
|
||||
// fallback and check the state.
|
||||
bkt = tx.Bucket(stateBucket)
|
||||
enc = bkt.Get(blockRoot)
|
||||
if enc == nil {
|
||||
return 0, errors.New("state enc can't be nil")
|
||||
}
|
||||
s, err := createState(enc)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if s == nil {
|
||||
return 0, errors.New("state can't be nil")
|
||||
}
|
||||
return s.Slot, nil
|
||||
}
|
||||
|
||||
s, err := createState(enc)
|
||||
b := ðpb.SignedBeaconBlock{}
|
||||
err := decode(enc, b)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if s == nil {
|
||||
return 0, errors.New("state can't be nil")
|
||||
if b.Block == nil {
|
||||
return 0, errors.New("block can't be nil")
|
||||
}
|
||||
return s.Slot, nil
|
||||
return b.Block.Slot, nil
|
||||
}
|
||||
|
||||
// HighestSlotStates returns the states with the highest slot from the db.
|
||||
|
Loading…
Reference in New Issue
Block a user