From 31eacecb49fe42dfd1fa09efad394798e326863e Mon Sep 17 00:00:00 2001 From: "fateme.r" Date: Sat, 17 Feb 2024 14:59:07 +0330 Subject: [PATCH] Optimizze commitment script filters --- src/main/scala/rosen/bridge/scripts/Commitment.es | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/scala/rosen/bridge/scripts/Commitment.es b/src/main/scala/rosen/bridge/scripts/Commitment.es index f4ec905..0ea9bf5 100644 --- a/src/main/scala/rosen/bridge/scripts/Commitment.es +++ b/src/main/scala/rosen/bridge/scripts/Commitment.es @@ -21,18 +21,17 @@ } .slice(0, trigger.R7[Int].get) .map{(box:Box) => box.R4[Coll[Byte]].get} - val commitmentWIDs = INPUTS.filter{(box:Box) => + val commitmentsWithMyWid = INPUTS.filter{(box:Box) => box.tokens.size > 0 && box.tokens(0)._1 == SELF.tokens(0)._1 && - box.propositionBytes == SELF.propositionBytes + box.propositionBytes == SELF.propositionBytes && + box.R4[Coll[Byte]].get == myWID } - .map{(box:Box) => box.R4[Coll[Byte]].get} val permitBox = OUTPUTS.filter {(box:Box) => box.R4[Coll[Byte]].isDefined && box.R4[Coll[Byte]].get == myWID }(0) val WIDExists = WIDs.exists {(WID: Coll[Byte]) => myWID == WID} - val commitmentWithWid = commitmentWIDs.filter{(WID: Coll[Byte]) => myWID == WID} sigmaProp( allOf( Coll( @@ -41,7 +40,7 @@ permitBox.tokens(0)._2 == SELF.tokens(0)._2, // check for duplicates WIDExists == false, - commitmentWithWid.size == 1, + commitmentsWithMyWid.size == 1, // validate commitment blake2b256(eventData ++ myWID) == SELF.R6[Coll[Byte]].get )