Changes in db name

This commit is contained in:
Vivek Teega 2019-04-13 09:25:39 +00:00
parent e88ec4f727
commit 0d93d0b5fe
16 changed files with 52 additions and 21 deletions

View File

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

View File

@ -35,6 +35,18 @@ class TransferLogs(Base):
destinationId = Column('destinationId', Integer)
blockNumber = Column('blockNumber', Integer)
time = Column('time', Integer)
transactionHash = Column('transactionHash', String)
class TransactionHistory(Base):
__tablename__ = "transactionHistory"
primary_key = Column('id', Integer, primary_key=True)
sourceFloAddress = Column('sourceFloAddress', String)
destFloAddress = Column('destFloAddress', String)
transferAmount = Column('transferAmount', Float)
blockNumber = Column('blockNumber', Integer)
time = Column('time', Integer)
transactionHash = Column('transactionHash', String)
blockchainReference = Column('blockchainReference', String)
class ContractStructure(ContractBase):

View File

@ -85,19 +85,20 @@ def extractInitTokens(text):
counter = 0
value = None
for idx,word in enumerate(textList):
for unit in base_units:
result = word.split(unit)
if len(result) == 1:
try:
result = float(word)
if textList[idx+1] in base_units:
value = result*base_units[textList[idx+1]]
counter = counter + 1
except:
continue
elif len(result) == 2 and result[1]=='':
value = float(result[0])*base_units[unit]
try:
result = float(word)
if textList[idx + 1] in base_units:
value = result * base_units[textList[idx + 1]]
counter = counter + 1
except:
for unit in base_units:
result = word.split(unit)
if len(result) == 2 and result[1]=='' and result[0]!='':
try:
value = float(result[0])*base_units[unit]
counter = counter + 1
except:
continue
if counter == 1:
return value

BIN
system.db

Binary file not shown.

View File

0
tokens/Main.db Normal file
View File

0
tokens/azenv.php.db Normal file
View File

0
tokens/dbk_put1.jsp.db Normal file
View File

0
tokens/favicon.ico.db Normal file
View File

0
tokens/gettokeninfo.db Normal file
View File

0
tokens/orders.xhtml.db Normal file
View File

Binary file not shown.

0
tokens/robots.txt.db Normal file
View File

BIN
tokens/teega.db Normal file

Binary file not shown.

0
tokens/users.db Normal file
View File

View File

@ -11,7 +11,7 @@ import os
import shutil
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy import create_engine, func, desc
from models import SystemData, ActiveTable, ConsumedTable, TransferLogs, Base, ContractStructure, ContractBase, ContractParticipants, SystemBase, ActiveContracts
from models import SystemData, ActiveTable, ConsumedTable, TransferLogs, TransactionHistory, Base, ContractStructure, ContractBase, ContractParticipants, SystemBase, ActiveContracts
committeeAddressList = ['oUc4dVvxwK7w5MHUHtev8UawN3eDjiZnNx']
@ -57,7 +57,7 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress)
session.add(TransferLogs(sourceFloAddress=inputAddress, destFloAddress=outputAddress,
transferAmount=entry[0].transferBalance, sourceId=piditem[0], destinationId=lastid+1,
blockNumber=block_data['height'], time=block_data['time'],
blockchainReference=transaction_data['txid']))
transactionHash=transaction_data['txid']))
entry[0].transferBalance = 0
if len(consumedpid_string)>1:
@ -100,7 +100,7 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress)
transferAmount=entry[0].transferBalance, sourceId=piditem[0],
destinationId=lastid + 1,
blockNumber=block_data['height'], time=block_data['time'],
blockchainReference=transaction_data['txid']))
transactionHash=transaction_data['txid']))
entry[0].transferBalance = 0
consumedpid_string = consumedpid_string + '{},'.format(piditem[0])
else:
@ -108,7 +108,7 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress)
transferAmount=piditem[1]-(checksum - commentTransferAmount), sourceId=piditem[0],
destinationId=lastid + 1,
blockNumber=block_data['height'], time=block_data['time'],
blockchainReference=transaction_data['txid']))
transactionHash=transaction_data['txid']))
entry[0].transferBalance = checksum - commentTransferAmount
@ -140,6 +140,15 @@ def transferToken(tokenIdentification, tokenAmount, inputAddress, outputAddress)
session.execute('DELETE FROM activeTable WHERE id={}'.format(piditem[0]))
session.commit()
session.commit()
string = "{} getblock {}".format(localapi, transaction_data['blockhash'])
response = subprocess.check_output(string, shell=True)
block_data = json.loads(response.decode("utf-8"))
blockchainReference = neturl + 'tx/' + transaction_data['txid']
session.add(TransactionHistory(sourceFloAddress=inputAddress, destFloAddress=outputAddress,
transferAmount=tokenAmount, blockNumber=block_data['height'], time=block_data['time'],
transactionHash=transaction_data['txid'], blockchainReference=blockchainReference))
session.commit()
session.close()
return 1
@ -232,9 +241,12 @@ 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':
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")
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')
# 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':
@ -266,7 +278,13 @@ def startWorking(transaction_data, parsed_data):
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][0], transferAmount=parsed_data['tokenAmount'], sourceId=0, destinationId=1, blockNumber=block_data['height'], time=block_data['time'], blockchainReference=transaction_data['txid']))
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],
transferAmount=parsed_data['tokenAmount'], blockNumber=block_data['height'],
time=block_data['time'],
transactionHash=transaction_data['txid'],
blockchainReference=blockchainReference))
session.commit()
session.close()
else: