Skip to content

Commit

Permalink
Script to purge all unprocessed messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii committed Jan 7, 2025
1 parent f9b4a85 commit 10c4cb8
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/purge_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import typer
from prediction_market_agent_tooling.gtypes import PrivateKey
from pydantic import SecretStr

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: SecretStr) -> None:
keys = APIKeys(BET_FROM_PRIVATE_KEY=PrivateKey(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 10c4cb8

Please sign in to comment.