Skip to content

Commit

Permalink
fix params
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandemeusy committed Jun 7, 2024
1 parent 17c9e3d commit 3259fe0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions ct-app/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions ct-app/database/utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
22 changes: 11 additions & 11 deletions ct-app/scripts/core_staging_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ flags:
getNFTHolders: 30
getPeersRewards: 30
applyEconomicModel: 30
distributeRewards: ~
distributeRewards: 1

node:
healthcheck: 10
Expand All @@ -40,7 +40,7 @@ economicModel:

coefficients:
a: 1
b: 1
b: 2
c: 3
l: 0

Expand All @@ -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

# =============================================================================
#
Expand Down

0 comments on commit 3259fe0

Please sign in to comment.