evernode-js-client 0.6.56 → 0.6.58
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +43 -53
- package/package.json +1 -1
package/index.js
CHANGED
@@ -61103,11 +61103,8 @@ module.exports = {
|
|
61103
61103
|
/***/ 538:
|
61104
61104
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
61105
61105
|
|
61106
|
-
const codec = __nccwpck_require__(597);
|
61107
61106
|
const { StateHelpers } = __nccwpck_require__(3390);
|
61108
|
-
const { XrplAccount } = __nccwpck_require__(6099);
|
61109
61107
|
const { BaseEvernodeClient } = __nccwpck_require__(4438);
|
61110
|
-
const { ReputationConstants } = __nccwpck_require__(5732);
|
61111
61108
|
|
61112
61109
|
const ReputationEvents = {}
|
61113
61110
|
|
@@ -61645,69 +61642,63 @@ class HostClient extends BaseEvernodeClient {
|
|
61645
61642
|
|
61646
61643
|
/**
|
61647
61644
|
* Prepare host reputation score to a common format for submission.
|
61648
|
-
* @param {
|
61649
|
-
* @
|
61645
|
+
* @param {number} scoreVersion Version of the scores.
|
61646
|
+
* @param {number} clusterSize Size of the cluster.
|
61647
|
+
* @param {object} collectedScores [Optional] Score object in { host: score } format.
|
61648
|
+
* @returns Unified reputation score buffer.
|
61650
61649
|
*/
|
61651
|
-
async prepareHostReputationScores(collectedScores =
|
61652
|
-
const myReputationInfo = await this.getReputationOrderByAddress(this.xrplAcc.address);
|
61653
|
-
if (!("orderedId" in (myReputationInfo ?? {})))
|
61654
|
-
return null;
|
61655
|
-
|
61656
|
-
const myOrderId = myReputationInfo.orderedId;
|
61657
|
-
|
61658
|
-
// Deciding universe.
|
61659
|
-
const universeStartIndex = Math.floor(myOrderId / 64) * 64;
|
61660
|
-
|
61661
|
-
const reputationClient = await HookClientFactory.create(HookTypes.reputation);
|
61662
|
-
await reputationClient.connect();
|
61663
|
-
let data = {};
|
61664
|
-
await Promise.all(Array.from({ length: 64 }, (_, i) => i + universeStartIndex).map(async (i) => {
|
61665
|
-
try {
|
61666
|
-
const hostReputationInfo = await reputationClient.getReputationContractInfoByOrderedId(i);
|
61667
|
-
if (!hostReputationInfo)
|
61668
|
-
throw 'No reputation info for this order id';
|
61669
|
-
data[i.toString()] = {
|
61670
|
-
publicKey: hostReputationInfo.contract?.pubkey ?? "-1",
|
61671
|
-
orderId: i
|
61672
|
-
};
|
61673
|
-
} catch (error) {
|
61674
|
-
data[i.toString()] = { publicKey: "-1", orderId: i };
|
61675
|
-
}
|
61676
|
-
}));
|
61677
|
-
await reputationClient.disconnect();
|
61678
|
-
|
61679
|
-
return Object.entries(data).map(e => ({
|
61680
|
-
...e[1],
|
61681
|
-
scoreValue: collectedScores[e[1]?.publicKey] || 0
|
61682
|
-
}));
|
61683
|
-
}
|
61684
|
-
|
61685
|
-
/**
|
61686
|
-
* Send reputation scores to the reputation hook.
|
61687
|
-
* @param {object} clusterSize Size of the cluster.
|
61688
|
-
* @param {object} scores [Optional] Score object in { host: score } format.
|
61689
|
-
*/
|
61690
|
-
async sendReputations(clusterSize, scores = null, options = {}) {
|
61650
|
+
async prepareHostReputationScores(scoreVersion, clusterSize, collectedScores = null) {
|
61691
61651
|
let buffer = Buffer.alloc(1);
|
61692
|
-
if (
|
61693
|
-
const
|
61694
|
-
if (
|
61652
|
+
if (collectedScores) {
|
61653
|
+
const myReputationInfo = await this.getReputationOrderByAddress(this.xrplAcc.address);
|
61654
|
+
if (("orderedId" in (myReputationInfo ?? {}))) {
|
61655
|
+
const myOrderId = myReputationInfo.orderedId;
|
61656
|
+
|
61657
|
+
// Deciding universe.
|
61658
|
+
const universeStartIndex = Math.floor(myOrderId / 64) * 64;
|
61659
|
+
|
61660
|
+
const reputationClient = await HookClientFactory.create(HookTypes.reputation);
|
61661
|
+
await reputationClient.connect();
|
61662
|
+
let data = {};
|
61663
|
+
await Promise.all(Array.from({ length: 64 }, (_, i) => i + universeStartIndex).map(async (i) => {
|
61664
|
+
try {
|
61665
|
+
const hostReputationInfo = await reputationClient.getReputationContractInfoByOrderedId(i);
|
61666
|
+
if (!hostReputationInfo)
|
61667
|
+
throw 'No reputation info for this order id';
|
61668
|
+
data[i.toString()] = {
|
61669
|
+
publicKey: hostReputationInfo.contract?.pubkey ?? "-1",
|
61670
|
+
orderId: i
|
61671
|
+
};
|
61672
|
+
} catch (error) {
|
61673
|
+
data[i.toString()] = { publicKey: "-1", orderId: i };
|
61674
|
+
}
|
61675
|
+
}));
|
61676
|
+
await reputationClient.disconnect();
|
61677
|
+
|
61695
61678
|
buffer = Buffer.alloc(66, 0);
|
61696
61679
|
let i = 0;
|
61697
|
-
for (const
|
61698
|
-
buffer.writeUIntLE(Number(
|
61680
|
+
for (const e of Object.entries(data)) {
|
61681
|
+
buffer.writeUIntLE(Number(collectedScores[e[1]?.publicKey] || 0), i + 1, 1);
|
61699
61682
|
i++;
|
61700
61683
|
}
|
61701
61684
|
buffer.writeUIntLE(clusterSize, 65, 1);
|
61702
61685
|
}
|
61703
61686
|
}
|
61704
61687
|
|
61705
|
-
buffer.writeUIntLE(
|
61688
|
+
buffer.writeUIntLE(scoreVersion, 0, 1);
|
61689
|
+
|
61690
|
+
return buffer;
|
61691
|
+
}
|
61706
61692
|
|
61693
|
+
/**
|
61694
|
+
* Send reputation scores to the reputation hook.
|
61695
|
+
* @param {string} bufferHex Prepared score buffer as hex string.
|
61696
|
+
*/
|
61697
|
+
async sendReputations(bufferHex, options = {}) {
|
61707
61698
|
const paramData = codec.decodeAccountID(this.xrplAcc.address);
|
61708
61699
|
|
61709
61700
|
await this.reputationAcc.invoke(this.config.reputationAddress,
|
61710
|
-
|
61701
|
+
bufferHex ? { isHex: true, data: bufferHex } : null,
|
61711
61702
|
{
|
61712
61703
|
hookParams: [
|
61713
61704
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_SEND_REPUTATION },
|
@@ -63579,7 +63570,6 @@ const ErrorReasons = {
|
|
63579
63570
|
}
|
63580
63571
|
|
63581
63572
|
const ReputationConstants = {
|
63582
|
-
SCORE_VERSION: 1,
|
63583
63573
|
REP_INFO_BUFFER_SIZE: 43,
|
63584
63574
|
REP_INFO_PUBKEY_OFFSET: 0,
|
63585
63575
|
REP_INFO_PEER_PORT_OFFSET: 33,
|
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.
|
9
|
+
"version": "0.6.58",
|
10
10
|
"dependencies": {
|
11
11
|
"elliptic": "6.5.4",
|
12
12
|
"libsodium-wrappers": "0.7.10",
|