Simplify handling hex state ID (#8890)

Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
Radosław Kapka
2021-05-17 09:56:00 +02:00
committed by GitHub
parent e6a1d5b1b9
commit e254e8edcc
2 changed files with 2 additions and 10 deletions

View File

@@ -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)

View File

@@ -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)