Skip to content

Commit

Permalink
Merge pull request #145 from andrewwhitehead/optional-ledger
Browse files Browse the repository at this point in the history
Do not fail with an error when no ledger is configured
  • Loading branch information
swcurran authored Aug 15, 2019
2 parents 3081f10 + 732dc8c commit a8dcffe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions aries_cloudagent/config/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ async def ledger_config(
taa_info = await ledger.get_txn_author_agreement()
if taa_info["taa_required"] and public_did:
taa_accepted = await ledger.get_latest_txn_author_acceptance()
if not taa_accepted \
or taa_info["taa_record"]["digest"] != taa_accepted["digest"]:
if (
not taa_accepted
or taa_info["taa_record"]["digest"] != taa_accepted["digest"]
):
if not await accept_taa(ledger, taa_info, provision):
return False

Expand Down
24 changes: 14 additions & 10 deletions aries_cloudagent/ledger/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ async def provide(self, settings: BaseSettings, injector: BaseInjector):
pool_name = settings.get("ledger.pool_name", "default")
keepalive = int(settings.get("ledger.keepalive", 5))
wallet = await injector.inject(BaseWallet)
IndyLedger = ClassLoader.load_class(self.LEDGER_CLASSES["indy"])
cache = await injector.inject(BaseCache, required=False)
ledger = IndyLedger(pool_name, wallet, keepalive=keepalive, cache=cache)

genesis_transactions = settings.get("ledger.genesis_transactions")
if genesis_transactions:
await ledger.create_pool_config(genesis_transactions, True)
elif not await ledger.check_pool_config():
LOGGER.info("Ledger pool configuration has not been created")
ledger = None
ledger = None

if wallet.WALLET_TYPE == "indy":
IndyLedger = ClassLoader.load_class(self.LEDGER_CLASSES["indy"])
cache = await injector.inject(BaseCache, required=False)
ledger = IndyLedger(pool_name, wallet, keepalive=keepalive, cache=cache)

genesis_transactions = settings.get("ledger.genesis_transactions")
if genesis_transactions:
await ledger.create_pool_config(genesis_transactions, True)
elif not await ledger.check_pool_config():
LOGGER.info("Ledger pool configuration has not been created")
ledger = None

return ledger

0 comments on commit a8dcffe

Please sign in to comment.