Skip to content

Commit

Permalink
Merge pull request #295 from w3f/fix/slashed
Browse files Browse the repository at this point in the history
Fix/slashed
  • Loading branch information
ironoa authored Sep 19, 2024
2 parents 7b4ed85 + 5bb6d47 commit 26e22d4
Show file tree
Hide file tree
Showing 4 changed files with 307 additions and 299 deletions.
4 changes: 2 additions & 2 deletions charts/polkadot-watcher/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: Polkadot Watcher
name: polkadot-watcher
version: v4.4.3
appVersion: v4.4.3
version: v4.4.4
appVersion: v4.4.4
apiVersion: v2
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkadot-watcher",
"version": "4.4.3",
"version": "4.4.4",
"description": "Monitor events on Polkadot networks",
"repository": "[email protected]:w3f/polkadot-watcher.git",
"author": "W3F Infrastructure Team <[email protected]>",
Expand All @@ -20,7 +20,7 @@
"start": "node ./dist/index.js start"
},
"dependencies": {
"@polkadot/api": "^11.2.1",
"@polkadot/api": "^13.1.1",
"@w3f/config": "^0.1.1",
"@w3f/logger": "^0.4.2",
"commander": "^4.0.0",
Expand Down
20 changes: 8 additions & 12 deletions src/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApiPromise } from '@polkadot/api';
import { Event } from '@polkadot/types/interfaces/system';
import { Header, SessionIndex, ValidatorId, Address } from '@polkadot/types/interfaces';
import { DeriveStakingQuery } from '@polkadot/api-derive/types';
import { Tuple, Vec } from '@polkadot/types/codec';
import { Vec } from '@polkadot/types/codec';
import { LoggerSingleton } from './logger';

import {
Expand Down Expand Up @@ -206,19 +206,15 @@ export class Subscriber {
}

private _slashedEventHandler(event: Event): void {
const validator = event.data[0].toString();

const items = event.data[0];
this.logger.debug(`${validator} has been reported for Slash`);
const account = this.validators.find((subject) => subject.address == validator);

(items as Tuple).forEach((item) => {
const validator = item[0];
this.logger.debug(`${validator} has been reported for Slash`);
const account = this.validators.find((subject) => subject.address == validator);

if (account) {
this.logger.info(`Really bad... Target ${account.name} has been reported for Slash`);
this.promClient.increaseSlashedReports(account.name, account.address);
}
});
if (account) {
this.logger.info(`Really bad... Target ${account.name} has been reported for Slash`);
this.promClient.increaseSlashedReports(account.name, account.address);
}
}

private async _newSessionEventHandler(): Promise<void> {
Expand Down
Loading

0 comments on commit 26e22d4

Please sign in to comment.