streamr-client-protocol
Advanced tools
Comparing version 8.5.0-alpha.0 to 8.5.0-alpha.1
@@ -10,2 +10,3 @@ import TimestampUtil from "./TimestampUtil"; | ||
import { generateMnemonicFromAddress, parseAddressFromNodeId } from './NodeUtil'; | ||
export { TimestampUtil, OrderingUtil, StreamMessageValidator, CachingStreamMessageValidator, SigningUtil, SmartContractRecord, TrackerRegistry, createTrackerRegistry, getTrackerRegistryFromContract, StorageNodeRegistry, createStorageNodeRegistry, getStorageNodeRegistryFromContract, generateMnemonicFromAddress, parseAddressFromNodeId }; | ||
import { keyToArrayIndex } from "./HashUtil"; | ||
export { TimestampUtil, OrderingUtil, StreamMessageValidator, CachingStreamMessageValidator, SigningUtil, SmartContractRecord, TrackerRegistry, createTrackerRegistry, getTrackerRegistryFromContract, StorageNodeRegistry, createStorageNodeRegistry, getStorageNodeRegistryFromContract, generateMnemonicFromAddress, parseAddressFromNodeId, keyToArrayIndex, }; |
@@ -16,3 +16,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseAddressFromNodeId = exports.generateMnemonicFromAddress = exports.getStorageNodeRegistryFromContract = exports.createStorageNodeRegistry = exports.StorageNodeRegistry = exports.getTrackerRegistryFromContract = exports.createTrackerRegistry = exports.TrackerRegistry = exports.SigningUtil = exports.CachingStreamMessageValidator = exports.StreamMessageValidator = exports.OrderingUtil = exports.TimestampUtil = void 0; | ||
exports.keyToArrayIndex = exports.parseAddressFromNodeId = exports.generateMnemonicFromAddress = exports.getStorageNodeRegistryFromContract = exports.createStorageNodeRegistry = exports.StorageNodeRegistry = exports.getTrackerRegistryFromContract = exports.createTrackerRegistry = exports.TrackerRegistry = exports.SigningUtil = exports.CachingStreamMessageValidator = exports.StreamMessageValidator = exports.OrderingUtil = exports.TimestampUtil = void 0; | ||
const TimestampUtil_1 = __importDefault(require("./TimestampUtil")); | ||
@@ -40,2 +40,4 @@ exports.TimestampUtil = TimestampUtil_1.default; | ||
Object.defineProperty(exports, "parseAddressFromNodeId", { enumerable: true, get: function () { return NodeUtil_1.parseAddressFromNodeId; } }); | ||
const HashUtil_1 = require("./HashUtil"); | ||
Object.defineProperty(exports, "keyToArrayIndex", { enumerable: true, get: function () { return HashUtil_1.keyToArrayIndex; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -24,10 +24,5 @@ "use strict"; | ||
const ethers_1 = require("ethers"); | ||
const HashUtil_1 = require("./HashUtil"); | ||
const trackerRegistryConfig = __importStar(require("../../contracts/TrackerRegistry.json")); | ||
const { JsonRpcProvider } = ethers_1.providers; | ||
// source: https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript | ||
function hashCode(str) { | ||
const a = str.split('') | ||
.reduce((prevHash, currVal) => (((prevHash << 5) - prevHash) + currVal.charCodeAt(0)) | 0, 0); | ||
return Math.abs(a); | ||
} | ||
class TrackerRegistry { | ||
@@ -46,3 +41,4 @@ constructor(records) { | ||
const streamKey = `${streamId}::${partition}`; | ||
return this.records[hashCode(streamKey) % this.records.length]; | ||
const index = (0, HashUtil_1.keyToArrayIndex)(this.records.length, streamKey); | ||
return this.records[index]; | ||
} | ||
@@ -49,0 +45,0 @@ getAllTrackers() { |
{ | ||
"name": "streamr-client-protocol", | ||
"version": "8.5.0-alpha.0", | ||
"version": "8.5.0-alpha.1", | ||
"description": "JavaScript classes implementing the Streamr client-to-node protocol", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
665492
288
8768