Beispiel #1
0
    def __init__(self, w3: Web3) -> None:
        self.w3 = w3

        self.table_key = f"chain{CONFIG.active_network['chainid']}"
        self.cur = Cursor(_get_data_folder().joinpath("cache.db"))
        self.cur.execute(f"CREATE TABLE IF NOT EXISTS {self.table_key} (method, params, result)")

        latest = w3.eth.getBlock("latest")
        self.last_block = latest.hash
        self.last_block_seen = latest.timestamp
        self.last_request = 0.0
        self.block_cache: OrderedDict = OrderedDict()
        self.block_filter = w3.eth.filter("latest")

        self.lock = threading.Lock()
        self.event = threading.Event()
        self.is_killed = False
        threading.Thread(target=self.block_filter_loop, daemon=True).start()
Beispiel #2
0
from hashlib import sha1
from sqlite3 import OperationalError
from typing import Any, Dict, Iterator, List, Optional, Tuple

from brownie._config import CONFIG, _get_data_folder
from brownie._singleton import _Singleton
from brownie.exceptions import BrownieEnvironmentError
from brownie.project.build import DEPLOYMENT_KEYS
from brownie.utils.sql import Cursor

from .rpc import _revert_register
from .web3 import _resolve_address

_contract_map: Dict = {}

cur = Cursor(_get_data_folder().joinpath(f"deployments.db"))
cur.execute("CREATE TABLE IF NOT EXISTS sources (hash PRIMARY KEY, source)")


class TxHistory(metaclass=_Singleton):

    """List-like singleton container that contains TransactionReceipt objects.
    Whenever a transaction is broadcast, the TransactionReceipt is automatically
    added to this container."""

    def __init__(self) -> None:
        self._list: List = []
        self.gas_profile: Dict = {}
        _revert_register(self)

    def __repr__(self) -> str: