import bitshares as bts


class SharedInstance():
    instance = None


def shared_bitshares_instance():
    """ This method will initialize ``SharedInstance.instance`` and return it.
        The purpose of this method is to have offer single default
        bitshares instance that can be reused by multiple classes.
    """
    if not SharedInstance.instance:
        clear_cache()
        SharedInstance.instance = bts.BitShares()
    return SharedInstance.instance


def set_shared_bitshares_instance(bitshares_instance):
    """ This method allows us to override default bitshares instance for all users of
        ``SharedInstance.instance``.

        :param bitshares.bitshares.BitShares bitshares_instance: BitShares instance
    """
    clear_cache()
    SharedInstance.instance = bitshares_instance


def clear_cache():
    """ Clear Caches
    """
    from .blockchainobject import BlockchainObject
    BlockchainObject.clear_cache()

@@ -63,16 +63,32 @@
  = None%0A
+    config = %7B%7D%0A
 %0A%0Adef sh
@@ -441,16 +441,39 @@
 tShares(
+**SharedInstance.config
 )%0A    re
@@ -634,16 +634,24 @@
  for all
+%0A       
  users o
@@ -651,24 +651,16 @@
 users of
-%0A       
  %60%60Share
@@ -752,24 +752,36 @@
 e: BitShares
+%0A           
  instance%0A  
@@ -977,20 +977,333 @@
 bject.clear_cache()%0A
+%0A%0Adef set_shared_config(config):%0A    %22%22%22 This allows to set a config that will be used when calling%0A        %60%60shared_bitshares_instance%60%60 and allows to define the configuration%0A        without requiring to actually create an instance%0A    %22%22%22%0A    assert isinstance(config, dict)%0A    SharedInstance.config = config%0A

set shared config