Skip to content

Update for 'Troupe/dev' branch #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions examples/network/echo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ids/
aliases.json
13 changes: 8 additions & 5 deletions examples/network/echo/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
MKID=node $(TROUPE)/rt/built/p2p/mkid.js
MKID=node $(TROUPE)/rt/built/p2p/mkid.mjs
MKALIASES=node $(TROUPE)/rt/built/p2p/mkaliases.js
START=$(TROUPE)/bin/network.sh
START=$(TROUPE)/network.sh

echo-server:

$(START) echo-server.trp --id=ids/echo-server.json # --debug --debugp2p

echo-client:
$(START) echo-client.trp --id=ids/echo-client.json --aliases=aliases.json --debug --debugp2p
$(START) echo-client.trp --id=ids/echo-client.json --aliases=aliases.json # --debug --debugp2p

create-network-identifiers:
mkdir -p ids
mkdir -p ids
$(MKID) --outfile=ids/echo-server.json
$(MKID) --outfile=ids/echo-client.json
$(MKALIASES) --include ids/echo-server.json --include ids/echo-client.json --outfile aliases.json

remove-network-identifiers:
rm -rf ids
rm -f aliases.json
8 changes: 5 additions & 3 deletions examples/network/echo/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Echo example

1. *First-time only* Run `make create-network-identifiers`. This command will create two network identifiers in the local subdirectory `ids/`, and an alias file with the generated identifiers.
1. *First-time only* Run `make create-network-identifiers`. This command will
create two network identifiers in the local subdirectory `ids/`, and an alias
file with the generated identifiers.

2. Run the server by running `make echo-server`
3. Open another terminal window and run the client by command `make echo-client`
2. Run the server by running `make echo-server`

3. Open another terminal window and run the client by command `make echo-client`
1 change: 0 additions & 1 deletion examples/network/echo/aliases.json

This file was deleted.

6 changes: 6 additions & 0 deletions examples/network/pingpong/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
package-lock.json

ids/
aliases.json
trustmap.json
21 changes: 14 additions & 7 deletions examples/network/pingpong/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
MKID=node $(TROUPE)/rt/built/p2p/mkid.js
MKID=node $(TROUPE)/rt/built/p2p/mkid.mjs
MKALIASES=node $(TROUPE)/rt/built/p2p/mkaliases.js
START=$(TROUPE)/bin/network.sh
START=$(TROUPE)/network.sh

zero.listener:
$(START) zero.trp --id=ids/pingpong-listener.json --rspawn=true --aliases=aliases.json --debug --debugp2p
listener:
$(START) zero.trp --id=ids/pingpong-listener.json --aliases=aliases.json --rspawn=true --trustmap=trustmap.json # --debug --debugp2p

pingpong.dialer:
$(START) p2ppingpong.trp --id=ids/pingpong-dialer.json --aliases=aliases.json # --debug --debugp2p
dialer:
$(START) p2ppingpong.trp --id=ids/pingpong-dialer.json --aliases=aliases.json # --debug --debugp2p

create-network-identifiers:
mkdir -p ids
mkdir -p ids
$(MKID) --outfile=ids/pingpong-listener.json
$(MKID) --outfile=ids/pingpong-dialer.json
$(MKALIASES) --include ids/pingpong-listener.json --include ids/pingpong-dialer.json --outfile aliases.json
npm install
node mktrustmap.mjs --infile aliases.json --outfile trustmap.json

remove-network-identifiers:
rm -rf ids
rm -f aliases.json
rm -f trustmap.json
11 changes: 11 additions & 0 deletions examples/network/pingpong/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ping-Pong example

1. *First-time only* Run `make create-network-identifiers`. This command will
create two network identifiers in the local subdirectory `ids/`, and an alias
file with the generated identifiers.

2. Run the Job Listener node, i.e. whereto remotely spawn a `pingpong` instance,
by running the command `make listener`.

3. Open another terminal window and run the Job Dialer, which sets up the two
instances of `pingpong`, with command `make dialer`.
1 change: 0 additions & 1 deletion examples/network/pingpong/aliases.json

This file was deleted.

19 changes: 19 additions & 0 deletions examples/network/pingpong/mktrustmap.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

import * as fs from 'node:fs';
import pkg from 'yargs';
const { argv } = pkg;

(async () => {
let trustmap = [];
const aliases_json = JSON.parse(fs.readFileSync(argv.infile, 'utf-8').toString());
for (let alias_key in aliases_json) {
trustmap.push({
level: '#TOP',
id: aliases_json[alias_key]
});
}

const outfile = argv.outfile;
fs.writeFile(outfile, JSON.stringify(trustmap), x => console.log(x));
})();
14 changes: 14 additions & 0 deletions examples/network/pingpong/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "pingpong",
"version": "1.0.0",
"description": "",
"main": "mktrustmap.mjs",
"author": "",
"license": "ISC",
"dependencies": {
"yargs": "^15.3.1"
},
"devDependencies": {
"@types/yargs": "^15.0.4"
}
}