PHP WebShell
Текущая директория: /usr/lib/node_modules/bitgo/node_modules/@polkadot/api-derive/cjs/staking
Просмотр файла: erasSlashes.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.erasSlashes = exports._erasSlashes = exports.eraSlashes = void 0;
exports._eraSlashes = _eraSlashes;
const rxjs_1 = require("rxjs");
const index_js_1 = require("../util/index.js");
const cache_js_1 = require("./cache.js");
const util_js_1 = require("./util.js");
const CACHE_KEY = 'eraSlashes';
function mapSlashes(era, noms, vals) {
const nominators = {};
const validators = {};
noms.forEach(([key, optBalance]) => {
nominators[key.args[1].toString()] = optBalance.unwrap();
});
vals.forEach(([key, optRes]) => {
validators[key.args[1].toString()] = optRes.unwrapOrDefault()[1];
});
return { era, nominators, validators };
}
function _eraSlashes(instanceId, api) {
return (0, index_js_1.memo)(instanceId, (era, withActive) => {
const [cacheKey, cached] = (0, cache_js_1.getEraCache)(CACHE_KEY, era, withActive);
return cached
? (0, rxjs_1.of)(cached)
: (0, rxjs_1.combineLatest)([
api.query.staking.nominatorSlashInEra.entries(era),
api.query.staking.validatorSlashInEra.entries(era)
]).pipe((0, rxjs_1.map)(([n, v]) => (0, cache_js_1.setEraCache)(cacheKey, withActive, mapSlashes(era, n, v))));
});
}
exports.eraSlashes = (0, util_js_1.singleEra)('_eraSlashes');
exports._erasSlashes = (0, util_js_1.combineEras)('_eraSlashes');
exports.erasSlashes = (0, util_js_1.erasHistoricApply)('_erasSlashes');
Выполнить команду
Для локальной разработки. Не используйте в интернете!