Skip to content

Commit dd813fe

Browse files
committed
Locks count published inside staking summary
1 parent f92bcb5 commit dd813fe

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/distribution/distribution.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class DistributionService {
136136

137137
public async getCurrentScores(stamp: number): Promise<ScoreData[]> {
138138
const relaysData = await this.fetchRelays()
139-
const { locksData, stakingData} = await this.stakingRewardsService.getHodlerData()
139+
const { locksData, stakingData, locksCount } = await this.stakingRewardsService.getHodlerData()
140140
const operatorRegistryState = await this.operatorRegistryService.getOperatorRegistryState()
141141
const verificationData = operatorRegistryState.VerifiedFingerprintsToOperatorAddresses
142142
const isHardware = operatorRegistryState.VerifiedHardwareFingerprints
@@ -214,7 +214,8 @@ export class DistributionService {
214214
const summary = {
215215
Timestamp: stamp,
216216
Stakes: stakesSummary,
217-
Network: data
217+
Network: data,
218+
Locks: locksCount
218219
}
219220

220221
if (this.isLive !== 'true') {

src/staking-rewards/staking-rewards.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ export class StakingRewardsService {
8282

8383
public async getHodlerData(): Promise<{
8484
locksData: { [key: string]: string[] },
85-
stakingData: { [key: string]: { [key: string]: string }}
85+
stakingData: { [key: string]: { [key: string]: string }},
86+
locksCount: { [key: string]: { [key: string]: number }}
8687
}> {
8788
const locksData = {}
8889
const stakingData = {}
90+
const locksCount = {}
8991

9092
const keys = await this.hodlerContract.getHodlerKeys()
9193
for (const key of keys) {
@@ -100,6 +102,10 @@ export class StakingRewardsService {
100102
if (!locksData[lock.fingerprint].includes(operatorAddress)) {
101103
locksData[lock.fingerprint].push(operatorAddress)
102104
}
105+
if (!locksCount[operatorAddress]) {
106+
locksCount[operatorAddress] = {}
107+
}
108+
locksCount[operatorAddress][lock.fingerprint] = (locksCount[operatorAddress][lock.fingerprint] || 0) + 1
103109
})
104110

105111
const stakes: { operator: string, amount: string }[] = await this.hodlerContract.getStakes(hodlerAddress)
@@ -116,7 +122,7 @@ export class StakingRewardsService {
116122
}
117123
this.logger.log(`Fetched staking data for ${Object.keys(stakingData).length} operators`)
118124

119-
return { stakingData, locksData }
125+
return { stakingData, locksData, locksCount }
120126
}
121127

122128
public async getLastSnapshot(): Promise<RoundSnapshot | undefined> {

0 commit comments

Comments
 (0)