Beispiel #1
0
 def __init__(self, tx={}, graphene_instance=None):
     self.graphene = graphene_instance or shared_graphene_instance()
     self.clear()
     # print("tx>>", tx)
     if not isinstance(tx, dict):
         raise ValueError("Invalid TransactionBuilder Format")
     super(TransactionBuilder, self).__init__(tx)
Beispiel #2
0
    def __init__(self, graphene_instance=None):
        self.graphene = graphene_instance or shared_graphene_instance()
        self.schedule = self.graphene.rpc.get_object("2.12.0").get(
            "current_shuffled_witnesses", [])

        super(Witnesses, self).__init__([
            Witness(x, lazy=True, graphene_instance=self.graphene)
            for x in self.schedule
        ])
Beispiel #3
0
    def __init__(
        self,
        accounts=[],
        markets=[],
        objects=[],
        on_tx=None,
        on_object=None,
        on_block=None,
        on_account=None,
        on_market=None,
        graphene_instance=None,
    ):
        # Events
        super(Notify, self).__init__()
        self.events = Events()

        # graphene instance
        self.graphene = graphene_instance or shared_graphene_instance()

        # Markets
        market_ids = []
        for market_name in markets:
            market = Market(market_name, graphene_instance=self.graphene)
            market_ids.append([
                market["base"]["id"],
                market["quote"]["id"],
            ])

        # Callbacks
        if on_tx:
            self.on_tx += on_tx
        if on_object:
            self.on_object += on_object
        if on_block:
            self.on_block += on_block
        if on_account:
            self.on_account += on_account
        if on_market:
            self.on_market += on_market

        # Open the websocket
        self.websocket = GrapheneWebsocket(
            urls=self.graphene.rpc.urls,
            user=self.graphene.rpc.user,
            password=self.graphene.rpc.password,
            accounts=accounts,
            markets=market_ids,
            objects=objects,
            on_tx=on_tx,
            on_object=on_object,
            on_block=on_block,
            on_account=self.process_account,
            on_market=self.process_market,
        )
Beispiel #4
0
    def __init__(self, account_name, graphene_instance=None):
        self.graphene = graphene_instance or shared_graphene_instance()
        account = Account(account_name)
        self.workers = self.graphene.rpc.get_workers_by_account(account["id"])

        super(Workers, self).__init__(
            [
                Worker(x, lazy=True, graphene_instance=self.graphene)
                for x in self.workers
            ]
        )
Beispiel #5
0
    def __init__(
        self,
        graphene_instance=None,
        mode="irreversible"
    ):
        self.graphene = graphene_instance or shared_graphene_instance()

        if mode == "irreversible":
            self.mode = 'last_irreversible_block_num'
        elif mode == "head":
            self.mode = "head_block_number"
        else:
            raise ValueError("invalid value for 'mode'!")
Beispiel #6
0
    def __init__(
        self,
        block,
        graphene_instance=None,
        lazy=False
    ):
        self.graphene = graphene_instance or shared_graphene_instance()
        self.cached = False
        self.block = block

        if isinstance(block, Block):
            super(Block, self).__init__(block)
            self.cached = True
        elif not lazy:
            self.refresh()
Beispiel #7
0
    def __init__(
        self,
        worker,
        lazy=False,
        graphene_instance=None,
    ):
        self.graphene = graphene_instance or shared_graphene_instance()
        self.cached = False

        if isinstance(worker, (Worker, dict)):
            self.identifier = worker["id"]
            super(Worker, self).__init__(worker)
            self.cached = True
        else:
            self.identifier = worker
            if not lazy:
                self.refresh()
Beispiel #8
0
    def __init__(
        self,
        witness,
        lazy=False,
        graphene_instance=None,
    ):
        self.graphene = graphene_instance or shared_graphene_instance()
        self.cached = False

        if isinstance(witness, Witness):
            self.witness = witness["name"]
            super(Witness, self).__init__(witness)
            self.cached = True
            self._cache(witness)
        else:
            self.witness = witness
            if witness in Witness.witness_cache:
                super(Witness, self).__init__(Witness.witness_cache[witness])
                self.cached = True
            elif not lazy and not self.cached:
                self.refresh()