Skip to content

Commit

Permalink
Properly initialize instance
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Dec 26, 2018
1 parent be38ba2 commit 0988b00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions graphenecommon/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class AbstractBlockchainInstanceProvider:
"""

def __init__(self, *args, **kwargs):
pass
self._blockchain = None
if kwargs.get("blockchain_instance"):
self._blockchain = kwargs["blockchain_instance"]

@classmethod
def inject(slf, cls):
Expand Down Expand Up @@ -47,7 +49,10 @@ def define_classes(self):

@property
def blockchain(self):
return self.shared_blockchain_instance()
if hasattr(self, "_blockchain") and self._blockchain:
return self._blockchain
else:
return self.shared_blockchain_instance()

@property
def chain(self):
Expand Down
2 changes: 2 additions & 0 deletions graphenecommon/transactionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(
assert self.operation_class
assert self.operations
assert self.account_class
AbstractBlockchainInstanceProvider.__init__(self, *args, **kwargs)

self.set_expiration(proposal_expiration or 2 * 24 * 60 * 60)
self.set_review(proposal_review)
Expand Down Expand Up @@ -141,6 +142,7 @@ def __init__(self, tx={}, proposer=None, **kwargs):
assert self.publickey_class
assert self.signed_transaction_class
assert self.amount_class
AbstractBlockchainInstanceProvider.__init__(self, **kwargs)

self.clear()
if tx and isinstance(tx, dict):
Expand Down

0 comments on commit 0988b00

Please sign in to comment.