Skip to content

Commit

Permalink
Merge pull request #47 from w3f/filter
Browse files Browse the repository at this point in the history
added filtering section
  • Loading branch information
ironoa authored May 4, 2023
2 parents ae016b4 + 8f81e24 commit 951a10b
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 549 deletions.
4 changes: 2 additions & 2 deletions charts/polkadot-k8s-payouts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: Polkadot K8s Payouts
name: polkadot-k8s-payouts
version: v1.2.2
appVersion: v1.2.2
version: v1.2.3
appVersion: v1.2.3
apiVersion: v2
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-payouts",
"version": "1.2.2",
"version": "1.2.3",
"description": "Automated transfers among accounts",
"repository": "git@github.com:w3f/accountant.git",
"author": "W3F Infrastructure Team <devops@web3.foundation>",
Expand Down
16 changes: 15 additions & 1 deletion src/claimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ export class Claimer {
async run(): Promise<void> {
await this.initInstanceVariables()

//filter targets
this.logger.info("filtering targets...")
await this.filterTargets()

//gather info
console.time('build validators map');
this.logger.info("gathering chain data...")
this.logger.info(`gathering chain data for ${this.targets.size} targets...`)
const validatorsMap = await this.gatherValidatorsMap(Array.from(this.targets))
console.timeEnd('build validators map');

Expand Down Expand Up @@ -60,6 +64,16 @@ export class Claimer {
this.lastRewardMax = Number(this.api.consts.staking.historyDepth?.toString())
if(!this.lastRewardMax) this.lastRewardMax = 84 //Polkadot runtime is not ready for this call
}

private async filterTargets(): Promise<void> {
const bonded = await this.api.query.staking.bonded.multi(Array.from(this.targets).map(target=>target.validatorAddress))
Array.from(this.targets).forEach((target,index) => {
if(!bonded[index].isSome){
this.logger.warn(`${target.alias} (${target.validatorAddress}) cannot be processed, it's not bonded`)
this.targets.delete(target)
}
})
}

private async gatherValidatorsMap(accounts: Target[]): Promise<ValidatorsMap> {

Expand Down
Loading

0 comments on commit 951a10b

Please sign in to comment.