-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(apps/whale-api): add updatemasternode indexer #1869
Conversation
Bump testcontainers to `grandcentral` with `master-1d169a75`. Fixes all broken tests and known regression from this change. Co-authored-by: Dilshan Madushanka <[email protected]>
….ts` to match other tests (#1865) <!-- Thanks for sending a pull request! --> #### What this PR does / why we need it: Uses to the assertion order used by all other tests. Uses a regex pattern to match instead of `toContain`. #### Additional comments?: As requested in #1841 (comment)
…#1854) <!-- Thanks for sending a pull request! --> #### What this PR does / why we need it: Add tests for new fixes on defid v3.
} | ||
} | ||
|
||
async indexStats (block: RawBlock, data: Masternode): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it won't make sense to indexStats
for an update? Since statistically there isn't any changes for updates?
- count, no changes, updating doesn't change the amount of masternode?
- tvl, what's locked is still locked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed. 3538564
await this.masternodeMapper.put({ | ||
id: data.nodeId, | ||
sort: `${HexEncoder.encodeHeight(block.height)}${txn.txid}`, | ||
ownerAddress: (ownerAddress !== null) ? ownerAddress : mn.ownerAddress, | ||
operatorAddress: (operatorAddress !== null) ? operatorAddress : mn.operatorAddress, | ||
creationHeight: block.height, | ||
resignHeight: -1, | ||
mintedBlocks: 0, | ||
timelock: 0, | ||
block: { hash: block.hash, height: block.height, medianTime: block.mediantime, time: block.time }, | ||
collateral: txn.vout[1].value.toFixed(8), | ||
updateRecords | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be replacing all the entries since it's an update, not a new creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating an existing record would look something like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. 0b13304
async invalidateBlockStart (block: RawBlock): Promise<void> { | ||
await this.masternodeStatsMapper.delete(block.height) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async invalidateBlockStart (block: RawBlock): Promise<void> { | |
await this.masternodeStatsMapper.delete(block.height) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed. c545463
mapTimelockStats (latest: TimelockStats[], lockStats: TimelockStats): TimelockStats[] { | ||
return latest.map(x => ({ | ||
...x, | ||
count: x.weeks === lockStats.weeks ? (x.count - lockStats.count) : x.count, | ||
tvl: x.weeks === lockStats.weeks ? new BigNumber(x.tvl).minus(lockStats.tvl).toFixed(8) : x.tvl | ||
})) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapTimelockStats (latest: TimelockStats[], lockStats: TimelockStats): TimelockStats[] { | |
return latest.map(x => ({ | |
...x, | |
count: x.weeks === lockStats.weeks ? (x.count - lockStats.count) : x.count, | |
tvl: x.weeks === lockStats.weeks ? new BigNumber(x.tvl).minus(lockStats.tvl).toFixed(8) : x.tvl | |
})) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have removed. 3538564
apps/whale-api/src/module.indexer/model/dftx/update.masternode.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Dilshan Madushanka <[email protected]> Signed-off-by: Kven Ho <[email protected]>
apps/whale-api/src/module.indexer/model/dftx/update.masternode.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Dilshan Madushanka <[email protected]> Signed-off-by: Kven Ho <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
apps/whale-api/src/module.indexer/model/dftx/update.masternode.ts
Outdated
Show resolved
Hide resolved
|
Signed-off-by: Fuxing Loh <[email protected]>
faf5589
…CreateMasternode (#1920) #### What this PR does / why we need it: This utilizes the "forward indexing" design; it doesn't require `whale-api` to be reindexed. It will automatically create a history entry to `MasternodeMapper`. You can update your `whale-api` node without this change.
What this PR does / why we need it:
Add
UpdateMasternodeIndexer extends DfTxIndexer<UpdateMasternode>
to update the masternode index when the DfTx UpdaterMasternode transaction is created.Which issue(s) does this PR fixes?:
Fixes part of #1842