Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejka committed Oct 17, 2024
1 parent 8e8cc6e commit 487d6eb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/data/client2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@


# Function to calculate weight of a block
def calculate_batch_weight(block_data):
return sum(
len(tx["inputs"]) + len(tx["outputs"])
for block in block_data["blocks"]
for tx in block["data"]["transactions"]
)
def calculate_batch_weight(block_data, mode):
if mode == "light":
return len(block_data["blocks"])
else:
return sum(
len(tx["inputs"]) + len(tx["outputs"])
for block in block_data["blocks"]
for tx in block["data"]["transactions"]
)

# Generator function to create jobs
def job_generator(start, blocks, step, mode, strategy):
Expand All @@ -53,7 +56,7 @@ def job_generator(start, blocks, step, mode, strategy):

Path(batch_file).write_text(json.dumps(batch_data, indent=2))

batch_weight = calculate_batch_weight(batch_data)
batch_weight = calculate_batch_weight(batch_data, mode)
yield batch_file, batch_weight


Expand Down Expand Up @@ -114,6 +117,7 @@ def job_producer(job_gen):

# Notify consumers that a new job is available
weight_lock.notify_all()
weight_lock.notify_all()


# Consumer function: Processes blocks from the queue
Expand Down

0 comments on commit 487d6eb

Please sign in to comment.