Exemplo n.º 1
0
from scanner.blockchain_common.wrapper_transaction import WrapperTransaction
from scanner.eventscanner.queue.pika_handler import send_to_backend
from binance_chain.exceptions import BinanceChainAPIException

from binance_chain.http import HttpApiClient
from binance_chain.http import PeerType
from binance_chain.constants import KlineInterval
from binance_chain.environment import BinanceEnvironment
from binance_chain.node_rpc.http import HttpRpcClient

#Setting Binance-Chain params, testnet_env for testnet
client = HttpApiClient(request_params={"verify": False, "timeout": 60})
#client = HttpApiClient()
#testnet_env = BinanceEnvironment.get_testnet_env()
#client = HttpApiClient(env=testnet_env, request_params={"verify": False, "timeout": 60})
peers = client.get_node_peers()
listen_addr = peers[0]['listen_addr']
rpc_client = HttpRpcClient(listen_addr)
processed = []
commited = []


class BinNetwork(WrapperNetwork):
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(BASE_DIR)
    base_dir = 'scanner/settings'

    def __init__(self, type):
        super().__init__(type)

    #No need to get last block number because we don't parse blocks in binance chain
from blockchain_common.wrapper_block import WrapperBlock
from blockchain_common.wrapper_network import WrapperNetwork
from blockchain_common.wrapper_output import WrapperOutput
from blockchain_common.wrapper_transaction import WrapperTransaction
from blockchain_common.wrapper_transaction_receipt import WrapperTransactionReceipt
from settings.settings_local import NETWORKS, ERC20_TOKENS

from binance_chain.http import HttpApiClient
from binance_chain.http import PeerType
from binance_chain.constants import KlineInterval
from binance_chain.environment import BinanceEnvironment
from binance_chain.node_rpc.http import HttpRpcClient

client = HttpApiClient(request_params={"verify": False, "timeout": 20})
httpapiclient = HttpApiClient()
peers = httpapiclient.get_node_peers()
listen_addr = peers[0]['listen_addr']
rpc_client = HttpRpcClient(listen_addr)
processed = []
commited = []


class BinNetwork(WrapperNetwork):
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(BASE_DIR)
    base_dir = 'settings'

    def __init__(self, type):
        super().__init__(type)
        url = NETWORKS[type]['url']
        is_testnet = NETWORKS[type].get('is_testnet')