evernode-js-client 0.6.54 → 0.6.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -9189,7 +9189,7 @@ module.exports = { mask, unmask };
9189
9189
 
9190
9190
 
9191
9191
  try {
9192
- module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.node");
9192
+ module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
9193
9193
  } catch (e) {
9194
9194
  module.exports = __nccwpck_require__(9467);
9195
9195
  }
@@ -38321,7 +38321,7 @@ module.exports = isValidUTF8;
38321
38321
 
38322
38322
 
38323
38323
  try {
38324
- module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
38324
+ module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.node");
38325
38325
  } catch (e) {
38326
38326
  module.exports = __nccwpck_require__(6982);
38327
38327
  }
@@ -60617,7 +60617,9 @@ class BaseEvernodeClient {
60617
60617
  const addrStateData = addrLedgerEntry?.HookStateData;
60618
60618
 
60619
60619
  if (addrStateData) {
60620
- const addrStateDecoded = StateHelpers.decodeReputationHostAddressState(Buffer.from(addrStateKey, 'hex'), Buffer.from(addrStateData, 'hex'));
60620
+ let addrStateDecoded = StateHelpers.decodeReputationHostAddressState(Buffer.from(addrStateKey, 'hex'), Buffer.from(addrStateData, 'hex'));
60621
+ const curMoment = await this.getMoment();
60622
+ addrStateDecoded.valid = !!(addrStateDecoded.lastScoredMoment && (curMoment - addrStateDecoded.lastScoredMoment) <= ReputationConstants.SCORE_EXPIRY_MOMENT_COUNT);
60621
60623
  return addrStateDecoded;
60622
60624
  }
60623
60625
  }
@@ -61682,22 +61684,26 @@ class HostClient extends BaseEvernodeClient {
61682
61684
 
61683
61685
  /**
61684
61686
  * Send reputation scores to the reputation hook.
61687
+ * @param {object} clusterSize Size of the cluster.
61685
61688
  * @param {object} scores [Optional] Score object in { host: score } format.
61686
61689
  */
61687
- async sendReputations(scores = null, options = {}) {
61688
- let buffer = null;
61690
+ async sendReputations(clusterSize, scores = null, options = {}) {
61691
+ let buffer = Buffer.alloc(1);
61689
61692
  if (scores) {
61690
61693
  const preparedScores = await this.prepareHostReputationScores(scores);
61691
61694
  if (preparedScores) {
61692
- buffer = Buffer.alloc(64, 0);
61695
+ buffer = Buffer.alloc(66, 0);
61693
61696
  let i = 0;
61694
61697
  for (const reputationScore of preparedScores) {
61695
- buffer.writeUIntLE(Number(reputationScore.scoreValue), i, 1);
61698
+ buffer.writeUIntLE(Number(reputationScore.scoreValue), i + 1, 1);
61696
61699
  i++;
61697
61700
  }
61701
+ buffer.writeUIntLE(clusterSize, 65, 1);
61698
61702
  }
61699
61703
  }
61700
61704
 
61705
+ buffer.writeUIntLE(ReputationConstants.SCORE_VERSION, 0, 1);
61706
+
61701
61707
  const paramData = codec.decodeAccountID(this.xrplAcc.address);
61702
61708
 
61703
61709
  await this.reputationAcc.invoke(this.config.reputationAddress,
@@ -63573,10 +63579,12 @@ const ErrorReasons = {
63573
63579
  }
63574
63580
 
63575
63581
  const ReputationConstants = {
63582
+ SCORE_VERSION: 1,
63576
63583
  REP_INFO_BUFFER_SIZE: 43,
63577
63584
  REP_INFO_PUBKEY_OFFSET: 0,
63578
63585
  REP_INFO_PEER_PORT_OFFSET: 33,
63579
- REP_INFO_MOMENT_OFFSET: 35
63586
+ REP_INFO_MOMENT_OFFSET: 35,
63587
+ SCORE_EXPIRY_MOMENT_COUNT: 2
63580
63588
  }
63581
63589
 
63582
63590
  // All keys are prefixed with 'EVR' (0x455652)
@@ -63965,6 +63973,10 @@ const HOST_ACCUMULATED_REWARD_OFFSET = 116;
63965
63973
  const HOST_REP_LAST_REG_MOMENT_OFFSET = 0;
63966
63974
  const HOST_REP_SCORE_NUMERATOR_OFFSET = 8;
63967
63975
  const HOST_REP_SCORE_DENOMINATOR_OFFSET = 16;
63976
+ const HOST_REP_SCORE_OFFSET = 24;
63977
+ const HOST_REP_LAST_RESET_MOMENT_OFFSET = 32;
63978
+ const HOST_REP_LAST_SCORED_MOMENT_OFFSET = 40;
63979
+ const HOST_REP_LAST_UNIVERSE_SIZE_OFFSET = 48;
63968
63980
 
63969
63981
  const PREV_HOST_ADDRESS_OFFSET = 0;
63970
63982
  const TRANSFER_LEDGER_IDX_OFFSET = 20;
@@ -64054,7 +64066,11 @@ class StateHelpers {
64054
64066
  hostAddress: codec.encodeAccountID(stateKeyBuf.slice(keyOffset)),
64055
64067
  lastRegisteredMoment: Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_REG_MOMENT_OFFSET)),
64056
64068
  scoreNumerator: Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_NUMERATOR_OFFSET)),
64057
- scoreDenominator: Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_DENOMINATOR_OFFSET))
64069
+ scoreDenominator: Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_DENOMINATOR_OFFSET)),
64070
+ score: stateDataBuf.length > HOST_REP_SCORE_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_OFFSET)) : null,
64071
+ lastResetMoment: stateDataBuf.length > HOST_REP_LAST_RESET_MOMENT_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_RESET_MOMENT_OFFSET)) : null,
64072
+ lastScoredMoment: stateDataBuf.length > HOST_REP_LAST_SCORED_MOMENT_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_SCORED_MOMENT_OFFSET)) : null,
64073
+ lastUniverseSize: stateDataBuf.length > HOST_REP_LAST_UNIVERSE_SIZE_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_UNIVERSE_SIZE_OFFSET)) : null,
64058
64074
  }
64059
64075
  return data;
64060
64076
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  ],
7
7
  "homepage": "https://github.com/HotPocketDev/evernode-js-client",
8
8
  "license": "SEE LICENSE IN https://raw.githubusercontent.com/EvernodeXRPL/evernode-resources/main/license/evernode-license.pdf",
9
- "version": "0.6.54",
9
+ "version": "0.6.56",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",
Binary file
Binary file