Skip to content

Commit 71ee2be

Browse files
FranciscoThiesentloriato
authored andcommitted
Connect to dashboard (#4)
* 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
1 parent 870944f commit 71ee2be

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

Mce/DataStore.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,9 @@ def get_tx(rpc_tx_hash):
29972997
return None
29982998

29992999
decoded_tx = rpc("decoderawtransaction", rpc_tx_hex)
3000+
3001+
# print("Decoded Transaction = %s" % str(decoded_tx) )
3002+
30003003
sdec_transaction_handler(decoded_tx)
30013004

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

3029+
stream_creation = decoded_tx.get('create', None)
3030+
if stream_creation is not None:
3031+
bd_insert_stream(decoded_tx)
3032+
return
3033+
30263034
# We should now find out if this specific transaction involves offchain data
30273035
# If it does, then we should use the rpc and ask for it
30283036
# print( "DECODED TRANSACTION = %s " % str(decoded_tx) )
3029-
3037+
30303038
try:
30313039
transaction_item = decoded_tx['vout'][0]['items'][0]
30323040
except Exception as e:
@@ -3056,6 +3064,29 @@ def sdec_transaction_handler(decoded_tx):
30563064

30573065
def is_equal(x, y, epsilon=1*10**(-2) ):
30583066
return abs(x - y) <= epsilon
3067+
3068+
def bd_insert_stream(decoded_tx):
3069+
print("INSERINDO UMA NOVA STREAM!")
3070+
stream_creation = decoded_tx.get('create', None)
3071+
stream_name = stream_creation['name']
3072+
stream_creation_txid = decoded_tx.get('txid', None)
3073+
stream_id = decoded_tx['create'].get('streamref', None)
3074+
print(stream_creation, stream_name, stream_creation_txid, stream_id)
3075+
3076+
if stream_name != 'Registros':
3077+
store.sql("""
3078+
INSERT INTO stream ( stream_id, creation_txid, name, unidade_federacao)
3079+
VALUES(?, ?, ?, ?)
3080+
""", (stream_id, stream_creation_txid, stream_name, stream_name)
3081+
)
3082+
else:
3083+
store.sql("""
3084+
INSERT INTO stream (stream_id, creation_txid, name)
3085+
VALUES(?, ?, ?)
3086+
""", (stream_id, stream_creation_txid, stream_name)
3087+
)
3088+
3089+
store.commit()
30593090

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

0 commit comments

Comments
 (0)