Merge branch 'local-node'
This commit is contained in:
commit
1d88005f70
@ -3,6 +3,7 @@ NET = mainnet
|
|||||||
DB_NAME = tree.db
|
DB_NAME = tree.db
|
||||||
ROOT_ADDRESS = FHQ5rPqqMZT4r3oqpecM54E7tieQoJwZTK
|
ROOT_ADDRESS = FHQ5rPqqMZT4r3oqpecM54E7tieQoJwZTK
|
||||||
INIT_TOKEN_NO = 21000000
|
INIT_TOKEN_NO = 21000000
|
||||||
|
FLO_CLI_PATH = /usr/local/bin/flo-cli
|
||||||
|
|
||||||
;if 'ranchimalltest#100' is on blockchain, set value to 'ranchimalltest'
|
;if 'ranchimalltest#100' is on blockchain, set value to 'ranchimalltest'
|
||||||
PREFIX = ranchimall
|
PREFIX = ranchimall
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import json
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import argparse
|
import argparse
|
||||||
import configparser
|
import configparser
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
# Read configuration
|
# Read configuration
|
||||||
@ -16,8 +17,10 @@ args = parser.parse_args()
|
|||||||
|
|
||||||
if config['DEFAULT']['NET'] == 'mainnet':
|
if config['DEFAULT']['NET'] == 'mainnet':
|
||||||
neturl = 'https://florincoin.info/'
|
neturl = 'https://florincoin.info/'
|
||||||
|
localapi = config['DEFAULT']['FLO_CLI_PATH']
|
||||||
elif config['DEFAULT']['NET'] == 'testnet':
|
elif config['DEFAULT']['NET'] == 'testnet':
|
||||||
neturl = 'https://testnet.florincoin.info/'
|
neturl = 'https://testnet.florincoin.info/'
|
||||||
|
localapi = '{} --testnet'.format(config['DEFAULT']['FLO_CLI_PATH'])
|
||||||
else:
|
else:
|
||||||
print('NET parameter is wrong')
|
print('NET parameter is wrong')
|
||||||
|
|
||||||
@ -32,18 +35,18 @@ def listcheck(lst):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def startTracking(blockindex, config, conn, c):
|
def startTracking(blockindex, config, conn, c):
|
||||||
string = "{}api/getblockhash?index={}".format(neturl, str(blockindex))
|
string = "{} getblockhash {}".format(localapi, str(blockindex))
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
blockhash = response.content.decode("utf-8")
|
blockhash = response.decode("utf-8")
|
||||||
|
|
||||||
string = "{}api/getblock?hash={}".format(neturl, str(blockhash))
|
string = "{} getblock {}".format(localapi, str(blockhash))
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
blockinfo = json.loads(response.content.decode("utf-8"))
|
blockinfo = json.loads(response.decode("utf-8"))
|
||||||
|
|
||||||
for transaction in blockinfo["tx"]:
|
for transaction in blockinfo["tx"]:
|
||||||
string = "{}api/getrawtransaction?txid={}&decrypt=1".format(neturl, str(transaction))
|
string = "{} getrawtransaction {} 1".format(localapi, str(transaction))
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
data = json.loads(response.content.decode("utf-8"))
|
data = json.loads(response.decode("utf-8"))
|
||||||
text = data["floData"]
|
text = data["floData"]
|
||||||
text = text[5:]
|
text = text[5:]
|
||||||
comment_list = text.split("#")
|
comment_list = text.split("#")
|
||||||
@ -76,9 +79,9 @@ def startTracking(blockindex, config, conn, c):
|
|||||||
inputadd = ''
|
inputadd = ''
|
||||||
|
|
||||||
for query in querylist:
|
for query in querylist:
|
||||||
string = "{}api/getrawtransaction?txid={}&decrypt=1".format(neturl, str(query[0]))
|
string = "{} getrawtransaction {} 1".format(localapi, str(query[0]))
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
content = json.loads(response.content.decode("utf-8"))
|
content = json.loads(response.decode("utf-8"))
|
||||||
|
|
||||||
for objec in content["vout"]:
|
for objec in content["vout"]:
|
||||||
if objec["n"] == query[1]:
|
if objec["n"] == query[1]:
|
||||||
@ -269,9 +272,9 @@ def main():
|
|||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
|
||||||
# get current block height
|
# get current block height
|
||||||
string = "{}api/getblockcount".format(neturl)
|
string = "{} getblockcount".format(localapi)
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
current_index = json.loads(response.content.decode("utf-8"))
|
current_index = json.loads(response.decode("utf-8"))
|
||||||
print("current_block_height : " + str(current_index))
|
print("current_block_height : " + str(current_index))
|
||||||
|
|
||||||
if args.reset == 1:
|
if args.reset == 1:
|
||||||
@ -290,14 +293,14 @@ def main():
|
|||||||
root_trans_hash = cur["addresses"]
|
root_trans_hash = cur["addresses"]
|
||||||
break
|
break
|
||||||
|
|
||||||
string = "{}api/getrawtransaction?txid={}&decrypt=1".format(neturl, str(root_trans_hash))
|
string = "{} getrawtransaction {} 1".format(localapi, str(root_trans_hash))
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
content = json.loads(response.content.decode("utf-8"))
|
content = json.loads(response.decode("utf-8"))
|
||||||
root_block_hash = content["blockhash"]
|
root_block_hash = content["blockhash"]
|
||||||
|
|
||||||
string = "{}api/getblock?hash={}".format(neturl, str(root_block_hash))
|
string = "{} getblock {}".format(localapi, str(root_block_hash))
|
||||||
response = requests.get(string)
|
response = subprocess.check_output(string, shell=True)
|
||||||
content = json.loads(response.content.decode("utf-8"))
|
content = json.loads(response.decode("utf-8"))
|
||||||
root_block_index = content["height"]
|
root_block_index = content["height"]
|
||||||
# root_block_index = 26066
|
# root_block_index = 26066
|
||||||
|
|
||||||
@ -324,7 +327,9 @@ def main():
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
response = requests.get("{}api/getblockcount".format(neturl))
|
response = requests.get("{}api/getblockcount".format(neturl))
|
||||||
current_index = json.loads(response.content.decode("utf-8"))
|
string = "{} getblockcount".format(localapi)
|
||||||
|
response = subprocess.check_output(string, shell=True)
|
||||||
|
current_index = json.loads(response.decode("utf-8"))
|
||||||
|
|
||||||
c.execute("SELECT lastblockscanned FROM extra WHERE id=1")
|
c.execute("SELECT lastblockscanned FROM extra WHERE id=1")
|
||||||
lastblockscanned = c.fetchall()[0][0]
|
lastblockscanned = c.fetchall()[0][0]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user