From a3e821fb16f5cb994175d042a39e4e43eca21121 Mon Sep 17 00:00:00 2001 From: lash Date: Sun, 8 Dec 2024 21:57:53 +0000 Subject: [PATCH] Clarify gen cmd example with reverse public key lookup --- devtools/gen/main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/devtools/gen/main.go b/devtools/gen/main.go index 401f194..6b58a50 100644 --- a/devtools/gen/main.go +++ b/devtools/gen/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "crypto/sha1" "flag" "fmt" "os" @@ -46,7 +47,18 @@ func main() { } userStore := common.UserDataStore{store} - err = userStore.WriteEntry(ctx, sessionId, common.DATA_AMOUNT, []byte("1.0")) + h := sha1.New() + h.Write([]byte(sessionId)) + address := h.Sum(nil) + addressString := fmt.Sprintf("%x", address) + + err = userStore.WriteEntry(ctx, sessionId, common.DATA_PUBLIC_KEY, []byte(addressString)) + if err != nil { + fmt.Fprintf(os.Stderr, err.Error()) + os.Exit(1) + } + + err = userStore.WriteEntry(ctx, addressString, common.DATA_PUBLIC_KEY_REVERSE, []byte(sessionId)) if err != nil { fmt.Fprintf(os.Stderr, err.Error()) os.Exit(1)