Skip to content

Commit

Permalink
Fix killAnonymous business handling, #919
Browse files Browse the repository at this point in the history
  • Loading branch information
wliyongfeng committed Aug 22, 2024
1 parent 21052ed commit 0e21be9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion backend/packages/pallet-proxy-scan/src/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {
(async () => {
await initPalletProxyScanDb();
await subscribeFinalizedHeight();
const blockHeights = [7314534, 11790556];
const blockHeights = [7314534, 7345159, 11790556];

const api = await getApi();
for (const height of blockHeights) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,18 @@ async function handleKillPure(call, signer, extrinsicIndexer) {

const pure = createdEvent.event.data[0].toString();
const delay = createdEvent.event.data[3].toNumber();
const proxy = await getPureProxyOn(

const preBlockHeight = extrinsicIndexer.blockHeight - 1;
const preBlockHash = await getBlockHash(preBlockHeight);
const { proxies: preBlockProxies } = await queryAllProxiesOf(
pure,
spawner,
proxyTypeArg,
delay,
extrinsicIndexer.blockHeight - 1,
preBlockHash,
);
const proxy = preBlockProxies.find(
(p) =>
p.delegate === spawner &&
p.proxyType === proxyTypeArg &&
p.delay === delay,
);
if (!proxy) {
// check there is proxy on previous height block
Expand All @@ -80,16 +86,19 @@ async function handleKillPure(call, signer, extrinsicIndexer) {
return;
}

const proxyId = generateProxyId(pure, spawner, proxyTypeArg, delay);
await markProxyRemoved(proxyId, extrinsicIndexer);

const timelineCol = await getProxyTimelineCol();
await timelineCol.insertOne({
proxyId,
name: "Killed",
args: {},
indexer: extrinsicIndexer,
});
for (const p of preBlockProxies) {
const { delegate, proxyType, delay } = p;
const proxyId = generateProxyId(pure, delegate, proxyType, delay);
await markProxyRemoved(proxyId, extrinsicIndexer);

await timelineCol.insertOne({
proxyId,
name: "Killed",
args: {},
indexer: extrinsicIndexer,
});
}
}

module.exports = {
Expand Down

0 comments on commit 0e21be9

Please sign in to comment.