Skip to content

Commit 7f1142a

Browse files
committed
Publish staking/snapshot with staking info per operator and relay running classification
1 parent 9198d20 commit 7f1142a

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

src/distribution/distribution.service.ts

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,44 @@ export class DistributionService {
178178
}
179179
})
180180

181+
const stakesSummary = {}
182+
Object.keys(stakingData).forEach(operator => {
183+
var stakePerOperator = BigInt(0)
184+
Object.values(stakingData[operator]).forEach(stake => {
185+
stakePerOperator += BigInt(stake)
186+
})
187+
stakesSummary[operator] = stakePerOperator.toString()
188+
})
189+
190+
const summary = {
191+
Timestamp: stamp,
192+
Stakes: stakesSummary,
193+
Network: data
194+
}
195+
196+
197+
if (this.isLive !== 'true') {
198+
this.logger.warn(`NOT LIVE: Not storing staking/snapshot [${stamp}]`)
199+
} else {
200+
try {
201+
const tags = [
202+
{ name: 'Protocol', value: 'ANyONe' },
203+
{ name: 'Protocol-Version', value: '0.2' },
204+
{ name: 'Content-Timestamp', value: stamp.toString() },
205+
{ name: 'Content-Type', value: 'application/json' },
206+
{ name: 'Entity-Type', value: 'staking/snapshot' },
207+
]
208+
209+
const { id: summary_tx } = await this.bundlingService.upload(
210+
JSON.stringify(data), { tags }
211+
)
212+
213+
this.logger.log(`Permanently stored staking/snaphot [${stamp}]: ${summary_tx}`)
214+
} catch (error) {
215+
this.logger.error(`Exception in staking distribution service persisting snapshot: ${error.message}`, error.stack)
216+
}
217+
}
218+
181219
return scores
182220
}
183221

@@ -217,7 +255,7 @@ export class DistributionService {
217255
}
218256
try {
219257
if (this.isLive !== 'true') {
220-
this.logger.warn(`NOT LIVE: Not storing distribution/summary [${snapshot.Timestamp}]`)
258+
this.logger.warn(`NOT LIVE: Not storing staking/summary [${snapshot.Timestamp}]`)
221259

222260
return false
223261
}
@@ -245,11 +283,11 @@ export class DistributionService {
245283
{ tags }
246284
)
247285

248-
this.logger.log(`Permanently stored distribution/summary [${stamp}]: ${summary_tx}`)
286+
this.logger.log(`Permanently stored staking/summary [${stamp}]: ${summary_tx}`)
249287
this.tasksService.updateDistribution(stamp, true, true)
250288
return true
251289
} catch (error) {
252-
this.logger.error(`Exception in distribution service persisting round: ${error.message}`, error.stack)
290+
this.logger.error(`Exception in staking distribution service persisting round: ${error.message}`, error.stack)
253291
}
254292

255293
return false

0 commit comments

Comments
 (0)