forked from bitshares/python-bitshares
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstance.py
More file actions
55 lines (37 loc) · 1.47 KB
/
Copy pathinstance.py
File metadata and controls
55 lines (37 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
from graphenecommon.instance import AbstractBlockchainInstanceProvider
class SharedInstance:
""" This class merely offers a singelton for the Blockchain Instance
"""
instance = None
config = {}
class BlockchainInstance(AbstractBlockchainInstanceProvider):
""" This is a class that allows compatibility with previous
naming conventions
"""
_sharedInstance = SharedInstance
def __init__(self, *args, **kwargs):
# Also allow 'bitshares_instance'
if kwargs.get("bitshares_instance"):
kwargs["blockchain_instance"] = kwargs["bitshares_instance"]
AbstractBlockchainInstanceProvider.__init__(self, *args, **kwargs)
def get_instance_class(self):
""" Should return the Chain instance class, e.g. `bitshares.BitShares`
"""
import bitshares as bts
return bts.BitShares
@property
def bitshares(self):
""" Alias for the specific blockchain
"""
return self.blockchain
def shared_blockchain_instance():
return BlockchainInstance().shared_blockchain_instance()
def set_shared_blockchain_instance(instance):
instance.clear_cache()
# instance.set_shared_instance()
BlockchainInstance.set_shared_blockchain_instance(instance)
def set_shared_config(config):
BlockchainInstance.set_shared_config(config)
shared_bitshares_instance = shared_blockchain_instance
set_shared_bitshares_instance = set_shared_blockchain_instance