Make db admin reward persistent

This commit is contained in:
Marek Wolan
2024-03-01 16:02:27 +00:00
parent 10a4053887
commit ed01293b86
4 changed files with 11 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
from ipaddress import IPv4Address
from typing import Any, Dict, List, Optional
from typing import Any, Dict, Optional
from uuid import uuid4
from primaite import getLogger
@@ -26,7 +26,7 @@ class DatabaseClient(Application):
server_password: Optional[str] = None
connected: bool = False
_query_success_tracker: Dict[str, bool] = {}
_connections_status: List[bool] = []
_last_connection_successful: Optional[bool] = None
"""Keep track of connections that were established or verified during this step. Used for rewards."""
def __init__(self, **kwargs):
@@ -46,7 +46,7 @@ class DatabaseClient(Application):
can_connect = self.connect(connection_id=list(self.connections.keys())[-1])
else:
can_connect = self.connect()
self._connections_status.append(can_connect)
self._last_connection_successful = can_connect
return can_connect
def describe_state(self) -> Dict:
@@ -57,8 +57,7 @@ class DatabaseClient(Application):
"""
state = super().describe_state()
# list of connections that were established or verified during this step.
state["connections_status"] = [c for c in self._connections_status]
self._connections_status.clear()
state["last_connection_successful"] = self._last_connection_successful
return state
def configure(self, server_ip_address: IPv4Address, server_password: Optional[str] = None):

View File

@@ -199,7 +199,7 @@ class WebBrowser(Application):
def state(self) -> Dict:
"""Return the contents of this dataclass as a dict for use with describe_state method."""
if self.status == self._HistoryItemStatus.LOADED:
outcome = self.response_code
outcome = self.response_code.value
else:
outcome = self.status.value
return {"url": self.url, "outcome": outcome}