Skip to content

Commit

Permalink
fix: db update after the first redeeming period
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios committed Nov 21, 2023
1 parent a866ad6 commit bed1244
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/valory/skills/decision_maker_abci/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,17 @@ def utilized_tools(self) -> Dict[str, int]:
@property
def redeemed_condition_ids(self) -> Set[str]:
"""Get the condition ids of all the redeemed positions."""
ids = str(self.db.get("redeemed_condition_ids", "[]"))
ids = self.db.get("redeemed_condition_ids", None)
if ids is None:
return set()
return set(json.loads(ids))

@property
def payout_so_far(self) -> int:
"""Get the payout of all the redeemed positions so far."""
payout = self.db.get("payout_so_far", None)
if payout is None:
payout = 0
return 0
return int(payout)

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def end_block(self) -> Optional[Tuple[BaseSynchronizedData, Enum]]:
if synced_data.period_count == 0:
# necessary for persisted keys to function properly and not raise an exception when the first period ends
update = {
db_key: getattr(synced_data, db_key)
db_key: getattr(synced_data.db, db_key, None)
for db_key in RedeemRound.selection_key
}
synced_data.db.update(**update)
Expand Down

0 comments on commit bed1244

Please sign in to comment.