Skip to content

Commit a74431f

Browse files
committed
Multi-ledger issues WIP
Signed-off-by: Ian Costanzo <ian@anon-solutions.ca>
1 parent 75c057e commit a74431f

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

aries_cloudagent/admin/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ async def check_multitenant_authorization(request: web.Request, handler):
370370
and not is_server_path
371371
and not is_unprotected_path(path)
372372
and not base_limited_access_path
373+
and not (request.method == "OPTIONS") # CORS fix
373374
):
374375
raise web.HTTPUnauthorized()
375376

demo/multi_ledger_config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
- id: bcorvinTest
1+
- id: local
22
is_production: true
3-
genesis_url: 'http://test.bcovrin.vonx.io/genesis'
3+
is_write: true
4+
genesis_url: 'http://$LEDGER_HOST:9000/genesis'
5+
#- id: bcorvinTest
6+
# is_production: true
7+
# genesis_url: 'http://dev.bcovrin.vonx.io/genesis'
48
- id: greenlightTest
59
is_production: true
610
genesis_url: 'http://dev.greenlight.bcovrin.vonx.io/genesis'

demo/runners/agent_container.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,9 +1274,11 @@ async def create_agent_with_args(args, ident: str = None):
12741274
)
12751275

12761276
multi_ledger_config_path = None
1277+
genesis = None
12771278
if "multi_ledger" in args and args.multi_ledger:
12781279
multi_ledger_config_path = "./demo/multi_ledger_config.yml"
1279-
genesis = await default_genesis_txns()
1280+
else:
1281+
genesis = await default_genesis_txns()
12801282
if not genesis and not multi_ledger_config_path:
12811283
print("Error retrieving ledger genesis transactions")
12821284
sys.exit(1)

demo/runners/support/agent.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def __init__(
213213
self.agency_wallet_did = self.did
214214
self.agency_wallet_key = self.wallet_key
215215

216+
self.multi_write_ledger_url = None
216217
if self.genesis_txn_list:
217218
updated_config_list = []
218219
with open(self.genesis_txn_list, "r") as stream:
@@ -225,6 +226,8 @@ def __init__(
225226
"$LEDGER_HOST", str(self.external_host)
226227
)
227228
updated_config_list.append(config)
229+
if "is_write" in config and config["is_write"]:
230+
self.multi_write_ledger_url = config["genesis_url"].replace("/genesis", "")
228231
with open(self.genesis_txn_list, "w") as file:
229232
documents = yaml.dump(updated_config_list, file)
230233

@@ -479,7 +482,10 @@ async def register_did(
479482
# if registering a did for issuing indy credentials, publish the did on the ledger
480483
self.log(f"Registering {self.ident} ...")
481484
if not ledger_url:
482-
ledger_url = LEDGER_URL
485+
if self.multi_write_ledger_url:
486+
ledger_url = self.multi_write_ledger_url
487+
else:
488+
ledger_url = LEDGER_URL
483489
if not ledger_url:
484490
ledger_url = f"http://{self.external_host}:9000"
485491
data = {"alias": alias or self.ident}
@@ -501,6 +507,7 @@ async def register_did(
501507
await asyncio.sleep(3.0)
502508
nym_info = data
503509
else:
510+
log_msg("using ledger: " + ledger_url + "/register")
504511
resp = await self.client_session.post(
505512
ledger_url + "/register", json=data
506513
)

0 commit comments

Comments
 (0)