-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbalance_check.py
68 lines (55 loc) · 1.59 KB
/
balance_check.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
60
61
62
63
64
65
66
67
68
#!/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, math
# Parse config
from six.moves import configparser
config = configparser.ConfigParser()
config.read('bot.cfg')
wallet = config.get('main', 'wallet')
# MySQL requests
from common_mysql import mysql_select_accounts_list, mysql_select_accounts_list_extra
# Request to node
from common_rpc import *
# balances check
def balance_check():
time_start = int(time.time())
count = 0
diff_summ = 0
# list from MySQL
accounts_list = mysql_select_accounts_list()
accounts_list_extra = mysql_select_accounts_list_extra()
for account in accounts_list:
balance = int(account_balance(account[1]))
mysql_balance = int(account[3])
diff = abs(balance - mysql_balance)
diff_summ = diff_summ + diff
if (diff > 0):
count = count + 1
print(account[1])
print('{0} {1}'.format(mysql_balance, balance))
accounts_list = mysql_select_accounts_list()
for account in accounts_list_extra:
balance = int(account_balance(account[1]))
mysql_balance = int(account[3])
diff = abs(balance - mysql_balance)
diff_summ = diff_summ + diff
if (diff > 0):
count = count + 1
print(account[1])
print('{0} {1}'.format(mysql_balance, balance))
time_end = int(time.time())
total_time = time_end - time_start
print (total_time)
print ("{} inconsistent accounts\n{} inconsistent sum (xrb)".format(count, diff_summ))
balance_check()