incubed
Version:
Typescript-version of the incubed client
43 lines • 1.95 kB
JavaScript
"use strict";
/***********************************************************
* This file is part of the Slock.it IoT Layer. *
* The Slock.it IoT Layer contains: *
* - USN (Universal Sharing Network) *
* - INCUBED (Trustless INcentivized remote Node Network) *
************************************************************
* Copyright (C) 2016 - 2018 Slock.it GmbH *
* All Rights Reserved. *
************************************************************
* You may use, distribute and modify this code under the *
* terms of the license contract you have concluded with *
* Slock.it GmbH. *
* For information about liability, maintenance etc. also *
* refer to the contract concluded with Slock.it GmbH. *
************************************************************
* For more information, please refer to https://slock.it *
* For questions, please contact info@slock.it *
***********************************************************/
Object.defineProperty(exports, "__esModule", { value: true });
const ethereumjs_util_1 = require("ethereumjs-util");
function canProof(node) {
return (node.props & 0x01) > 0;
}
exports.canProof = canProof;
function canMultiChain(node) {
return (node.props & 0x02) > 0;
}
exports.canMultiChain = canMultiChain;
function createRandomIndexes(len, limit, seed, result = []) {
let step = seed.readUIntBE(0, 6); // first 6 bytes
let pos = seed.readUIntBE(6, 6) % len; // next 6 bytes
while (result.length < limit) {
if (result.indexOf(pos) >= 0)
step = (seed = ethereumjs_util_1.keccak256(seed)).readUIntBE(0, 6);
else
result.push(pos);
pos = (pos + step) % len;
}
return result;
}
exports.createRandomIndexes = createRandomIndexes;
//# sourceMappingURL=serverList.js.map