From a5dd6cd73f21d67eb9f872dbf16156101fc9dafb Mon Sep 17 00:00:00 2001 From: yc Date: Sat, 18 Apr 2026 20:40:23 +0200 Subject: [PATCH] delete peer cache fix --- client/identity.go | 3 +++ client/peerstorage.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/identity.go b/client/identity.go index 42d9782..c7a7507 100644 --- a/client/identity.go +++ b/client/identity.go @@ -426,6 +426,9 @@ func (id *Identity) GetRequestJobs() []RequestsJob { } func (id *Identity) SaveBackgroundJob() error { + if id.RootKp == nil { + return errors.New("identity not fully initialized: RootKp is nil") + } var bj BackgroundJob bj.Jobs = id.GetRequestJobs() bj.RootPublic = id.RootKp.Public diff --git a/client/peerstorage.go b/client/peerstorage.go index 34f67ef..354927d 100644 --- a/client/peerstorage.go +++ b/client/peerstorage.go @@ -109,9 +109,13 @@ func (ps *PeerStorage) DeletePeer(uid string) error { defer ps.close() shakey := sha256.Sum256([]byte(uid)) key := shakey[:] - return ps.db.Update(func(txn *badger.Txn) error { + err = ps.db.Update(func(txn *badger.Txn) error { return txn.Delete(key) }) + if err == nil { + delete(ps.cache, uid) + } + return err } // LoadPeers function loads Peers from the badger database with a specific password