@streamr/node 101.0.0-beta.1 → 101.0.0-beta.2
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/dist/package.json +6 -6
- package/dist/src/plugins/operator/MaintainTopologyHelper.d.ts +3 -3
- package/dist/src/plugins/operator/MaintainTopologyHelper.js +18 -19
- package/dist/src/plugins/operator/MaintainTopologyHelper.js.map +1 -1
- package/dist/src/plugins/operator/OperatorPlugin.d.ts +1 -1
- package/dist/src/plugins/operator/OperatorPlugin.js +45 -54
- package/dist/src/plugins/operator/OperatorPlugin.js.map +1 -1
- package/dist/src/plugins/operator/announceNodeToContract.d.ts +2 -3
- package/dist/src/plugins/operator/announceNodeToContract.js +8 -8
- package/dist/src/plugins/operator/announceNodeToContract.js.map +1 -1
- package/dist/src/plugins/operator/checkOperatorValueBreach.d.ts +2 -2
- package/dist/src/plugins/operator/checkOperatorValueBreach.js +4 -4
- package/dist/src/plugins/operator/checkOperatorValueBreach.js.map +1 -1
- package/dist/src/plugins/operator/closeExpiredFlags.d.ts +2 -3
- package/dist/src/plugins/operator/closeExpiredFlags.js +6 -6
- package/dist/src/plugins/operator/closeExpiredFlags.js.map +1 -1
- package/dist/src/plugins/operator/inspectRandomNode.d.ts +3 -4
- package/dist/src/plugins/operator/inspectRandomNode.js +6 -6
- package/dist/src/plugins/operator/inspectRandomNode.js.map +1 -1
- package/dist/src/plugins/operator/inspectionUtils.d.ts +3 -4
- package/dist/src/plugins/operator/inspectionUtils.js +8 -7
- package/dist/src/plugins/operator/inspectionUtils.js.map +1 -1
- package/dist/src/plugins/operator/maintainOperatorValue.d.ts +2 -2
- package/dist/src/plugins/operator/maintainOperatorValue.js +3 -3
- package/dist/src/plugins/operator/maintainOperatorValue.js.map +1 -1
- package/dist/src/plugins/operator/reviewSuspectNode.d.ts +3 -4
- package/dist/src/plugins/operator/reviewSuspectNode.js +4 -4
- package/dist/src/plugins/operator/reviewSuspectNode.js.map +1 -1
- package/dist/src/plugins/storage/StorageEventListener.js +4 -4
- package/dist/src/plugins/storage/StorageEventListener.js.map +1 -1
- package/package.json +6 -6
- package/dist/src/plugins/operator/ContractFacade.d.ts +0 -80
- package/dist/src/plugins/operator/ContractFacade.js +0 -376
- package/dist/src/plugins/operator/ContractFacade.js.map +0 -1
- package/dist/src/plugins/operator/fetchRedundancyFactor.d.ts +0 -2
- package/dist/src/plugins/operator/fetchRedundancyFactor.js +0 -43
- package/dist/src/plugins/operator/fetchRedundancyFactor.js.map +0 -1
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.inspectTarget = exports.findNodesForTargetGivenFleetState = exports.findTarget = void 0;
|
|
7
|
-
const lodash_1 = require("lodash");
|
|
8
7
|
const protocol_1 = require("@streamr/protocol");
|
|
9
|
-
const
|
|
10
|
-
const weightedSample_1 = require("../../helpers/weightedSample");
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
11
9
|
const sample_1 = __importDefault(require("lodash/sample"));
|
|
12
10
|
const without_1 = __importDefault(require("lodash/without"));
|
|
11
|
+
const weightedSample_1 = require("../../helpers/weightedSample");
|
|
12
|
+
const ConsistentHashRing_1 = require("./ConsistentHashRing");
|
|
13
13
|
function createStreamIDMatcher(streamId) {
|
|
14
14
|
return (streamPart) => {
|
|
15
15
|
return protocol_1.StreamPartIDUtils.getStreamID(streamPart) === streamId;
|
|
@@ -21,9 +21,9 @@ function isAnyPartitionOfStreamAssignedToMe(assignments, streamId) {
|
|
|
21
21
|
function getPartitionsOfStreamAssignedToMe(assignments, streamId) {
|
|
22
22
|
return assignments.getMyStreamParts().filter(createStreamIDMatcher(streamId));
|
|
23
23
|
}
|
|
24
|
-
async function findTarget(myOperatorContractAddress,
|
|
24
|
+
async function findTarget(myOperatorContractAddress, myOperator, assignments, streamrClient, logger) {
|
|
25
25
|
// choose sponsorship
|
|
26
|
-
const sponsorships = await
|
|
26
|
+
const sponsorships = await myOperator.getSponsorships();
|
|
27
27
|
const suitableSponsorships = sponsorships
|
|
28
28
|
.filter(({ operatorCount }) => operatorCount >= 2) // exclude sponsorships with only self
|
|
29
29
|
.filter(({ streamId }) => isAnyPartitionOfStreamAssignedToMe(assignments, streamId));
|
|
@@ -34,7 +34,7 @@ async function findTarget(myOperatorContractAddress, contractFacade, assignments
|
|
|
34
34
|
const targetSponsorship = (0, weightedSample_1.weightedSample)(suitableSponsorships, ({ operatorCount }) => operatorCount - 1 // account for self to keep ratios correct
|
|
35
35
|
);
|
|
36
36
|
// choose operator
|
|
37
|
-
const operators = await
|
|
37
|
+
const operators = await myOperator.getOperatorsInSponsorship(targetSponsorship.sponsorshipAddress);
|
|
38
38
|
const targetOperatorAddress = (0, sample_1.default)((0, without_1.default)(operators, myOperatorContractAddress));
|
|
39
39
|
if (targetOperatorAddress === undefined) {
|
|
40
40
|
// Only happens if during the async awaits the other operator(s) were removed from the sponsorship.
|
|
@@ -49,7 +49,8 @@ async function findTarget(myOperatorContractAddress, contractFacade, assignments
|
|
|
49
49
|
logger.info('Skip inspection (no suitable stream part)', { targetSponsorship, targetOperatorAddress });
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
52
|
-
const
|
|
52
|
+
const targetOperator = streamrClient.getOperator(targetOperatorAddress);
|
|
53
|
+
const flagAlreadyRaised = await targetOperator.hasOpenFlag(targetSponsorship.sponsorshipAddress);
|
|
53
54
|
if (flagAlreadyRaised) {
|
|
54
55
|
logger.info('Skip inspection (target already has open flag)', { targetSponsorship, targetOperatorAddress });
|
|
55
56
|
return undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspectionUtils.js","sourceRoot":"","sources":["../../../../src/plugins/operator/inspectionUtils.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAgC;
|
|
1
|
+
{"version":3,"file":"inspectionUtils.js","sourceRoot":"","sources":["../../../../src/plugins/operator/inspectionUt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S,CAAC;QACtC,EAAE,EAAE,4BAAiB,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC;QACpD,SAAS,EAAE,4BAAiB,CAAC,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC;QAClE,GAAG,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,IAAI,CAAC;QACD,KAAK,MAAM,UAAU,IAAI,IAAA,gBAAO,EAAC,qBAAqB,CAAC,EAAE,CAAC;YACtD,6BAA6B;YAC7B,2EAA2E;YAC3E,MAAM,MAAM,GAAG,IAAI,CAAA;YACnB,WAAW,CAAC,cAAc,EAAE,CAAA;YAC5B,IAAI,MAAM,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE;oBAC/C,cAAc,EAAE,MAAM,CAAC,eAAe;oBACtC,gBAAgB,EAAE,MAAM,CAAC,UAAU;oBACnC,UAAU,EAAE,UAAU,CAAC,MAAM;oBAC7B,iBAAiB,EAAE,MAAM,CAAC,kBAAkB;iBAC/C,CAAC,CAAA;gBACF,OAAO,IAAI,CAAA;YACf,CAAC;QACL,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,kCAAkC,EAAE;YAC5C,cAAc,EAAE,MAAM,CAAC,eAAe;YACtC,gBAAgB,EAAE,MAAM,CAAC,UAAU;YACnC,WAAW,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC;YAC9D,iBAAiB,EAAE,MAAM,CAAC,kBAAkB;SAC/C,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IAChB,CAAC;YAAS,CAAC;QACP,MAAM,GAAG,CAAC,WAAW,EAAE,CAAA;IAC3B,CAAC;AACL,CAAC;AAvDD,sCAuDC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const maintainOperatorValue: (withdrawLimitSafetyFraction: number, minSponsorshipEarningsInWithdraw: number, maxSponsorshipsInWithdraw: number,
|
|
1
|
+
import { Operator } from '@streamr/sdk';
|
|
2
|
+
export declare const maintainOperatorValue: (withdrawLimitSafetyFraction: number, minSponsorshipEarningsInWithdraw: number, maxSponsorshipsInWithdraw: number, myOperator: Operator) => Promise<void>;
|
|
@@ -4,14 +4,14 @@ exports.maintainOperatorValue = void 0;
|
|
|
4
4
|
const utils_1 = require("@streamr/utils");
|
|
5
5
|
const multiply_1 = require("../../helpers/multiply");
|
|
6
6
|
const logger = new utils_1.Logger(module);
|
|
7
|
-
const maintainOperatorValue = async (withdrawLimitSafetyFraction, minSponsorshipEarningsInWithdraw, maxSponsorshipsInWithdraw,
|
|
7
|
+
const maintainOperatorValue = async (withdrawLimitSafetyFraction, minSponsorshipEarningsInWithdraw, maxSponsorshipsInWithdraw, myOperator) => {
|
|
8
8
|
logger.info('Check whether it is time to withdraw my earnings');
|
|
9
|
-
const { sumDataWei, maxAllowedEarningsDataWei, sponsorshipAddresses } = await
|
|
9
|
+
const { sumDataWei, maxAllowedEarningsDataWei, sponsorshipAddresses } = await myOperator.getEarnings(minSponsorshipEarningsInWithdraw, maxSponsorshipsInWithdraw);
|
|
10
10
|
const triggerWithdrawLimitDataWei = (0, multiply_1.multiply)(maxAllowedEarningsDataWei, 1 - withdrawLimitSafetyFraction);
|
|
11
11
|
logger.trace(` -> is ${sumDataWei} > ${triggerWithdrawLimitDataWei} ?`);
|
|
12
12
|
if (sumDataWei > triggerWithdrawLimitDataWei) {
|
|
13
13
|
logger.info('Withdraw earnings from sponsorships', { sponsorshipAddresses });
|
|
14
|
-
await
|
|
14
|
+
await myOperator.withdrawEarningsFromSponsorships(sponsorshipAddresses);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
logger.info('Skip withdrawing earnings');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maintainOperatorValue.js","sourceRoot":"","sources":["../../../../src/plugins/operator/maintainOperatorValue.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"maintainOperatorValue.js","sourceRoot":"","sources":["../../../../src/plugins/operator/maintainOperatorValue.ts"],"names":[],"mappings":";;;AACA,0CAAuC;AACvC,qDAAiD;AAEjD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAE1B,MAAM,qBAAqB,GAAG,KAAK,EACtC,2BAAmC,EACnC,gCAAwC,EACxC,yBAAiC,EACjC,UAAoB,EACP,EAAE;IACf,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;IAC/D,MAAM,EAAE,UAAU,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,GAAG,MAAM,UAAU,CAAC,WAAW,CAChG,gCAAgC,EAChC,yBAAyB,CAC5B,CAAA;IACD,MAAM,2BAA2B,GAAG,IAAA,mBAAQ,EAAC,yBAAyB,EAAE,CAAC,GAAG,2BAA2B,CAAC,CAAA;IACxG,MAAM,CAAC,KAAK,CAAC,UAAU,UAAU,MAAM,2BAA2B,IAAI,CAAC,CAAA;IACvE,IAAI,UAAU,GAAG,2BAA2B,EAAE,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,EAAE,oBAAoB,EAAE,CAAC,CAAA;QAC5E,MAAM,UAAU,CAAC,gCAAgC,CAAC,oBAAoB,CAAC,CAAA;IAC3E,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAA;IAC5C,CAAC;AACL,CAAC,CAAA;AAnBY,QAAA,qBAAqB,yBAmBjC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
import { Operator, StreamrClient } from '@streamr/sdk';
|
|
2
3
|
import { EthereumAddress } from '@streamr/utils';
|
|
3
|
-
import { ContractFacade } from './ContractFacade';
|
|
4
|
-
import { StreamrClient } from '@streamr/sdk';
|
|
5
4
|
import { CreateOperatorFleetStateFn } from './OperatorFleetState';
|
|
6
5
|
export interface ReviewProcessOpts {
|
|
7
6
|
sponsorshipAddress: EthereumAddress;
|
|
8
7
|
targetOperator: EthereumAddress;
|
|
9
8
|
partition: number;
|
|
10
|
-
|
|
9
|
+
myOperator: Operator;
|
|
11
10
|
streamrClient: StreamrClient;
|
|
12
11
|
createOperatorFleetState: CreateOperatorFleetStateFn;
|
|
13
12
|
getRedundancyFactor: (operatorContractAddress: EthereumAddress) => Promise<number | undefined>;
|
|
@@ -21,4 +20,4 @@ export interface ReviewProcessOpts {
|
|
|
21
20
|
maxInspections: number;
|
|
22
21
|
abortSignal: AbortSignal;
|
|
23
22
|
}
|
|
24
|
-
export declare const reviewSuspectNode: ({ sponsorshipAddress, targetOperator, partition,
|
|
23
|
+
export declare const reviewSuspectNode: ({ sponsorshipAddress, targetOperator, partition, myOperator, streamrClient, createOperatorFleetState, getRedundancyFactor, maxSleepTime, heartbeatTimeoutInMs, votingPeriod, inspectionIntervalInMs, maxInspections, abortSignal }: ReviewProcessOpts) => Promise<void>;
|
|
@@ -4,16 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.reviewSuspectNode = void 0;
|
|
7
|
-
const utils_1 = require("@streamr/utils");
|
|
8
7
|
const protocol_1 = require("@streamr/protocol");
|
|
8
|
+
const utils_1 = require("@streamr/utils");
|
|
9
9
|
const random_1 = __importDefault(require("lodash/random"));
|
|
10
10
|
const inspectOverTime_1 = require("./inspectOverTime");
|
|
11
11
|
const logger = new utils_1.Logger(module);
|
|
12
|
-
const reviewSuspectNode = async ({ sponsorshipAddress, targetOperator, partition,
|
|
12
|
+
const reviewSuspectNode = async ({ sponsorshipAddress, targetOperator, partition, myOperator, streamrClient, createOperatorFleetState, getRedundancyFactor, maxSleepTime, heartbeatTimeoutInMs, votingPeriod, inspectionIntervalInMs, maxInspections, abortSignal }) => {
|
|
13
13
|
if (Date.now() + maxSleepTime > votingPeriod.startTime) {
|
|
14
14
|
throw new Error('Max sleep time overlaps with voting period');
|
|
15
15
|
}
|
|
16
|
-
const streamId = await
|
|
16
|
+
const streamId = await myOperator.getStreamId(sponsorshipAddress);
|
|
17
17
|
// random sleep time to make sure multiple instances of voters don't all inspect at the same time
|
|
18
18
|
const sleepTimeInMsBeforeFirstInspection = (0, random_1.default)(maxSleepTime);
|
|
19
19
|
const consumeResults = (0, inspectOverTime_1.inspectOverTime)({
|
|
@@ -40,7 +40,7 @@ const reviewSuspectNode = async ({ sponsorshipAddress, targetOperator, partition
|
|
|
40
40
|
const kick = results.filter((b) => b).length <= results.length / 2;
|
|
41
41
|
logger.info('Vote on flag', { sponsorshipAddress, targetOperator, kick });
|
|
42
42
|
try {
|
|
43
|
-
await
|
|
43
|
+
await myOperator.voteOnFlag(sponsorshipAddress, targetOperator, kick);
|
|
44
44
|
}
|
|
45
45
|
catch (err) {
|
|
46
46
|
logger.warn('Encountered error while voting on flag', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewSuspectNode.js","sourceRoot":"","sources":["../../../../src/plugins/operator/reviewSuspectNode.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"reviewSuspectNode.js","sourceRoot":"","sources":["../../../../src/plugins/operator/reviewSuspectNode.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAkD;AAElD,0CAA2F;AAC3F,2DAAkC;AAElC,uDAAmD;AAEnD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAqB1B,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACpC,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,sBAAsB,EACtB,cAAc,EACd,WAAW,EACK,EAAiB,EAAE;IACnC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,YAAY,GAAG,YAAY,CAAC,SAAS,EAAE,C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Ac,EAAE,IAAI,CAAC,CAAA;QACzE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,wCAAwC,EAAE;gBAClD,kBAAkB;gBAClB,cAAc;gBACd,IAAI;gBACJ,MAAM,EAAE,GAAG,EAAE,OAAO;aACvB,CAAC,CAAA;QACN,CAAC;IACL,CAAC,EAAE,iBAAiB,EAAE,WAAW,CAAC,CAAA;AACtC,CAAC,CAAA;AAxDY,QAAA,iBAAiB,qBAwD7B"}
|
|
@@ -34,12 +34,12 @@ class StorageEventListener {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
start() {
|
|
37
|
-
this.streamrClient.on('
|
|
38
|
-
this.streamrClient.on('
|
|
37
|
+
this.streamrClient.on('streamAddedToStorageNode', this.onAddToStorageNode);
|
|
38
|
+
this.streamrClient.on('streamRemovedFromFromStorageNode', this.onRemoveFromStorageNode);
|
|
39
39
|
}
|
|
40
40
|
destroy() {
|
|
41
|
-
this.streamrClient.off('
|
|
42
|
-
this.streamrClient.off('
|
|
41
|
+
this.streamrClient.off('streamAddedToStorageNode', this.onAddToStorageNode);
|
|
42
|
+
this.streamrClient.off('streamRemovedFromFromStorageNode', this.onRemoveFromStorageNode);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
exports.StorageEventListener = StorageEventListener;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageEventListener.js","sourceRoot":"","sources":["../../../../src/plugins/storage/StorageEventListener.ts"],"names":[],"mappings":";;;AACA,0CAAwD;AAExD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC;;;GAGG;AACH,MAAa,oBAAoB;IACZ,SAAS,CAAiB;IAC1B,aAAa,CAAe;IAC5B,OAAO,CAAoE;IAC3E,kBAAkB,CAA6C;IAC/D,uBAAuB,CAA6C;IAErF,YACI,SAA0B,EAC1B,aAA4B,EAC5B,OAA2E;QAE3E,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,CAAC,KAAiC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QACjG,IAAI,CAAC,uBAAuB,GAAG,CAAC,KAAiC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAC5G,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,KAAiC,EAAE,IAAyB;QAClF,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YACvC,OAAM;QACV,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QACnE,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YACjE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,uDAAuD,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAC9F,CAAC;IACL,CAAC;IAED,KAAK;QACD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"StorageEventListener.js","sourceRoot":"","sources":["../../../../src/plugins/storage/StorageEventListener.ts"],"names":[],"mappings":";;;AACA,0CAAwD;AAExD,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,MAAM,CAAC,CAAA;AAEjC;;;GAGG;AACH,MAAa,oBAAoB;IACZ,SAAS,CAAiB;IAC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AC,kCAAkC,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAA;IAC3F,CAAC;IAED,OAAO;QACH,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,0BAA0B,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAC3E,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,kCAAkC,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAA;IAC5F,CAAC;CACJ;AAzCD,oDAyCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/node",
|
|
3
|
-
"version": "101.0.0-beta.
|
|
3
|
+
"version": "101.0.0-beta.2",
|
|
4
4
|
"description": "A full-featured node implementation for the Streamr Network",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"@inquirer/prompts": "^4.2.1",
|
|
33
33
|
"@streamr/config": "^5.3.12",
|
|
34
34
|
"@streamr/network-contracts-ethers6": "^7.1.2",
|
|
35
|
-
"@streamr/protocol": "101.0.0-beta.
|
|
36
|
-
"@streamr/sdk": "101.0.0-beta.
|
|
37
|
-
"@streamr/utils": "101.0.0-beta.
|
|
35
|
+
"@streamr/protocol": "101.0.0-beta.2",
|
|
36
|
+
"@streamr/sdk": "101.0.0-beta.2",
|
|
37
|
+
"@streamr/utils": "101.0.0-beta.2",
|
|
38
38
|
"aedes": "^0.51.0",
|
|
39
39
|
"ajv": "^8.8.2",
|
|
40
40
|
"ajv-formats": "^2.1.1",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@inquirer/testing": "^2.1.12",
|
|
61
|
-
"@streamr/dht": "101.0.0-beta.
|
|
62
|
-
"@streamr/test-utils": "101.0.0-beta.
|
|
61
|
+
"@streamr/dht": "101.0.0-beta.2",
|
|
62
|
+
"@streamr/test-utils": "101.0.0-beta.2",
|
|
63
63
|
"@types/cors": "^2.8.17",
|
|
64
64
|
"@types/express": "^4.17.21",
|
|
65
65
|
"@types/heap": "^0.2.34",
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Provider } from 'ethers';
|
|
3
|
-
import { Operator } from '@streamr/network-contracts-ethers6';
|
|
4
|
-
import { StreamID } from '@streamr/protocol';
|
|
5
|
-
import { EthereumAddress, TheGraphClient } from '@streamr/utils';
|
|
6
|
-
import { Overrides } from 'ethers';
|
|
7
|
-
import { NetworkPeerDescriptor } from '@streamr/sdk';
|
|
8
|
-
import { OperatorServiceConfig } from './OperatorPlugin';
|
|
9
|
-
interface EarningsData {
|
|
10
|
-
sponsorshipAddresses: EthereumAddress[];
|
|
11
|
-
sumDataWei: bigint;
|
|
12
|
-
maxAllowedEarningsDataWei: bigint;
|
|
13
|
-
}
|
|
14
|
-
export declare const VOTE_KICK = "0x0000000000000000000000000000000000000000000000000000000000000001";
|
|
15
|
-
export declare const VOTE_NO_KICK = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
16
|
-
export declare class ParseError extends Error {
|
|
17
|
-
readonly reasonText: string;
|
|
18
|
-
constructor(reasonText: string);
|
|
19
|
-
}
|
|
20
|
-
export declare function parsePartitionFromReviewRequestMetadata(metadataAsString: string | undefined): number | never;
|
|
21
|
-
export type ReviewRequestListener = (sponsorship: EthereumAddress, operatorContractAddress: EthereumAddress, partition: number, votingPeriodStartTime: number, votingPeriodEndTime: number) => void;
|
|
22
|
-
export interface SponsorshipResult {
|
|
23
|
-
sponsorshipAddress: EthereumAddress;
|
|
24
|
-
streamId: StreamID;
|
|
25
|
-
operatorCount: number;
|
|
26
|
-
}
|
|
27
|
-
export interface Flag {
|
|
28
|
-
id: string;
|
|
29
|
-
flaggingTimestamp: number;
|
|
30
|
-
target: {
|
|
31
|
-
id: string;
|
|
32
|
-
};
|
|
33
|
-
sponsorship: {
|
|
34
|
-
id: string;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export declare class ContractFacade {
|
|
38
|
-
private readonly operatorContract;
|
|
39
|
-
private readonly theGraphClient;
|
|
40
|
-
private readonly config;
|
|
41
|
-
constructor(operatorContract: Operator, theGraphClient: TheGraphClient, config: OperatorServiceConfig);
|
|
42
|
-
static createInstance(config: OperatorServiceConfig): ContractFacade;
|
|
43
|
-
writeHeartbeat(nodeDescriptor: NetworkPeerDescriptor): Promise<void>;
|
|
44
|
-
getTimestampOfLastHeartbeat(): Promise<number | undefined>;
|
|
45
|
-
getOperatorContractAddress(): Promise<EthereumAddress>;
|
|
46
|
-
getSponsorshipsOfOperator(operatorAddress: EthereumAddress): Promise<SponsorshipResult[]>;
|
|
47
|
-
getExpiredFlags(sponsorships: EthereumAddress[], maxAgeInMs: number): Promise<Flag[]>;
|
|
48
|
-
getOperatorsInSponsorship(sponsorshipAddress: EthereumAddress): Promise<EthereumAddress[]>;
|
|
49
|
-
flag(sponsorship: EthereumAddress, operator: EthereumAddress, partition: number): Promise<void>;
|
|
50
|
-
getRandomOperator(): Promise<EthereumAddress | undefined>;
|
|
51
|
-
/**
|
|
52
|
-
* Find the sum of earnings in Sponsorships (that the Operator must withdraw before the sum reaches a limit),
|
|
53
|
-
* SUBJECT TO the constraints, set in the OperatorServiceConfig:
|
|
54
|
-
* - only take at most maxSponsorshipsInWithdraw addresses (those with most earnings), or all if undefined
|
|
55
|
-
* - only take sponsorships that have more than minSponsorshipEarningsInWithdraw, or all if undefined
|
|
56
|
-
*/
|
|
57
|
-
getEarningsOf(operatorContractAddress: EthereumAddress, minSponsorshipEarningsInWithdraw: number, maxSponsorshipsInWithdraw: number): Promise<EarningsData>;
|
|
58
|
-
getMyEarnings(minSponsorshipEarningsInWithdraw: number, maxSponsorshipsInWithdraw: number): Promise<EarningsData>;
|
|
59
|
-
withdrawMyEarningsFromSponsorships(sponsorshipAddresses: EthereumAddress[]): Promise<void>;
|
|
60
|
-
triggerWithdraw(targetOperatorAddress: EthereumAddress, sponsorshipAddresses: EthereumAddress[]): Promise<void>;
|
|
61
|
-
private getOperatorAddresses;
|
|
62
|
-
pullStakedStreams(requiredBlockNumber: number): AsyncGenerator<{
|
|
63
|
-
sponsorship: {
|
|
64
|
-
id: string;
|
|
65
|
-
stream: {
|
|
66
|
-
id: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
}, undefined, undefined>;
|
|
70
|
-
hasOpenFlag(operatorAddress: EthereumAddress, sponsorshipAddress: EthereumAddress): Promise<boolean>;
|
|
71
|
-
addReviewRequestListener(listener: ReviewRequestListener, abortSignal: AbortSignal): void;
|
|
72
|
-
getStreamId(sponsorshipAddress: string): Promise<StreamID>;
|
|
73
|
-
voteOnFlag(sponsorship: string, targetOperator: string, kick: boolean): Promise<void>;
|
|
74
|
-
closeFlag(sponsorship: string, targetOperator: string): Promise<void>;
|
|
75
|
-
addOperatorContractStakeEventListener(eventName: 'Staked' | 'Unstaked', listener: (sponsorship: string) => unknown): void;
|
|
76
|
-
removeOperatorContractStakeEventListener(eventName: 'Staked' | 'Unstaked', listener: (sponsorship: string) => unknown): void;
|
|
77
|
-
getProvider(): Provider;
|
|
78
|
-
getEthersOverrides(): Promise<Overrides>;
|
|
79
|
-
}
|
|
80
|
-
export {};
|