feat: Rename krasnodar to kras. Add functions to pick random nodes (#4)

This commit is contained in:
Pavel 2023-02-16 11:21:43 +03:00 committed by GitHub
parent f573a0b44d
commit a65217fd2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 96 additions and 51 deletions

View File

@ -33,7 +33,7 @@ Which can be used to initialize the Fluence client (see [Fluence JS SDK](https:/
```typescript ```typescript
import { FluencePeer } from '@fluencelabs/fluence'; import { FluencePeer } from '@fluencelabs/fluence';
const peer = new FluencePeer; const peer = new FluencePeer();
await peer.start({ connectTo: relayNode }); await peer.start({ connectTo: relayNode });
``` ```
@ -41,18 +41,17 @@ await peer.start({ connectTo: relayNode });
- stage - unstable network for development tests; low capacity - stage - unstable network for development tests; low capacity
- TestNet - more stable network, used for QA of new releases; higher capacity - TestNet - more stable network, used for QA of new releases; higher capacity
- Krasnodar - stable network, has the highest load capacity - Kras - stable network, has the highest load capacity
All 3 networks are connected, i.e. any node can be discovered from every other. They're open and permissionless, meaning that anyone can use any node for bootstrapping. All 3 networks are connected, i.e. any node can be discovered from every other. They're open and permissionless, meaning that anyone can use any node for bootstrapping.
## Fluence Stack ## Fluence Stack
| Layer | Tech | Scale | State | Based on | | Layer | Tech | Scale | State | Based on |
| :-------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------: | :-------------------------------: | :--------------------------------------------------------: | | :-------------------: | :-------------------------------------------------------------------------------------------------------------------------------: | :------------------------------: | :-------------------------------: | :-----------------------------------------------------------------------------------------------------------: |
| Execution | [Marine](https://github.com/fluencelabs/marine) | Single peer | Disk, network, external processes | Wasm, [IT](https://github.com/fluencelabs/interface-types), [Wasmer*](https://github.com/fluencelabs/wasmer) | | Execution | [Marine](https://github.com/fluencelabs/marine) | Single peer | Disk, network, external processes | Wasm, [IT](https://github.com/fluencelabs/interface-types), [Wasmer\*](https://github.com/fluencelabs/wasmer) |
| Composition | [Aqua](https://github.com/fluencelabs/aqua) | Involved peers | Results and signatures | ⇅, π-calculus | | Composition | [Aqua](https://github.com/fluencelabs/aqua) | Involved peers | Results and signatures | ⇅, π-calculus |
| Topology | [TrustGraph](https://github.com/fluencelabs/fluence/tree/master/trust-graph), [DHT*](https://github.com/fluencelabs/rust-libp2p) | Distributed with Kademlia* algo | Actual state of the network | [libp2p](https://github.com/libp2p/rust-libp2p) | | Topology | [TrustGraph](https://github.com/fluencelabs/fluence/tree/master/trust-graph), [DHT\*](https://github.com/fluencelabs/rust-libp2p) | Distributed with Kademlia\* algo | Actual state of the network | [libp2p](https://github.com/libp2p/rust-libp2p) |
| Security & Accounting | Blockchain | Whole network | Licenses & payments | substrate? | | Security & Accounting | Blockchain | Whole network | Licenses & payments | substrate? |
<br/> <br/>
@ -61,7 +60,6 @@ All 3 networks are connected, i.e. any node can be discovered from every other.
<img alt="aquamarine scheme" align="center" src="doc/image.png"/> <img alt="aquamarine scheme" align="center" src="doc/image.png"/>
</p> </p>
## License ## License
[Apache 2.0](https://github.com/fluencelabs/fluence/blob/trustless_computing/LICENSE.md) [Apache 2.0](https://github.com/fluencelabs/fluence/blob/trustless_computing/LICENSE.md)

29
package-lock.json generated
View File

@ -1,8 +1,31 @@
{ {
"name": "fluence-network-environment", "name": "@fluencelabs/fluence-network-environment",
"version": "0.1.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": {
"": {
"name": "@fluencelabs/fluence-network-environment",
"version": "1.0.0",
"license": "Apache-2.0",
"devDependencies": {
"typescript": "3.9.5"
}
},
"node_modules/typescript": {
"version": "3.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.5.tgz",
"integrity": "sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
}
},
"dependencies": { "dependencies": {
"typescript": { "typescript": {
"version": "3.9.5", "version": "3.9.5",

View File

@ -74,49 +74,73 @@ export const testNet: Node[] = [
}, },
]; ];
export const krasnodar: Node[] = [ export const kras: Node[] = [
{ {
multiaddr: '/dns4/kras-00.fluence.dev/tcp/19990/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e', multiaddr: '/dns4/kras-00.fluence.dev/tcp/19990/wss/p2p/12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e',
peerId:'12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e' peerId: '12D3KooWSD5PToNiLQwKDXsu8JSysCwUt8BVUJEqCHcDe7P5h45e',
}, },
{ {
multiaddr: '/dns4/kras-00.fluence.dev/tcp/19001/wss/p2p/12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51', multiaddr: '/dns4/kras-00.fluence.dev/tcp/19001/wss/p2p/12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51',
peerId:'12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51' peerId: '12D3KooWR4cv1a8tv7pps4HH6wePNaK6gf1Hww5wcCMzeWxyNw51',
}, },
{ {
multiaddr: '/dns4/kras-01.fluence.dev/tcp/19001/wss/p2p/12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA', multiaddr: '/dns4/kras-01.fluence.dev/tcp/19001/wss/p2p/12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA',
peerId:'12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA' peerId: '12D3KooWKnEqMfYo9zvfHmqTLpLdiHXPe4SVqUWcWHDJdFGrSmcA',
}, },
{ {
multiaddr: '/dns4/kras-02.fluence.dev/tcp/19001/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf', multiaddr: '/dns4/kras-02.fluence.dev/tcp/19001/wss/p2p/12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf',
peerId:'12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf' peerId: '12D3KooWHLxVhUQyAuZe6AHMB29P7wkvTNMn7eDMcsqimJYLKREf',
}, },
{ {
multiaddr: '/dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE', multiaddr: '/dns4/kras-03.fluence.dev/tcp/19001/wss/p2p/12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE',
peerId:'12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE' peerId: '12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE',
}, },
{ {
multiaddr: '/dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi', multiaddr: '/dns4/kras-04.fluence.dev/tcp/19001/wss/p2p/12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi',
peerId:'12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi' peerId: '12D3KooWFEwNWcHqi9rtsmDhsYcDbRUCDXH84RC4FW6UfsFWaoHi',
}, },
{ {
multiaddr: '/dns4/kras-05.fluence.dev/tcp/19001/wss/p2p/12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS', multiaddr: '/dns4/kras-05.fluence.dev/tcp/19001/wss/p2p/12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS',
peerId:'12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS' peerId: '12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS',
}, },
{ {
multiaddr: '/dns4/kras-06.fluence.dev/tcp/19001/wss/p2p/12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr', multiaddr: '/dns4/kras-06.fluence.dev/tcp/19001/wss/p2p/12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr',
peerId:'12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr' peerId: '12D3KooWDUszU2NeWyUVjCXhGEt1MoZrhvdmaQQwtZUriuGN1jTr',
}, },
{ {
multiaddr: '/dns4/kras-07.fluence.dev/tcp/19001/wss/p2p/12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn', multiaddr: '/dns4/kras-07.fluence.dev/tcp/19001/wss/p2p/12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn',
peerId:'12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn' peerId: '12D3KooWEFFCZnar1cUJQ3rMWjvPQg6yMV2aXWs2DkJNSRbduBWn',
}, },
{ {
multiaddr: '/dns4/kras-08.fluence.dev/tcp/19001/wss/p2p/12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt', multiaddr: '/dns4/kras-08.fluence.dev/tcp/19001/wss/p2p/12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt',
peerId:'12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt' peerId: '12D3KooWFtf3rfCDAfWwt6oLZYZbDfn9Vn7bv7g6QjjQxUUEFVBt',
}, },
{ {
multiaddr: '/dns4/kras-09.fluence.dev/tcp/19001/wss/p2p/12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm', multiaddr: '/dns4/kras-09.fluence.dev/tcp/19001/wss/p2p/12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm',
peerId:'12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm' peerId: '12D3KooWD7CvsYcpF9HE9CCV9aY3SJ317tkXVykjtZnht2EbzDPm',
} },
]; ];
// for backward compatibility
export const krasnodar = kras;
export const randomKras = () => {
return randomItem(kras);
};
export const randomTestNet = () => {
return randomItem(testNet);
};
export const randomStage = () => {
return randomItem(stage);
};
function randomItem(arr: Node[]) {
const index = randomInt(0, arr.length);
return arr[index];
}
function randomInt(min: number, max: number) {
return Math.floor(Math.random() * (max - min)) + min;
}