From c35949391e40207e1a0fbf33d4c02a0e1e6b9695 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Mon, 12 Aug 2024 15:52:59 +0200 Subject: [PATCH] add string decoding/encoding for rawdb.Target --- core/rawdb/accessors_state_arbitrum.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/rawdb/accessors_state_arbitrum.go b/core/rawdb/accessors_state_arbitrum.go index b9a0656474..9ca3be7ec7 100644 --- a/core/rawdb/accessors_state_arbitrum.go +++ b/core/rawdb/accessors_state_arbitrum.go @@ -17,6 +17,8 @@ package rawdb import ( + "errors" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" @@ -31,6 +33,20 @@ const ( TargetHost Target = "host" ) +func (t Target) ToString() string { + return string(t) +} + +func TargetFromString(str string) (Target, error) { + target := Target(str) + switch target { + case TargetWavm, TargetArm64, TargetAmd64, TargetHost: + return target, nil + default: + return target, errors.New("unsupported target") + } +} + var Targets = []Target{TargetWavm, TargetArm64, TargetAmd64, TargetHost} func WriteActivation(db ethdb.KeyValueWriter, moduleHash common.Hash, asmMap map[Target][]byte) {