Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added ability to refresh the pool manually #1623

Merged
2 changes: 1 addition & 1 deletion packages/indy-vdr/src/IndyVdrApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { multiSignRequest, signRequest } from './utils/sign'
@injectable()
export class IndyVdrApi {
private agentContext: AgentContext
private indyVdrPoolService: IndyVdrPoolService
public indyVdrPoolService: IndyVdrPoolService
wadeking98 marked this conversation as resolved.
Show resolved Hide resolved

public constructor(agentContext: AgentContext, indyVdrPoolService: IndyVdrPoolService) {
this.agentContext = agentContext
Expand Down
2 changes: 1 addition & 1 deletion packages/indy-vdr/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
IndyVdrDidCreateResult,
IndyVdrDidCreateOptions,
} from './dids'
export { IndyVdrPoolConfig } from './pool'
export { IndyVdrPoolConfig, IndyVdrPoolService } from './pool'
export * from './IndyVdrModule'
export * from './IndyVdrModuleConfig'
export * from './anoncreds'
16 changes: 16 additions & 0 deletions packages/indy-vdr/src/pool/IndyVdrPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ export class IndyVdrPool {
})
}

/**
* Refreshes the connection to the pool.
*/
public async refreshConnection(): Promise<void> {
if (this._pool) {
await this._pool.refresh()
}
}

/**
* Get the transactions for a pool
*/
public get transactions() {
return this.pool.transactions
}

private get pool(): indyVdrPool {
if (!this._pool) this.connect()
if (!this._pool) throw new IndyVdrError('Pool is not connected.')
Expand Down
14 changes: 14 additions & 0 deletions packages/indy-vdr/src/pool/IndyVdrPoolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,20 @@ export class IndyVdrPoolService {
}
}

/**
* Refresh the pool connections asynchronously
*/
public refreshPoolConnections() {
return Promise.allSettled(this.pools.map((pool) => pool.refreshConnection()))
}

/**
* Get all pool transactions
*/
public getAllPoolTransactions() {
return Promise.allSettled(this.pools.map((pool) => pool.transactions))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a promise right? So then allSettled is not needed I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pool.transactions returns a promise

}

/**
* Get the most appropriate pool for the given indyNamespace
*/
Expand Down
Loading