Skip to content
Snippets Groups Projects
Commit d660f392 authored by adorda's avatar adorda
Browse files

Corregido uso de bloque canónico

parent 74cfb49b
No related branches found
No related tags found
No related merge requests found
...@@ -50,11 +50,14 @@ class NoConnectionException(Exception): ...@@ -50,11 +50,14 @@ class NoConnectionException(Exception):
class Gateway: class Gateway:
is_poa = False
def __init__(self, provider_generator, is_geth_poa_network=False): def __init__(self, provider_generator, is_geth_poa_network=False):
self.w3 = Web3(provider_generator.generate_provider()) self.w3 = Web3(provider_generator.generate_provider())
if is_geth_poa_network: if is_geth_poa_network:
from web3.middleware import geth_poa_middleware from web3.middleware import geth_poa_middleware
self.w3.middleware_stack.inject(geth_poa_middleware, layer=0) self.w3.middleware_stack.inject(geth_poa_middleware, layer=0)
self.is_poa = True
if not self.w3.isConnected(): if not self.w3.isConnected():
raise InvalidTransactionException("No connection to node") raise InvalidTransactionException("No connection to node")
...@@ -153,7 +156,7 @@ class Gateway: ...@@ -153,7 +156,7 @@ class Gateway:
def get_tx_input(self, contract, tx): def get_tx_input(self, contract, tx):
return contract.decode_function_input(tx.input) return contract.decode_function_input(tx.input)
def transaction_is_canonical(self, transaction): def block_is_canonical_poa(self, transaction):
last_block_number = self.get_last_blocknumber() last_block_number = self.get_last_blocknumber()
tx_block_number = transaction.blockNumber tx_block_number = transaction.blockNumber
required_block_difference = math.ceil(self.get_signers_count() / 2) + 1 required_block_difference = math.ceil(self.get_signers_count() / 2) + 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment