Add a POST /api/nimbus/v1/graffiti API

This commit is contained in:
Zahary Karadjov 2021-03-26 19:57:02 +02:00 committed by zah
parent cc3851ec02
commit 5266db3485
2 changed files with 14 additions and 1 deletions

View File

@ -11,7 +11,7 @@ import
std/osproc,
# Nimble packages
chronos, json_rpc/servers/httpserver, presto
chronos, json_rpc/servers/httpserver, presto,
# Local modules
./conf, ./beacon_clock, ./beacon_chain_db,

View File

@ -139,6 +139,19 @@ proc installNimbusApiHandlers*(router: var RestRouter, node: BeaconNode) =
))
return RestApiResponse.jsonResponse((peers: res))
router.api(MethodPost, "/api/nimbus/v1/graffiti") do (
graffiti: Option[string]) -> RestApiResponse:
if graffiti.isSome and graffiti.get.isOk:
try:
node.graffitiBytes = GraffitiBytes.init(graffiti.get.get)
return RestApiResponse.jsonResponse((result: true))
except CatchableError as err:
return RestApiResponse.jsonError(
Http400, "Invalid graffiti string", err.msg)
else:
return RestApiResponse.jsonError(
Http400, "You must specify a valid graffiti string")
router.api(MethodPost, "/api/nimbus/v1/chronicles/settings") do (
log_level: Option[string]) -> RestApiResponse:
if log_level.isSome():