From 3259fe001bdb18f27424b8c434119ba0b828d59f Mon Sep 17 00:00:00 2001 From: Jean Demeusy Date: Fri, 7 Jun 2024 17:08:07 +0200 Subject: [PATCH] fix params --- ct-app/core/core.py | 4 ++-- ct-app/database/utils.py | 6 ++++-- ct-app/scripts/core_staging_config.yaml | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ct-app/core/core.py b/ct-app/core/core.py index 7e7df505..a217407c 100644 --- a/ct-app/core/core.py +++ b/ct-app/core/core.py @@ -427,7 +427,7 @@ async def distribute_rewards(self): self.debug(rewards) self.debug(iterations) - with DatabaseConnection() as session: + with DatabaseConnection(self.params.db) as session: entries = set[Reward]() for peer, values in rewards.items(): @@ -499,7 +499,7 @@ def _total_messages_to_send(rewards: dict[str, dict[str, int]]) -> int: "expected": peer.message_count_for_reward, "remaining": peer.message_count_for_reward, "issued": 0, - "tag": DBUtils.peerIDToInt(peer.address.id), + "tag": DBUtils.peerIDToInt(peer.address.id, self.params.db), "ticket-price": peer.economic_model.budget.ticket_price, } # will be retrieved from the API once the endpoint is available in 2.1 for peer in peers diff --git a/ct-app/database/utils.py b/ct-app/database/utils.py index dfdf680d..bc7122e5 100644 --- a/ct-app/database/utils.py +++ b/ct-app/database/utils.py @@ -1,11 +1,13 @@ +from core.components.parameters import Parameters + from .database_connection import DatabaseConnection from .models import Peer class Utils: @classmethod - def peerIDToInt(cls, peer_id: str) -> int: - with DatabaseConnection() as session: + def peerIDToInt(cls, peer_id: str, db_params: Parameters) -> int: + with DatabaseConnection(db_params) as session: existing_peer = session.query(Peer).filter_by(peer_id=peer_id).first() if existing_peer: diff --git a/ct-app/scripts/core_staging_config.yaml b/ct-app/scripts/core_staging_config.yaml index f2dacbb8..0b20685a 100644 --- a/ct-app/scripts/core_staging_config.yaml +++ b/ct-app/scripts/core_staging_config.yaml @@ -15,7 +15,7 @@ flags: getNFTHolders: 30 getPeersRewards: 30 applyEconomicModel: 30 - distributeRewards: ~ + distributeRewards: 1 node: healthcheck: 10 @@ -40,7 +40,7 @@ economicModel: coefficients: a: 1 - b: 1 + b: 2 c: 3 l: 0 @@ -53,21 +53,21 @@ economicModel: condition: "x > c" budget: - amount: 400 - period: 1200 - s: 0.25 - countsInPeriod: 1 - ticketPrice: 0.5 # deprecated + # one distribution every 60s + amount: 0.000000001 + period: 86400 + s: 1 + countsInPeriod: 1440 winningProbability: 1 # ============================================================================= # # ============================================================================= distribution: - minEligiblePeers: 500 - messageDeliveryDelay: 10.0 - delayBetweenTwoMessages: 0.2 - maxIterations: 6 + minEligiblePeers: 5 + messageDeliveryDelay: 4.0 + delayBetweenTwoMessages: 0.05 + maxIterations: 2 # ============================================================================= #