Skip to content

Commit

Permalink
Merge pull request #254 from pshenmic/feat/validators-hash
Browse files Browse the repository at this point in the history
Identity field for Validators
  • Loading branch information
pshenmic authored Sep 6, 2024
2 parents ccd5873 + 5e9d3b4 commit ce9cf93
Show file tree
Hide file tree
Showing 6 changed files with 644 additions and 499 deletions.
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

0 comments on commit ce9cf93

Please sign in to comment.