Skip to content

Commit

Permalink
Connect to dashboard (#4)
Browse files Browse the repository at this point in the history
* Stopping DataStore.py from creating the database

* Changing return type for a initialization function of DataStore.py

* Reverting changes

* Reverting DataStore.py version

* Implementation of bd_insert_company on DataStore.py

* Calling function for registering new companies

* Fixing simple typo

* Fixing the number of values inserted on company table

* Adding debug statement

* Swapping order of debugging statements

* Fixing company json parsing

* Small fix on json parsing

* Signaling SDEC code with comments

* Fail proof when getting values from the enterprise

* Print nota_fiscal complete structure so as to allow structure analysis

* Adding another print for debugging purposes

* Adding more print statements

* Debugging

* Debugging

* Fixing typo

* Clean up the code

* Adding function for nota_fisccal insertion on our database

* Troubleshooting

* Fixing nota_fiscal data parsing

* Casting parameters on data_store bd_insert_receipt function

* Fixing nota_fiscal insertion command

* Adding more casts to nota_fiscal data

* Fixing typo

* Print Note

* fixing exigibilidadeISS naming

* Fixing demon?

* FIxing demons??

* TxID as Primary Key

* Passing item_txid ahead

* Adding receipt_validator function

* Adding weak_receipt_validator

* Fixing type

* Fixing variable name

* Fixing another typo

* Adding endereco_blockchain for companies

* Troubleshooting

* Small fix

* Adding cast for endereco_blockchain

* Fixing validator of receipts

* Comparing floats with tolerance

* Fixing small typo

* Small fix + adding debug statements

* print txid

* Fixing a few things

* fix typo

* removing break line

* missing colon

* Missing Emissor

* Fixing emissor reference

* Removing printf's to merge

* Adding print statement for analysis of transaction format

* Insering the logic related to filling streams database table

* Fixing indentation

* Fixing Indentation 2

* Fixing SQL insertion command

* Fixing typo

* Replacing a field name on stream insertion

* Update Mce/DataStore.py
  • Loading branch information
FranciscoThiesen authored and tloriato committed Apr 24, 2019
1 parent 870944f commit 71ee2be
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Mce/DataStore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2997,6 +2997,9 @@ def get_tx(rpc_tx_hash):
return None

decoded_tx = rpc("decoderawtransaction", rpc_tx_hex)

# print("Decoded Transaction = %s" % str(decoded_tx) )

sdec_transaction_handler(decoded_tx)

rpc_tx = rpc_tx_hex.decode('hex')
Expand All @@ -3023,10 +3026,15 @@ def sdec_transaction_handler(decoded_tx):
# rpc_tx_hex = rpc("getrawtransaction", rpc_tx_hash)
# decoded_tx = rpc("decoderawtransaction", rpc_tx_hex)

stream_creation = decoded_tx.get('create', None)
if stream_creation is not None:
bd_insert_stream(decoded_tx)
return

# We should now find out if this specific transaction involves offchain data
# If it does, then we should use the rpc and ask for it
# print( "DECODED TRANSACTION = %s " % str(decoded_tx) )

try:
transaction_item = decoded_tx['vout'][0]['items'][0]
except Exception as e:
Expand Down Expand Up @@ -3056,6 +3064,29 @@ def sdec_transaction_handler(decoded_tx):

def is_equal(x, y, epsilon=1*10**(-2) ):
return abs(x - y) <= epsilon

def bd_insert_stream(decoded_tx):
print("INSERINDO UMA NOVA STREAM!")
stream_creation = decoded_tx.get('create', None)
stream_name = stream_creation['name']
stream_creation_txid = decoded_tx.get('txid', None)
stream_id = decoded_tx['create'].get('streamref', None)
print(stream_creation, stream_name, stream_creation_txid, stream_id)

if stream_name != 'Registros':
store.sql("""
INSERT INTO stream ( stream_id, creation_txid, name, unidade_federacao)
VALUES(?, ?, ?, ?)
""", (stream_id, stream_creation_txid, stream_name, stream_name)
)
else:
store.sql("""
INSERT INTO stream (stream_id, creation_txid, name)
VALUES(?, ?, ?)
""", (stream_id, stream_creation_txid, stream_name)
)

store.commit()

def bd_insert_receipt(receipt_offchain_data, company_address, item_txid):
print("INSERCAO DE NOTA FOI CHAMADA!!!!!")
Expand Down

0 comments on commit 71ee2be

Please sign in to comment.