Skip to content

Commit 321d4fd

Browse files
committed
[explorer] Send update signal to cached views process for honest revealers
1 parent 40b7b76 commit 321d4fd

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

blockchain/explorer.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def __init__(self, log_queue):
7676
log_label="db-pending",
7777
)
7878

79+
# Track data requests which are almost finished
80+
self.data_request_reveal_addresses = {}
81+
7982
def configure_logging_process(self, queue, label):
8083
handler = logging.handlers.QueueHandler(queue)
8184
root = logging.getLogger(label)
@@ -155,12 +158,33 @@ def update_cached_views(self, block_json, logger, caching_server):
155158
}
156159
self.try_send_request(logger, caching_server, request)
157160

161+
# Update the data requests solved cached view for all addresses involved in a reveal transaction
162+
# at the moment that the associated tally transaction is found.
163+
# This is a necessary addition because since wit/2, there are no tally outputs for honest solvers
164+
# anymore which results in their views not being updated.
165+
# Note that validators which do not reveal their committed value will not be included here, but
166+
# they will be part of the liar_addresses array in the associated tally transaction later on.
167+
for reveal in block_json["transactions"]["reveal"]:
168+
data_request_txn = reveal["data_request"]
169+
if data_request_txn not in self.data_request_reveal_addresses:
170+
self.data_request_reveal_addresses[data_request_txn] = []
171+
self.data_request_reveal_addresses[data_request_txn].append(
172+
reveal["address"]
173+
)
174+
158175
# Update the data requests solved cached view for all addresses in all tallies
159176
tally_addresses = set()
160177
for tally in block_json["transactions"]["tally"]:
161178
tally_addresses.update(tally["output_addresses"])
162179
tally_addresses.update(tally["error_addresses"])
163180
tally_addresses.update(tally["liar_addresses"])
181+
# Update the tally addresses set with honest validators since wit/2 tally transactions do not
182+
# contain an output for those validators anymore.
183+
if tally["data_request"] in self.data_request_reveal_addresses:
184+
tally_addresses.update(
185+
self.data_request_reveal_addresses[tally["data_request"]]
186+
)
187+
del self.data_request_reveal_addresses[tally["data_request"]]
164188
if len(tally_addresses) > 0:
165189
request = {
166190
"method": "update",

0 commit comments

Comments
 (0)