mirror of https://github.com/nucypher/nucypher.git
Don't obtain entire ritual when only specific participant information is needed for determining participation state.
parent
6c56dd2d9b
commit
e1a74366a0
|
@ -246,10 +246,16 @@ class ActiveRitualTracker:
|
|||
Returns node's participant information for the provided
|
||||
ritual id; None if node is not participating in the ritual
|
||||
"""
|
||||
ritual = self.coordinator_agent.get_ritual(ritual_id=ritual_id)
|
||||
for p in ritual.participants:
|
||||
if p.provider == self.operator.checksum_address:
|
||||
return p
|
||||
is_participant = self.coordinator_agent.is_participant(
|
||||
ritual_id=ritual_id, provider=self.operator.checksum_address
|
||||
)
|
||||
if is_participant:
|
||||
participant = self.coordinator_agent.get_participant(
|
||||
ritual_id=ritual_id,
|
||||
provider=self.operator.checksum_address,
|
||||
transcript=True,
|
||||
)
|
||||
return participant
|
||||
|
||||
return None
|
||||
|
||||
|
|
|
@ -255,9 +255,7 @@ def test_get_ritual_participant_info(ritualist, get_random_checksum_address):
|
|||
)
|
||||
participants.append(participant)
|
||||
|
||||
mock_ritual = Mock()
|
||||
mock_ritual.participants = participants
|
||||
mocked_agent.get_ritual.return_value = mock_ritual
|
||||
mocked_agent.is_participant.return_value = False
|
||||
|
||||
# operator not in participants list
|
||||
participant_info = active_ritual_tracker._get_ritual_participant_info(ritual_id=0)
|
||||
|
@ -269,6 +267,9 @@ def test_get_ritual_participant_info(ritualist, get_random_checksum_address):
|
|||
)
|
||||
participants.append(participant)
|
||||
|
||||
mocked_agent.is_participant.return_value = True
|
||||
mocked_agent.get_participant.return_value = participant
|
||||
|
||||
# operator in participants list
|
||||
participant_info = active_ritual_tracker._get_ritual_participant_info(ritual_id=0)
|
||||
assert participant_info
|
||||
|
@ -289,9 +290,7 @@ def test_get_participation_state_values_from_contract(
|
|||
)
|
||||
participants.append(participant)
|
||||
|
||||
mock_ritual = Mock()
|
||||
mock_ritual.participants = participants
|
||||
mocked_agent.get_ritual.return_value = mock_ritual
|
||||
mocked_agent.is_participant.return_value = False
|
||||
|
||||
# not participating so everything should be False
|
||||
(
|
||||
|
@ -308,6 +307,8 @@ def test_get_participation_state_values_from_contract(
|
|||
index=i + 1, provider=ritualist.checksum_address
|
||||
)
|
||||
participants.append(ritual_participant)
|
||||
mocked_agent.is_participant.return_value = True
|
||||
mocked_agent.get_participant.return_value = ritual_participant
|
||||
|
||||
# participating, but nothing submitted
|
||||
(
|
||||
|
|
Loading…
Reference in New Issue