Skip to content

Commit

Permalink
Smaller cache
Browse files Browse the repository at this point in the history
  • Loading branch information
RoMa committed Sep 25, 2023
1 parent 43ae3f5 commit 0aea00a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sockets/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ async def on_new_block(e):
'difficulty': block_info["verboseData"]["difficulty"],
'blueScore': block_info["header"]["blueScore"],
'timestamp': block_info["header"]["timestamp"],
'txCount': len(block_info["transactions"]),
'txs': [{
'txId': x["verboseData"]["transactionId"],
'outputs': [(output["verboseData"]["scriptPublicKeyAddress"], output["amount"]) for output in
x["outputs"]]
} for x in block_info["transactions"]]
x["outputs"][-20:]]
} for x in block_info["transactions"][-20:]]
}

BLOCKS_CACHE.append(emit_info)
if len(BLOCKS_CACHE) > 50:
if len(BLOCKS_CACHE) > 10:
BLOCKS_CACHE.pop(0)

await sio.emit("new-block", emit_info, room="blocks")
Expand Down

0 comments on commit 0aea00a

Please sign in to comment.