Skip to content

Commit

Permalink
CashShuffle: some minor nits
Browse files Browse the repository at this point in the history
  • Loading branch information
cculianu committed Feb 28, 2019
1 parent ba645fe commit 7a52414
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions plugins/shuffle/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def wrapper(self):
return wrapper

def __init__(self):
self.clear_packets()

def clear_packets(self):
"clear the packets"
self.packets = message_factory.Packets()
self.phases = {
'Announcement':message_factory.ANNOUNCEMENT,
Expand All @@ -25,7 +29,6 @@ def __init__(self):
'Blame':message_factory.BLAME,
}


def blame_reason(self, name):
"""
This method returns the number of blame reason by its name
Expand Down Expand Up @@ -200,19 +203,19 @@ def add_hash(self, hash_value):
def add_signatures(self, signatures):
"adds signatures to NEW packet"
packet = self.packets.packet.add()
for k in signatures:
for utxo, sig in signatures.items():
packet.packet.message.signatures.add()
packet.packet.message.signatures[-1].utxo = k
packet.packet.message.signatures[-1].signature.signature = signatures[k]
packet.packet.message.signatures[-1].utxo = utxo
packet.packet.message.signatures[-1].signature.signature = sig

def shuffle_packets(self):
"shuffle the packets"
packs = [p for p in self.packets.packet]
shuffle(packs)
self.clear_packets()
for i in range(0, len(packs)):
for p in packs:
self.packets.packet.add()
self.packets.packet[-1].CopyFrom(packs[i])
self.packets.packet[-1].CopyFrom(p)

def encryption_keys_count(self):
"counts the number of encryption keys"
Expand Down Expand Up @@ -326,6 +329,3 @@ def get_strs(self):
"gets strs values from the packets"
return [packet.packet.message.str for packet in self.packets.packet]

def clear_packets(self):
"clear the packets"
self.__init__()

0 comments on commit 7a52414

Please sign in to comment.