Skip to content

blockchain_instance getting lost when initializing Order from id #234

@bitphage

Description

@bitphage

In Order: order = self.blockchain.rpc.get_objects([args[0]])[0]

self.blockchain here is a property of AbstractBlockchainInstanceProvider, and self._blockchain attr is not set, thus a new bitshares instance (shared) is being initializing effectively connecting to the default node:

> /home/vvk/devel/bitshares/python-bitshares/bitshares/price.py(109)__init__()
-> order = self.blockchain.rpc.get_objects([args[0]])[0]
(Pdb) step
--Call--
> /home/vvk/devel/bitshares/python-graphenelib/graphenecommon/instance.py(54)blockchain()
-> @property
(Pdb) next
> /home/vvk/devel/bitshares/python-graphenelib/graphenecommon/instance.py(56)blockchain()
-> if hasattr(self, "_blockchain") and self._blockchain:
(Pdb) step
> /home/vvk/devel/bitshares/python-graphenelib/graphenecommon/instance.py(60)blockchain()
-> return self.shared_blockchain_instance()

I did a quick workaround locally like this, not sure this is right fix:

--- a/bitshares/price.py
+++ b/bitshares/price.py
@@ -106,6 +106,7 @@ class Order(Price):
         if len(args) == 1 and isinstance(args[0], str):
             """ Load from id
             """
+            self._blockchain = kwargs.get('blockchain_instance')
             order = self.blockchain.rpc.get_objects([args[0]])[0]
             if order:
                 Price.__init__(self, order["sell_price"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions