mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Simplify handling hex state ID (#8890)
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
@@ -137,11 +137,7 @@ func (bs *Server) stateRoot(ctx context.Context, stateId []byte) ([]byte, error)
|
||||
case "justified":
|
||||
root, err = bs.justifiedStateRoot(ctx)
|
||||
default:
|
||||
ok, matchErr := bytesutil.IsBytes32Hex(stateId)
|
||||
if matchErr != nil {
|
||||
return nil, errors.Wrap(err, "could not parse ID")
|
||||
}
|
||||
if ok {
|
||||
if len(stateId) == 32 {
|
||||
root, err = bs.stateRootByHex(ctx, stateId)
|
||||
} else {
|
||||
slotNumber, parseErr := strconv.ParseUint(stateIdString, 10, 64)
|
||||
|
||||
@@ -67,11 +67,7 @@ func (p *StateProvider) State(ctx context.Context, stateId []byte) (iface.Beacon
|
||||
return nil, errors.Wrap(err, "could not get justified state")
|
||||
}
|
||||
default:
|
||||
ok, matchErr := bytesutil.IsBytes32Hex(stateId)
|
||||
if matchErr != nil {
|
||||
return nil, errors.Wrap(err, "could not parse ID")
|
||||
}
|
||||
if ok {
|
||||
if len(stateId) == 32 {
|
||||
s, err = p.stateByHex(ctx, stateId)
|
||||
} else {
|
||||
slotNumber, parseErr := strconv.ParseUint(stateIdString, 10, 64)
|
||||
|
||||
Reference in New Issue
Block a user