Skip to content

Commit

Permalink
Removed redundant function
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Kenyon <[email protected]>
  • Loading branch information
TheTreek committed Dec 9, 2021
1 parent ac8789a commit 40b9919
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions packages/core/src/modules/ledger/IndyPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class IndyPool {
}

public async connect() {
this.poolConnected = (async () => {
this.poolConnected = (async ()=>{
const poolName = this.poolConfig.id
const genesisPath = await this.getGenesisPath()

Expand Down Expand Up @@ -110,23 +110,11 @@ export class IndyPool {
return this.poolConnected
}

/**
* If the pool is already trying to connect it will wait for it,
* otherwise it will not wait
*/
private async pendingConnection() {
if (this.poolConnected != undefined) {
await this.poolConnected
}
}

private async submitRequest(request: Indy.LedgerRequest) {
await this.pendingConnection()
return this.indy.submitRequest(await this.getPoolHandle(), request)
}

public async submitReadRequest(request: Indy.LedgerRequest) {
await this.pendingConnection()
const response = await this.submitRequest(request)

if (isLedgerRejectResponse(response)) {
Expand All @@ -137,7 +125,7 @@ export class IndyPool {
}

public async submitWriteRequest(request: Indy.LedgerRequest) {
await this.pendingConnection()

const response = await this.submitRequest(request)

if (isLedgerRejectResponse(response)) {
Expand All @@ -148,6 +136,10 @@ export class IndyPool {
}

private async getPoolHandle() {
if (this.poolConnected != undefined) {
//If we have tried to already connect to pool wait for it
await this.poolConnected
}
if (!this._poolHandle) {
return this.connect()
}
Expand Down

0 comments on commit 40b9919

Please sign in to comment.