Skip to content
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

Identity field for Validators #254

Merged
merged 12 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ GET /validators
payoutAddress: "yeRZBWYfeNE4yVUHV4ZLs83Ppn9aMRH57A",
pubKeyOperator: "b928fa4e127214ccb2b5de1660b5e371d2f3c9845077bc3900fc6aabe82ddd2e61530be3765cea15752e30fc761ab730"
}
}
},
identity: "8tsWRSwsTM5AXv4ViCF9gu39kzjbtfFDM6rCyL2RcFzd"
}, ...
],
pagination: {
Expand Down Expand Up @@ -318,7 +319,8 @@ GET /validator/F60A6BF9EC0794BB0CFD1E0F2217933F4B33EDE6FE810692BC275CA18148AEF0
payoutAddress: "yeRZBWYfeNE4yVUHV4ZLs83Ppn9aMRH57A",
pubKeyOperator: "b928fa4e127214ccb2b5de1660b5e371d2f3c9845077bc3900fc6aabe82ddd2e61530be3765cea15752e30fc761ab730"
}
}
},
"identity: "8tsWRSwsTM5AXv4ViCF9gu39kzjbtfFDM6rCyL2RcFzd"
}
```
---
Expand Down
1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@dashevo/dashd-rpc": "^19.0.0",
"@fastify/cors": "^8.3.0",
"@scure/base": "^1.1.5",
"bs58": "^6.0.0",
"dash": "4.2.0",
"dotenv": "^16.3.1",
"fastify": "^4.21.0",
Expand Down
11 changes: 6 additions & 5 deletions packages/api/src/controllers/ValidatorsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ class ValidatorsController {
return response.send({
...validators,
resultSet: validatorsWithInfo.map(validator =>
new Validator(validator.proTxHash, activeValidators.some(activeValidator =>
activeValidator.pro_tx_hash === validator.proTxHash),
validator.proposedBlocksAmount,
validator.lastProposedBlockHeader,
ProTxInfo.fromObject(validator.proTxInfo)
new Validator(
validator.proTxHash, activeValidators.some(activeValidator =>
activeValidator.pro_tx_hash === validator.proTxHash),
validator.proposedBlocksAmount,
validator.lastProposedBlockHeader,
ProTxInfo.fromObject(validator.proTxInfo)
)
)
})
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/models/Validator.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/* eslint-disable camelcase */
const BlockHeader = require('./BlockHeader')
const Base58 = require('bs58').default

module.exports = class Validator {
proTxHash
isActive
proposedBlocksAmount
lastProposedBlockHeader
proTxInfo
identity

constructor (
proTxHash,
isActive,
Expand All @@ -19,6 +22,7 @@ module.exports = class Validator {
this.proposedBlocksAmount = proposedBlocksAmount ?? null
this.lastProposedBlockHeader = lastProposedBlockHeader ?? null
this.proTxInfo = proTxInfo ?? null
this.identity = proTxHash ? Base58.encode(Buffer.from(proTxHash, 'hex')) : null
}

static fromRow ({
Expand Down
Loading
Loading