-
Notifications
You must be signed in to change notification settings - Fork 27
/
representative.py
59 lines (44 loc) · 1.52 KB
/
representative.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Nano Telegram bot
# @NanoWalletBot https://t.me/NanoWalletBot
#
# Source code:
# https://github.com/SergiySW/NanoWalletBot
#
# Released under the BSD 3-Clause License
#
import logging
import urllib3, socket, json
import time
# Parse config
from six.moves import configparser
config = configparser.ConfigParser()
log_file = config.get('main', 'log_file')
wallet = config.get('main', 'wallet')
representative = config.get('main', 'representative')
# Enable logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO, filename=log_file)
logger = logging.getLogger(__name__)
# MySQL requests
from common_mysql import mysql_update_balance, mysql_update_frontier, mysql_select_accounts_list, mysql_set_price
# Request to node
from common_rpc import *
# Representative set
def change_representative():
# list from node
account_list = rpc({"action":"account_list","wallet":wallet}, 'accounts')
for account in account_list:
# current representative
account_representative = rpc({"action":"account_representative","account":account}, 'representative')
if ((len(account_representative)>63) and (account_representative not in representative)):
print(account)
block = rpc({"action":"account_representative_set","wallet":wallet,"account":account,"representative":representative}, 'block')
mysql_update_frontier(account, block)
print(block)
time.sleep(5)
time.sleep(0.1)
#frontier = r.values()[0]
change_representative()