Skip to content

Commit

Permalink
democracy bot fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Jun 22, 2024
1 parent 38a6698 commit c5ca8ab
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 259 deletions.
7 changes: 4 additions & 3 deletions client/bot-community.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,12 @@ def vote_on_proposals(client: Client, cid: str, voters: list):
for voter in voters:
reputations = [[t[1], t[0]] for t in client.reputation(voter)]
if len(reputations) == 0:
print(f"no reputations for {voter}")
print(f"no reputations for {voter}. can't vote")
continue
vote = random.choices(choices, weights)[0]
print(f"voting {vote} on proposal {proposal.id} with {voter} and reputations {reputations}")
client.vote(voter, proposal.id, "aye", reputations)
client.vote(voter, proposal.id, vote, reputations)
client.await_block()


def update_proposal_states(client: Client, who: str):
Expand All @@ -359,7 +360,7 @@ def update_proposal_states(client: Client, who: str):
print(
f"checking proposal {proposal.id}, state: {proposal.state}, approval: {proposal.approval} turnout: {proposal.turnout}")
if proposal.state in ['Ongoing', 'Confirming']:
print(f"updateing proposal {proposal.id}")
print(f"updating proposal {proposal.id}")
client.update_proposal_state(who, proposal.id)


Expand Down
5 changes: 2 additions & 3 deletions client/faucet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
from time import sleep
from py_client.client import Client


app = flask.Flask(__name__)
app.config['DEBUG'] = True
CLIENT = Client()


def faucet(accounts):
for x in range(0, 180): # try 100 times
for x in range(0, 1): # try multiple
try:
CLIENT.faucet(accounts, is_faucet=True)
CLIENT.await_block() # wait for transaction to complete
Expand Down Expand Up @@ -50,5 +49,5 @@ def faucet_service():
else:
return "no accounts provided to drip to\n"

app.run()

app.run()
2 changes: 1 addition & 1 deletion client/py_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def faucet(self, accounts, faucet_url='http://localhost:5000/api', is_faucet=Fal
else:
payload = {'accounts': accounts}
try:
requests.get(faucet_url, params=payload, timeout=10)
requests.get(faucet_url, params=payload, timeout=20)
except requests.exceptions.Timeout:
print("faucet timeout")

Expand Down
Loading

0 comments on commit c5ca8ab

Please sign in to comment.