From c14cf95b8aa33361f10e808ff8e9fb2785d86adc Mon Sep 17 00:00:00 2001 From: mikera Date: Mon, 13 Jan 2025 18:39:04 +0000 Subject: [PATCH] Make set-peer-data less strict to allow controllers with different keys --- .../src/main/java/convex/core/cvm/Context.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/convex-core/src/main/java/convex/core/cvm/Context.java b/convex-core/src/main/java/convex/core/cvm/Context.java index b6debb472..dfeedcb46 100644 --- a/convex-core/src/main/java/convex/core/cvm/Context.java +++ b/convex-core/src/main/java/convex/core/cvm/Context.java @@ -2159,20 +2159,17 @@ public Context setPeerData(AccountKey peerKey, AHashMap data) { // get the callers account and account status Address address = getAddress(); - AccountStatus as = getAccountStatus(address); - AccountKey ak = as.getAccountKey(); - if (ak == null) return withError(ErrorCodes.STATE,"The account signing this transaction must have a public key"); - PeerStatus ps=s.getPeer(ak); - if (ps==null) return withError(ErrorCodes.STATE,"Peer does not exist for this account and account key: "+ak.toChecksumHex()); - if (!ps.getController().equals(address)) return withError(ErrorCodes.STATE,"Current address "+address+" is not the controller of this peer account"); + PeerStatus ps=s.getPeer(peerKey); + if (ps==null) return withError(ErrorCodes.STATE,"Peer does not exist for key: "+peerKey); + if (!Utils.equals(ps.getController(),address)) return withError(ErrorCodes.STATE,"Current address "+address+" is not the controller of this peer account"); Hash lastStateHash = s.getHash(); // TODO: should use complete Map // at the moment only :url is used in the data map AHashMap newMeta=data; PeerStatus updatedPeer=ps.withPeerData(newMeta); - s=s.withPeer(ak, updatedPeer); // adjust peer + s=s.withPeer(peerKey, updatedPeer); // adjust peer // if no change just return the current context if (lastStateHash.equals(s.getHash())){