avoid `read`/`readError` in favor of `value`/`error` (#5904)

In VC logic, bump 3 remaining uses of `readError`/`read` to use
`error`/`value` instead. The surrounding logic guarantees success.
This commit is contained in:
Etan Kissling 2024-02-19 10:52:35 +01:00 committed by GitHub
parent 4fc1550d0f
commit e04e95167d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -5,6 +5,8 @@
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
import std/strutils
import chronicles, stew/base10
import ".."/spec/eth2_apis/eth2_rest_serialization,
@ -123,7 +125,7 @@ proc apiResponseOr[T](future: FutureBase, timerFut: Future[void],
if future.failed():
ApiResponse[T].err($future.error.msg)
else:
ApiResponse[T].ok(Future[T](future).read())
ApiResponse[T].ok(Future[T](future).value())
else:
if timerFut.finished():
ApiResponse[T].err(message)

View File

@ -5,6 +5,8 @@
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{.push raises: [].}
import
std/[tables, os, sets, sequtils, strutils, uri, algorithm],
results,
@ -1045,12 +1047,12 @@ proc getValidatorRegistration(
if sigfut.finished():
# This is short-path if we able to create signature locally.
if not(sigfut.completed()):
let exc = sigfut.readError()
let exc = sigfut.error()
debug "Got unexpected exception while signing validator registration",
validator = shortLog(validator), error_name = $exc.name,
error_msg = $exc.msg
return err(RegistrationKind.ErrorSignature)
let sigres = sigfut.read()
let sigres = sigfut.value()
if sigres.isErr():
debug "Failed to get signature for validator registration",
validator = shortLog(validator), error = sigres.error()