コード例 #1
0
def stop_node(node_list, platon_dpos):
    auto = AutoDeployPlaton()
    del node_list[0]
    del node_list[9]
    del node_list[0]
    while True:
        time.sleep(random.randrange(100, 5000))
        verfier_info_list = platon_dpos.GetVerifiersList()
        num = len(verfier_info_list)
        if num <= 1:
            continue
        f = int((num - 1) / 3)
        if f < 2:
            continue
        stop_node_list = random.sample(node_list, random.randrange(1, f))
        q.put(1)
        log.info("关闭节点:{}".format(stop_node_list))
        number = platon_dpos.web3.eth.blockNumber
        sleep_time = get_sleep_time(number)
        auto.kill_of_list(stop_node_list)
        if sleep_time > 21:
            time.sleep(random.randrange(1, sleep_time - 20))
        log.info("恢复节点:{}".format(stop_node_list))
        auto.restart_list(stop_node_list)
        q.get()
コード例 #2
0
def restart_node(node_list, platon_dpos):
    auto = AutoDeployPlaton()
    del node_list[0]
    del node_list[9]
    del node_list[0]
    while True:
        time.sleep(random.randrange(100, 5000))
        verfier_info_list = platon_dpos.GetVerifiersList()
        num = len(verfier_info_list)
        if num <= 1:
            f = 1
        else:
            f = int((num - 1) / 3) + 1
        stop_node_list = random.sample(node_list, random.randrange(1, f + 1))
        q.put(1)
        log.info("重启节点:{}".format(stop_node_list))
        auto.restart_list(stop_node_list)
        q.get()