From 38d0efc96c65cfd1f5f05ef3804a8afb41d05db5 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 12 Feb 2020 14:56:40 +0300 Subject: [PATCH] core: fix Registered state descriptor processing It has simple boolean value encoded, no `strconv` needed (it actually chokes on such input). --- pkg/core/blockchain.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 43d716114..1f3866ee2 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -5,7 +5,6 @@ import ( "math" "math/big" "sort" - "strconv" "sync" "sync/atomic" "time" @@ -684,12 +683,11 @@ func processValidatorStateDescriptor(descriptor *transaction.StateDescriptor, da return err } if descriptor.Field == "Registered" { - isRegistered, err := strconv.ParseBool(string(descriptor.Value)) - if err != nil { - return err + if len(descriptor.Value) == 1 { + validatorState.Registered = descriptor.Value[0] != 0 + return dao.PutValidatorState(validatorState) } - validatorState.Registered = isRegistered - return dao.PutValidatorState(validatorState) + return errors.New("bad descriptor value") } return nil }