-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9525f23
commit 2cff43e
Showing
4 changed files
with
50 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/input-scan/src/business/event/centrifuge/blockRewards/nextEvent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function findRewardFromNextEvent(blockEvents, sort) { | ||
const nextEvent = blockEvents[sort + 1]; | ||
const { event: { section, method } } = nextEvent; | ||
if (section !== "blockRewards" || method !== "NewSession") { | ||
return; | ||
} | ||
|
||
const eachCollatorReward = nextEvent.event.data[0].toString(); | ||
const totalReward = nextEvent.event.data[1].toString(); | ||
return { | ||
eachCollatorReward, | ||
totalReward, | ||
} | ||
} | ||
|
||
module.exports = { | ||
findRewardFromNextEvent, | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/input-scan/src/business/event/centrifuge/blockRewards/noExtrinsicEvent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function findRewardFromNoExtrinsicEvents(blockEvents, sort) { | ||
const noExtrinsicEvents = blockEvents.filter((e, index) => e.phase.isNone && index > sort); | ||
const targetEvent = noExtrinsicEvents.find(({ event }) => { | ||
const { section, method } = event; | ||
return section === "blockRewards" && method === "NewSession"; | ||
}); | ||
if (!targetEvent) { | ||
return; | ||
} | ||
|
||
const eachCollatorReward = targetEvent.event.data[0].toString(); | ||
const totalReward = targetEvent.event.data[1].toString(); | ||
return { | ||
eachCollatorReward, | ||
totalReward, | ||
} | ||
} | ||
|
||
module.exports = { | ||
findRewardFromNoExtrinsicEvents, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters