dcp-client 4.2.19 → 4.2.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dcp-client",
3
- "version": "4.2.19",
3
+ "version": "4.2.20",
4
4
  "description": "Core libraries for accessing DCP network",
5
5
  "keywords": [
6
6
  "dcp"
@@ -1,17 +0,0 @@
1
- <html>
2
- <head>
3
- <meta charset="utf-8"/>
4
- <script src="../../../bravojs/bravo.js"></script>
5
- <script src="../../dcp-client.js" scheduler="http://scheduler.distributed.computer"></script>
6
- </head>
7
- <body>
8
- Hello, world
9
- </body>
10
- <script>
11
- console.log('main module below');
12
- module.declare([], function mainModuleScope(require, exports, module)
13
- {
14
- alert('main module loaded');
15
- });
16
- </script>
17
- </html>
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @file events.js
5
- * Sample BravoJS + Web main module showing how to deploy a DCP job whilst receiving
6
- * events describing the current state of the job, processing results
7
- * as they are received, and so on.
8
- *
9
- * Note: Your keystore should be placed in your home directory in .dcp/default.keystore.
10
- * When using the dcp-client API in NodeJS, this keystore will be used for communicating over DCP.
11
- *
12
- * @author Wes Garland, wes@kingsds.network
13
- * @date Aug 2019, April 2020
14
- */
15
-
16
- const SCHEDULER_URL = new URL('https://scheduler.distributed.computer');
17
-
18
- /** Main program entry point */
19
- async function main() {
20
- const compute = require('dcp/compute');
21
- const wallet = require('dcp/wallet');
22
- let startTime;
23
-
24
- const job = compute.for(
25
- ['red', 'green', 'yellow', 'blue', 'brown', 'orange', 'pink'],
26
- (colour) => {
27
- progress(0);
28
- let sum = 0;
29
- for (let i = 0; i < 10000000; i += 1) {
30
- progress(i / 10000000);
31
- sum += Math.random();
32
- }
33
- return { colour, sum };
34
- },
35
- );
36
-
37
- job.on('accepted', () => {
38
- console.log(` - Job accepted by scheduler, waiting for results`);
39
- console.log(` - Job has id ${job.id}`);
40
- startTime = Date.now();
41
- });
42
-
43
- job.on('readystatechange', (arg) => {
44
- console.log(`new ready state: ${arg}`);
45
- });
46
-
47
- job.on('result', (ev) => {
48
- console.log(
49
- ` - Received result for slice ${ev.sliceNumber} at ${
50
- Math.round((Date.now() - startTime) / 100) / 10
51
- }s`,
52
- );
53
- console.log(` * Wow! ${ev.result.colour} is such a pretty colour!`);
54
- });
55
-
56
- job.public.name = 'events example, nodejs';
57
-
58
- const ks = await wallet.get(); /* usually loads ~/.dcp/default.keystore */
59
- job.setPaymentAccountKeystore(ks);
60
- const results = await job.exec(compute.marketValue);
61
- console.log('results=', Array.from(results));
62
- }
63
-
64
- /* Initialize DCP Client and run main() */
65
- require('../..')
66
- .init(SCHEDULER_URL)
67
- .then(main)
68
- .catch(console.error)
69
- .finally(process.exit);
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @file events.js
5
- * Sample node application showing how to deploy a DCP job whilst receiving
6
- * events describing the current state of the job, processing results
7
- * as they are received, and so on.
8
- *
9
- * Note: Your keystore should be placed in your home directory in .dcp/default.keystore.
10
- * When using the dcp-client API in NodeJS, this keystore will be used for communicating over DCP.
11
- *
12
- * @author Wes Garland, wes@kingsds.network
13
- * @date Aug 2019, April 2020
14
- */
15
-
16
- const SCHEDULER_URL = new URL('https://scheduler.distributed.computer');
17
-
18
- /** Main program entry point */
19
- async function main() {
20
- const compute = require('dcp/compute');
21
- const wallet = require('dcp/wallet');
22
- let startTime;
23
-
24
- const job = compute.for(
25
- ['red', 'green', 'yellow', 'blue', 'brown', 'orange', 'pink'],
26
- (colour) => {
27
- progress(0);
28
- let sum = 0;
29
- for (let i = 0; i < 10000000; i += 1) {
30
- progress(i / 10000000);
31
- sum += Math.random();
32
- }
33
- return { colour, sum };
34
- },
35
- );
36
-
37
- job.on('accepted', () => {
38
- console.log(` - Job accepted by scheduler, waiting for results`);
39
- console.log(` - Job has id ${job.id}`);
40
- startTime = Date.now();
41
- });
42
-
43
- job.on('readystatechange', (arg) => {
44
- console.log(`new ready state: ${arg}`);
45
- });
46
-
47
- job.on('result', (ev) => {
48
- console.log(
49
- ` - Received result for slice ${ev.sliceNumber} at ${
50
- Math.round((Date.now() - startTime) / 100) / 10
51
- }s`,
52
- );
53
- console.log(` * Wow! ${ev.result.colour} is such a pretty colour!`);
54
- });
55
-
56
- job.public.name = 'events example, nodejs';
57
-
58
- const ks = await wallet.get(); /* usually loads ~/.dcp/default.keystore */
59
- job.setPaymentAccountKeystore(ks);
60
- const results = await job.exec(compute.marketValue);
61
- console.log('results=', Array.from(results));
62
- }
63
-
64
- /* Initialize DCP Client and run main() */
65
- require('../..')
66
- .init(SCHEDULER_URL)
67
- .then(main)
68
- .catch(console.error)
69
- .finally(process.exit);
@@ -1,16 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <script src="http://scheduler.wes.office.kingsds.network/dcp-client/dcp-client.js" dcpConfig="https://scheduler.distributed.computer/etc/dcp-config.js"></script>
6
- <script>
7
- async function start()
8
- {
9
- a = await dcp.wallet.getId();
10
- }
11
- </script>
12
- </head>
13
- <body onload="start()">
14
- <h2>wait for it</h2>
15
- </body>
16
- </html>
package/startrek.js~ DELETED
@@ -1,60 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('.').init().then(main).then(process.exit);
4
-
5
- async function main() {
6
- const compute = require('dcp/compute');
7
-
8
- let inputSet = [
9
- 'picard:human',
10
- 'geordi:human',
11
- 'riker:human',
12
- 'data:android',
13
- 'hugh:borg',
14
- 'guinan:el-aurian',
15
- 'q:q'
16
- ];
17
-
18
- console.log('scheduler: ', require('dcp/dcp-config').scheduler.location.href);
19
-
20
- function sameSpecies(character1, character2)
21
- {
22
- var [name1, species1] = character1;
23
- var [name2, species2] = character2;
24
-
25
- progress(0);
26
- if (species1 === species2)
27
- return `${name1} and ${name2} are both ${species1}s`;
28
- else
29
- return `${name1} and ${name2} are not the same species`;
30
- }
31
-
32
- async function checkSameSpecies(who)
33
- {
34
- const job = compute.for(inputSet, sameSpecies, [who]);
35
- job.on('accepted', () => {
36
- console.log(` - Job accepted by scheduler, waiting for results`);
37
- console.log(` - Job has id ${job.id}`);
38
- startTime = Date.now();
39
- });
40
-
41
- job.on('readystatechange', (arg) => {
42
- console.log(`new ready state: ${arg}`);
43
- });
44
-
45
- job.on('console', (ev) => console[ev.level](ev.message));
46
- job.on('result', (ev) => {
47
- console.log(`${ev.result}`);
48
- });
49
-
50
- job.public.name = 'ST:TNG Species Comparator';
51
- job.public.description = 'StarDate ' + (new Date()).toString();
52
- // job.computeGroups = [{joinSecret: 'wes', joinKey: 'wes'}];
53
-
54
- return job.exec();
55
- }
56
-
57
- await checkSameSpecies('wesley:human');
58
- await checkSameSpecies('lore:android');
59
- await checkSameSpecies('7 of 9:borg');
60
- }