Change block explorer

This commit is contained in:
Vivek Teega 2019-04-19 09:50:36 +00:00
parent ebcfc002d8
commit d27090c9f4
5 changed files with 17 additions and 18 deletions

View File

@ -1,4 +1,4 @@
[DEFAULT]
NET = testnet
NET = mainnet
FLO_CLI_PATH = /usr/local/bin/flo-cli
START_BLOCK = 525360
START_BLOCK = 3387900

3
cronjob.sh Executable file
View File

@ -0,0 +1,3 @@
cd /home/production/deployed/flo-token-tracking/
python3 tracktokens-smartcontracts.py

View File

@ -232,11 +232,10 @@ def parse_flodata(string):
# todo Rule 31 - Extract number of tokens to be sent and the address to which to be sent, both data is mandatory
elif not incorporation and transfer:
amount = extractAmount(cleanstring, hashList[0][:-1])
address = extractAddress(nospacestring)
if None not in [amount, address]:
if None not in [amount]:
parsed_data = {'type': 'transfer', 'transferType': 'token', 'flodata': string,
'tokenIdentification': hashList[0][:-1],
'tokenAmount': amount, 'address': address[:-1]}
'tokenAmount': amount}
else:
parsed_data = {'type': 'noise'}

BIN
system.db

Binary file not shown.

23
tracktokens-smartcontracts.py Normal file → Executable file
View File

@ -241,12 +241,9 @@ def startWorking(transaction_data, parsed_data):
# todo Rule 45 - If the transfer type is token, then call the function transferToken to adjust the balances
if parsed_data['transferType'] == 'token':
if parsed_data['address'] == outputlist[0]:
returnval = transferToken(parsed_data['tokenIdentification'], parsed_data['tokenAmount'], inputlist[0], outputlist[0])
if returnval is None:
print("Something went wrong in the token transfer method")
else:
print('Address mentioned in flodata doesn\'t match the address in blockchain\'s outputlist')
returnval = transferToken(parsed_data['tokenIdentification'], parsed_data['tokenAmount'], inputlist[0], outputlist[0])
if returnval is None:
print("Something went wrong in the token transfer method")
# todo Rule 46 - If the transfer type is smart contract, then call the function transferToken to do sanity checks & lock the balance
elif parsed_data['transferType'] == 'smartContract':
@ -274,13 +271,13 @@ def startWorking(transaction_data, parsed_data):
engine = create_engine('sqlite:///tokens/{}.db'.format(parsed_data['tokenIdentification']), echo=True)
Base.metadata.create_all(bind=engine)
session = sessionmaker(bind=engine)()
session.add(ActiveTable(address=outputlist[0], parentid=0, transferBalance=parsed_data['tokenAmount']))
session.add(ActiveTable(address=inputlist[0], parentid=0, transferBalance=parsed_data['tokenAmount']))
string = "{} getblock {}".format(localapi, transaction_data['blockhash'])
response = subprocess.check_output(string, shell=True)
block_data = json.loads(response.decode("utf-8"))
session.add(TransferLogs(sourceFloAddress=inputadd, destFloAddress=outputlist[0], transferAmount=parsed_data['tokenAmount'], sourceId=0, destinationId=1, blockNumber=block_data['height'], time=block_data['time'], transactionHash=transaction_data['txid']))
blockchainReference = neturl + 'tx/' + transaction_data['txid']
session.add(TransactionHistory(sourceFloAddress=inputadd, destFloAddress=outputlist[0],
session.add(TransactionHistory(sourceFloAddress=inputadd, destFloAddress='-',
transferAmount=parsed_data['tokenAmount'], blockNumber=block_data['height'],
time=block_data['time'],
transactionHash=transaction_data['txid'],
@ -394,10 +391,10 @@ config.read('config.ini')
# Assignment the flo-cli command
if config['DEFAULT']['NET'] == 'mainnet':
neturl = 'https://florincoin.info/'
neturl = 'https://flosight.duckdns.org/'
localapi = config['DEFAULT']['FLO_CLI_PATH']
elif config['DEFAULT']['NET'] == 'testnet':
neturl = 'https://testnet.florincoin.info/'
neturl = 'https://testnet-flosight.duckdns.org/'
localapi = '{} --testnet'.format(config['DEFAULT']['FLO_CLI_PATH'])
else:
print("NET parameter is wrong\nThe script will exit now ")
@ -449,6 +446,9 @@ print("current_block_height : " + str(current_index))
for blockindex in range( startblock, current_index ):
print(blockindex)
if blockindex == 3387978:
print('hello')
# Scan every block
string = "{} getblockhash {}".format(localapi, str(blockindex))
response = subprocess.check_output(string, shell=True)
@ -467,9 +467,6 @@ for blockindex in range( startblock, current_index ):
transaction_data = json.loads(response.decode("utf-8"))
text = transaction_data["floData"]
if blockindex == 525362:
print('debug point')
# todo Rule 9 - Reject all noise transactions. Further rules are in parsing.py
parsed_data = parsing.parse_flodata(text)