Skip to content
Snippets Groups Projects

Points should maintain an external list of wallet to country mappings

Files

+ 5
27
@@ -28,8 +28,6 @@ state_key = "consensus_points_timestamp" # Static key used for states table
positive_points_func = 'submit_cmix_points'
negative_points_func = 'submit_cmix_deductions'
raw_points_log = ''
wallet_list_path = ''
wallet_list = None
#################
@@ -37,7 +35,7 @@ wallet_list = None
#################
def main():
global xxdot_url
global xxdot_url, raw_points_log
# Process input variables and program arguments
args = get_args()
@@ -49,6 +47,7 @@ def main():
db_name = args['db']
db_user = args['user']
db_pass = args['pass']
raw_points_log = args['raw_points_log']
# Read Mnemonic from file and create keypair
with open(wallet_path) as file:
@@ -129,8 +128,6 @@ def process_period(conn, substrate, keypair, point_info, start_period, end_perio
# Calculate points for the retrieved round information
wallet_points, raw_points = round_point_computation(point_info, round_info, active_nodes)
update_wallet_country_list(active_nodes, wallet_list_path)
# Define Lists
positive = []
negative = []
@@ -182,7 +179,7 @@ def round_point_computation(point_info, round_info, active_nodes):
node_multipliers[node_id] = bin_multipliers[node_bin] # Assign multiplier to node
node_wallets[node_id] = wallet_address # Add wallet association for node id
wallet_points[wallet_address] = 0
raw_points_dict[wallet_address] = 0
raw_points_dict[wallet_address] = [0, node_country]
# Calculate point information for each round
for row in round_info:
@@ -206,7 +203,7 @@ def round_point_computation(point_info, round_info, active_nodes):
wallet = node_wallets.get(bytes(node_id))
if wallet:
wallet_points[wallet] += fail_points
raw_points_dict[wallet] += fail_points
raw_points_dict[wallet][0] += fail_points
else:
# Handle point multipliers
# NOTE: Weirdness can result here from nodes going offline between eras. Should be reviewed.
@@ -226,7 +223,7 @@ def round_point_computation(point_info, round_info, active_nodes):
wallet = node_wallets.get(bytes(node_id))
if wallet:
wallet_points[wallet] += points
raw_points_dict[wallet] += success_points
raw_points_dict[wallet][0] += success_points
else:
log.warning(f"no wallet found for nid {bytes(node_id)}")
else:
@@ -416,7 +413,6 @@ def get_args():
get_args controls the argparse usage for the script. It sets up and parses
arguments and returns them in dict format
"""
global raw_points_log, wallet_list_path
parser = argparse.ArgumentParser(description="Options for point assignment script")
parser.add_argument("--verbose", action="store_true",
help="Print debug logs", default=False)
@@ -445,15 +441,12 @@ def get_args():
default="cmix")
parser.add_argument("--pass", type=str,
help="DB password")
parser.add_argument("--wallet-list-path", type=str, help="List of wallet-country")
args = vars(parser.parse_args())
log.basicConfig(format='[%(levelname)s] %(asctime)s: %(message)s',
level=log.DEBUG if args['verbose'] else log.INFO,
datefmt='%d-%b-%y %H:%M:%S',
filename=args["log"])
raw_points_log = args['raw_points_log']
wallet_list_path = args['wallet_list_path']
return args
@@ -480,21 +473,6 @@ def parse_bins(countries_list):
return ret
def update_wallet_country_list(active_nodes, list_path):
global wallet_list
with open(list_path, "a+") as f:
if not wallet_list:
wallet_list = {}
lines = f.readlines()
for line in lines:
parts = line.split(",")
wallet_list[parts[0]] = wallet_list[parts[1]]
for line in active_nodes:
if line[0] not in wallet_list:
wallet_list[line[0]] = line[2]
f.write(f"{line[0]},{line[2]}\n")
########################
# Connection Functions #
########################
Loading