Skip to content

Commit

Permalink
implement max crn paid correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
moshemalawach committed Mar 21, 2024
1 parent 21ba9d2 commit 1436bd6
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/aleph_nodestatus/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def process_distribution(nodes, resource_nodes, since, current):
rnode = resource_nodes.get(rnode_id, None)
if rnode is None:
continue
if rnode["status"] != "linked":
if rnode["status"] != "linked": # how could this happen?
continue

rnode_reward_address = rnode["owner"]
Expand All @@ -191,18 +191,21 @@ def process_distribution(nodes, resource_nodes, since, current):

crn_multiplier = compute_score_multiplier(rnode["score"])

assert 0 <= crn_multiplier <= 1, "Invalid value of the score multiplier"

this_resource_node = (
compute_resource_node_rewards(rnode["decentralization"])
* block_count
* crn_multiplier
)

rewards[rnode_reward_address] = (
rewards.get(rnode_reward_address, 0) + this_resource_node
)

if crn_multiplier > 0:
paid_node_count += 1

if paid_node_count <= settings.node_max_paid: # we only pay the first N nodes
rewards[rnode_reward_address] = (
rewards.get(rnode_reward_address, 0) + this_resource_node
)

if paid_node_count > settings.node_max_paid:
paid_node_count = settings.node_max_paid
Expand All @@ -212,6 +215,9 @@ def process_distribution(nodes, resource_nodes, since, current):

linkage = 0.7 + (0.1 * paid_node_count)

if linkage > 1: # Cap the linkage at 1
linkage = 1

assert 0.7 <= linkage <= 1, "Invalid value of the linkage"

this_node_modifier = linkage * score_multiplier
Expand Down

0 comments on commit 1436bd6

Please sign in to comment.