From 10013b5fa9378f42b403bca31aaac987a40ad433 Mon Sep 17 00:00:00 2001 From: peterlimg Date: Fri, 31 Jan 2025 21:56:00 +1100 Subject: [PATCH] Clear sign cache when switch wallet --- wasmsdk/wallet_base.go | 2 ++ zboxcore/zboxutil/http.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/wasmsdk/wallet_base.go b/wasmsdk/wallet_base.go index 3f7e1be44..f53fc02c5 100644 --- a/wasmsdk/wallet_base.go +++ b/wasmsdk/wallet_base.go @@ -1,6 +1,7 @@ package main import ( + "github.com/0chain/gosdk/zboxcore/zboxutil/httputil" "github.com/0chain/gosdk/zcncore" ) @@ -23,6 +24,7 @@ func splitKeys(privateKey string, numSplits int) (string, error) { // // nolint: unused func setWalletInfo(jsonWallet string, splitKeyWallet bool) bool { + httputil.ClearSignCache() err := zcncore.SetWalletInfo(jsonWallet, "bls0chain", splitKeyWallet) if err == nil { return true diff --git a/zboxcore/zboxutil/http.go b/zboxcore/zboxutil/http.go index d8a474fe0..f3ec6d847 100644 --- a/zboxcore/zboxutil/http.go +++ b/zboxcore/zboxutil/http.go @@ -986,3 +986,11 @@ func joinUrl(baseURl string, paths ...string) (*url.URL, error) { u.Path = path.Join(u.Path, p) return u, nil } + +func ClearSignCache() { + c, err := lru.New[string, string](1000) + if err != nil { + panic(err) + } + SignCache = c +}