Skip to content

Commit

Permalink
* Added support for returning Hermes version in server/info
Browse files Browse the repository at this point in the history
* Removed async/await code in ValidationMessage.ts writer
  • Loading branch information
pkcs8 committed Oct 6, 2022
1 parent c2fb856 commit fc25fd2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hermes",
"version": "0.3.0",
"version": "0.3.1",
"description": "Project Hermes: XRPL Validation message service",
"main": "index.js",
"author": "Anurag",
Expand Down
3 changes: 3 additions & 0 deletions src/controllers/ServerController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ ServerController.route('/config')
if (ENV.SERVER_GRPC_ENABLED) {
info.grpc_url = `${ENV.SERVER_HOSTNAME}:${ENV.SERVER_GRPC_PORT}`
}
if (process.env.name && process.env.version) {
info.version = `${process.env.name}-${process.env.version}`
}
}
return res.json(info)
})
Expand Down
14 changes: 5 additions & 9 deletions src/processors/ValidationMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@ class ValidationMessage {
this._signingPubKey = decodeNodePublic(validation.validation_public_key).toString('hex').toUpperCase()
}

async create(): Promise<boolean> {
create(): boolean {
if (this.verify()) {
try {
await Validation.create(this._validation)
return true
} catch (error) {
Validation.create(this._validation, (error, doc) => {
if (error instanceof MongoServerError && error.code === 11000) {
logger.verbose(LOGPREFIX, `${error}`)
}
else {
else if (error) {
logger.error(LOGPREFIX, `${error}`)
}
return false
}
})
return true
}
else {
logger.verbose(LOGPREFIX, `Error: Signature verification failed for ${this._validation.validation_public_key}.${this._validation.ledger_index}`)
Expand Down
4 changes: 2 additions & 2 deletions src/processors/peersync/PollService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class PollService {
if (LocalNode.host) ledgerRangeRequest.setRequestingHost(LocalNode.host)

client.getValidationsByLedgerRange(ledgerRangeRequest)
.on('data', async (validation: ValidationResponse) => {
.on('data', (validation: ValidationResponse) => {
try {
const vm = new ValidationMessage(this.deserialize(validation))
await vm.create()
vm.create()
} catch {
}
this._totalDocs++
Expand Down
1 change: 1 addition & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ interface IServerInfo {
fingerprint?: string | void
rest_url?: string
grpc_url?: string
version?: string
}

0 comments on commit fc25fd2

Please sign in to comment.