Skip to content

Commit

Permalink
Script to purge all unprocessed messages (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Jan 8, 2025
1 parent 9b23f3c commit 58cae35
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions scripts/purge_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import typer
from prediction_market_agent_tooling.gtypes import private_key_type

from prediction_market_agent.db.agent_communication import (
fetch_count_unprocessed_transactions,
pop_message,
)
from prediction_market_agent.utils import APIKeys


def main(private_key: str) -> None:
keys = APIKeys(BET_FROM_PRIVATE_KEY=private_key_type(private_key))
n_messages = fetch_count_unprocessed_transactions(
consumer_address=keys.bet_from_address
)

if (
input(
f"Are you sure you want to purge all {n_messages} messages for agent {keys.bet_from_address}? (y/n): "
)
!= "y"
):
return

popped = 0
while fetch_count_unprocessed_transactions(consumer_address=keys.bet_from_address):
pop_message(api_keys=keys)
popped += 1
print(f"Popped {popped} messages.")


if __name__ == "__main__":
typer.run(main)

0 comments on commit 58cae35

Please sign in to comment.