mirror of https://github.com/nucypher/nucypher.git
Remove use of index within Participant struct - we don't specifically use it.
parent
c84060b2bd
commit
00788e9001
|
@ -691,12 +691,10 @@ class CoordinatorAgent(EthereumContractAgent):
|
|||
def get_participant(
|
||||
self, ritual_id: int, provider: ChecksumAddress, transcript: bool
|
||||
) -> Coordinator.Participant:
|
||||
data, index = self.contract.functions.getParticipant(
|
||||
data = self.contract.functions.getParticipant(
|
||||
ritual_id, provider, transcript
|
||||
).call()
|
||||
participant = next(
|
||||
iter(Coordinator.Ritual.make_participants([data], start=index))
|
||||
)
|
||||
participant = next(iter(Coordinator.Ritual.make_participants([data])))
|
||||
return participant
|
||||
|
||||
@contract_api(CONTRACT_CALL)
|
||||
|
@ -708,9 +706,7 @@ class CoordinatorAgent(EthereumContractAgent):
|
|||
data = self.contract.functions.getParticipants(
|
||||
ritual_id, start_index, max_results, transcripts
|
||||
).call()
|
||||
participants = Coordinator.Ritual.make_participants(
|
||||
data=data, start=start_index
|
||||
)
|
||||
participants = Coordinator.Ritual.make_participants(data=data)
|
||||
return participants
|
||||
|
||||
def _get_participants(
|
||||
|
|
|
@ -95,16 +95,14 @@ class Coordinator:
|
|||
|
||||
@dataclass
|
||||
class Participant:
|
||||
index: int
|
||||
provider: ChecksumAddress
|
||||
aggregated: bool = False
|
||||
transcript: bytes = bytes()
|
||||
decryption_request_static_key: bytes = bytes()
|
||||
|
||||
@classmethod
|
||||
def from_data(cls, index: int, data: list):
|
||||
def from_data(cls, data: list):
|
||||
return cls(
|
||||
index=index,
|
||||
provider=ChecksumAddress(data[0]),
|
||||
aggregated=data[1],
|
||||
transcript=bytes(data[2]),
|
||||
|
@ -155,12 +153,8 @@ class Coordinator:
|
|||
return participant_public_keys
|
||||
|
||||
@staticmethod
|
||||
def make_participants(
|
||||
data: list, start: int = 0
|
||||
) -> Iterable["Coordinator.Participant"]:
|
||||
def make_participants(data: list) -> Iterable["Coordinator.Participant"]:
|
||||
"""Converts a list of participant data into an iterable of Participant objects."""
|
||||
for i, participant_data in enumerate(data, start=start):
|
||||
participant = Coordinator.Participant.from_data(
|
||||
index=i, data=participant_data
|
||||
)
|
||||
for participant_data in data:
|
||||
participant = Coordinator.Participant.from_data(data=participant_data)
|
||||
yield participant
|
||||
|
|
|
@ -257,7 +257,6 @@ def test_get_participation_state_start_aggregation_round_participation_not_alrea
|
|||
#
|
||||
def participating(*args, **kwargs):
|
||||
participant = Coordinator.Participant(
|
||||
index=0,
|
||||
provider=ChecksumAddress(ursula.checksum_address),
|
||||
aggregated=False,
|
||||
transcript=os.urandom(32),
|
||||
|
@ -392,7 +391,6 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked(
|
|||
#
|
||||
def participating(*args, **kwargs):
|
||||
participant = Coordinator.Participant(
|
||||
index=0,
|
||||
provider=ChecksumAddress(ursula.checksum_address),
|
||||
aggregated=True,
|
||||
transcript=os.urandom(32),
|
||||
|
@ -422,7 +420,6 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked(
|
|||
#
|
||||
def participating(*args, **kwargs):
|
||||
participant = Coordinator.Participant(
|
||||
index=0,
|
||||
provider=ChecksumAddress(ursula.checksum_address),
|
||||
aggregated=False,
|
||||
transcript=bytes(),
|
||||
|
@ -456,7 +453,6 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked(
|
|||
#
|
||||
def participating(*args, **kwargs):
|
||||
participant = Coordinator.Participant(
|
||||
index=0,
|
||||
provider=ChecksumAddress(ursula.checksum_address),
|
||||
aggregated=False,
|
||||
transcript=os.urandom(32),
|
||||
|
|
|
@ -249,10 +249,8 @@ def test_get_ritual_participant_info(ritualist, get_random_checksum_address):
|
|||
|
||||
participants = []
|
||||
# random participants
|
||||
for i in range(0, 3):
|
||||
participant = Coordinator.Participant(
|
||||
index=i, provider=get_random_checksum_address()
|
||||
)
|
||||
for _ in range(0, 3):
|
||||
participant = Coordinator.Participant(provider=get_random_checksum_address())
|
||||
participants.append(participant)
|
||||
|
||||
mocked_agent.is_participant.return_value = False
|
||||
|
@ -262,9 +260,7 @@ def test_get_ritual_participant_info(ritualist, get_random_checksum_address):
|
|||
assert participant_info is None
|
||||
|
||||
# add operator to participants list
|
||||
participant = Coordinator.Participant(
|
||||
index=i + 1, provider=ritualist.checksum_address
|
||||
)
|
||||
participant = Coordinator.Participant(provider=ritualist.checksum_address)
|
||||
participants.append(participant)
|
||||
|
||||
mocked_agent.is_participant.return_value = True
|
||||
|
@ -284,10 +280,8 @@ def test_get_participation_state_values_from_contract(
|
|||
|
||||
participants = []
|
||||
# random participants
|
||||
for i in range(0, 5):
|
||||
participant = Coordinator.Participant(
|
||||
index=i, provider=get_random_checksum_address()
|
||||
)
|
||||
for _ in range(0, 5):
|
||||
participant = Coordinator.Participant(provider=get_random_checksum_address())
|
||||
participants.append(participant)
|
||||
|
||||
mocked_agent.is_participant.return_value = False
|
||||
|
@ -303,9 +297,7 @@ def test_get_participation_state_values_from_contract(
|
|||
assert not posted_aggregate
|
||||
|
||||
# add operator to participants list
|
||||
ritual_participant = Coordinator.Participant(
|
||||
index=i + 1, provider=ritualist.checksum_address
|
||||
)
|
||||
ritual_participant = Coordinator.Participant(provider=ritualist.checksum_address)
|
||||
participants.append(ritual_participant)
|
||||
mocked_agent.is_participant.return_value = True
|
||||
mocked_agent.get_participant.return_value = ritual_participant
|
||||
|
|
|
@ -102,8 +102,7 @@ class MockCoordinatorAgent(MockContractAgent):
|
|||
init_timestamp=init_timestamp,
|
||||
end_timestamp=end_timestamp,
|
||||
participants=[
|
||||
self.Participant(index=i, provider=provider)
|
||||
for i, provider in enumerate(providers)
|
||||
self.Participant(provider=provider) for provider in providers
|
||||
],
|
||||
dkg_size=len(providers),
|
||||
threshold=self.get_threshold_for_ritual_size(len(providers)),
|
||||
|
|
|
@ -60,7 +60,6 @@ def test_initiate_ritual(
|
|||
|
||||
participants = [
|
||||
Coordinator.Participant(
|
||||
index=i,
|
||||
provider=c,
|
||||
)
|
||||
for i, c in enumerate(cohort)
|
||||
|
@ -98,7 +97,6 @@ def test_perform_round_1(
|
|||
participants = dict()
|
||||
for i, checksum_address in enumerate(cohort):
|
||||
participants[checksum_address] = Coordinator.Participant(
|
||||
index=i,
|
||||
provider=checksum_address,
|
||||
)
|
||||
|
||||
|
@ -191,7 +189,6 @@ def test_perform_round_2(
|
|||
participants = dict()
|
||||
for i, checksum_address in enumerate(cohort):
|
||||
participant = Coordinator.Participant(
|
||||
index=i,
|
||||
transcript=bytes(random_transcript),
|
||||
provider=checksum_address,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue