Skip to content

Commit

Permalink
chore(deps): upgrade captp
Browse files Browse the repository at this point in the history
Also move some stdout logs to stderr.
  • Loading branch information
michaelfig committed Oct 29, 2019
1 parent 865e598 commit 0a19afd
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 33 deletions.
8 changes: 4 additions & 4 deletions lib/ag-solo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function insistIsBasedir() {
}

export default async function solo(progname, rawArgv) {
console.log('solo', rawArgv);
console.error('solo', rawArgv);
const { _: argv, ...opts } = parseArgs(rawArgv, {
stopEarly: true,
boolean: ['help', 'version'],
Expand Down Expand Up @@ -63,7 +63,7 @@ start
const subdir = subArgs[1];
insist(basedir !== undefined, 'you must provide a BASEDIR');
initBasedir(basedir, webport, webhost, subdir, egresses.split(','));
console.log(`Run '(cd ${basedir} && ${progname} start)' to start the vat machine`);
console.error(`Run '(cd ${basedir} && ${progname} start)' to start the vat machine`);
} else if (argv[0] === 'set-gci-ingress') {
const basedir = insistIsBasedir();
const { _: subArgs, ...subOpts } = parseArgs(argv.slice(1), {});
Expand All @@ -78,7 +78,7 @@ start
} else if (argv[0] === 'upload-contract') {
await uploadContract(insistIsBasedir, argv.slice(1));
} else {
console.log(`unrecognized command ${argv[0]}`);
console.log(`try one of: init, set-gci-ingress, start`);
console.error(`unrecognized command ${argv[0]}`);
console.error(`try one of: init, set-gci-ingress, start`);
}
}
26 changes: 13 additions & 13 deletions lib/ag-solo/upload-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import parseArgs from 'minimist';
import WebSocket from 'ws';
import { E } from '@agoric/eventual-send';
import makeCapTP from '@agoric/captp';
import { makeCapTP } from '@agoric/captp';
import fs from 'fs';
import path from 'path';

Expand Down Expand Up @@ -52,7 +52,7 @@ export default async function upload(insistIsBasedir, args) {
const exit = makePromise();
ws.on('open', async () => {
try {
const [handler, bootstrap] = makeCapTP('upload', obj =>
const { dispatch, getBootstrap } = makeCapTP('upload', obj =>
sendJSON(ws, obj),
);
ws.on('message', data => {
Expand All @@ -62,29 +62,29 @@ export default async function upload(insistIsBasedir, args) {
if (obj.type === 'CTP_ERROR') {
throw obj.error;
}
handler[obj.type](obj);
dispatch(obj);
} catch (e) {
console.log('server error processing message', data, e);
console.error('server error processing message', data, e);
exit.rej(e);
}
});

// Wait for the chain to become ready.
let bootC = E.C(bootstrap());
console.log('Chain loaded:', await bootC.G.LOADING.P);
let bootC = E.C(getBootstrap());
console.error('Chain loaded:', await bootC.G.LOADING.P);
// Take a new copy, since the contract targets should exist.
bootC = E.C(bootstrap());
bootC = E.C(getBootstrap());
if (once) {
if (await bootC.G.READY.M.isReady().P) {
console.log('Contracts already uploaded');
console.error('Contracts already uploaded');
ws.close();
exit.res(0);
return;
}
}
const uploadsC = bootC.G.uploads;

console.log(`Uploading contracts...`);
console.error(`Uploading contracts...`);

const names = [];
const contractsAP = [];
Expand All @@ -97,7 +97,7 @@ export default async function upload(insistIsBasedir, args) {
const target = match[2];
const filepath = match[3];
const { source, moduleFormat } = await buildSourceBundle(filepath);
// console.log(`Uploading ${source}`);
// console.error(`Uploading ${source}`);

const targetObj = await bootC.G[target].P;
if (!targetObj) {
Expand All @@ -106,7 +106,7 @@ export default async function upload(insistIsBasedir, args) {
);
} else {
// Install the contract, then save it in home.uploads.
console.log(`Uploading ${name}`)
console.log(name)
contractsAP.push(E(targetObj).install(source, moduleFormat));
names.push(name);
}
Expand All @@ -117,7 +117,7 @@ export default async function upload(insistIsBasedir, args) {
await uploadsC.M.set(names[i], contracts[i]).P;
}

console.log('Success! See home.uploads~.list()');
console.error('Success! See home.uploads~.list()');
if (once) {
await bootC.G.READY.M.resolve('contracts uploaded').P;
}
Expand All @@ -128,7 +128,7 @@ export default async function upload(insistIsBasedir, args) {
}
});
ws.on('close', (_code, _reason) => {
console.log('connection closed');
// console.log('connection closed');
exit.res(1);
});
return exit.p;
Expand Down
14 changes: 8 additions & 6 deletions lib/ag-solo/vats/vat-http.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import harden from '@agoric/harden';
import makeCapTP from '@agoric/captp';
// Avoid importing the full captp bundle, which would carry
// in its own makeHardener, etc.
import { makeCapTP } from '@agoric/captp/lib/captp';

import { getReplHandler } from './repl';

Expand Down Expand Up @@ -50,15 +52,15 @@ function build(E, D) {
if (ROLES.client) {
const conns = new Map();
const forward = method => obj => {
const handlers = conns.get(obj.connectionID);
if (!handlers || !handlers[method]) {
const dispatch = conns.get(obj.connectionID);
if (!dispatch || !dispatch(obj)) {
console.log(
`Could not find CapTP handler ${method}`,
obj.connectionID,
);
return undefined;
}
return handlers[method](obj);
return true;
};
Object.assign(
handler,
Expand All @@ -77,11 +79,11 @@ function build(E, D) {
o.connectionID = obj.connectionID;
D(commandDevice).sendBroadcast(o);
};
const [handlers] = makeCapTP(obj.connectionID, sendObj, () =>
const { dispatch } = makeCapTP(obj.connectionID, sendObj, () =>
// Harden only our exported objects.
harden(exportedToCapTP),
);
conns.set(obj.connectionID, handlers);
conns.set(obj.connectionID, dispatch);
},
CTP_CLOSE(obj) {
console.log(`Finishing CapTP`, obj.connectionID);
Expand Down
51 changes: 43 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"dependencies": {
"@agoric/acorn-eventual-send": "^1.0.1",
"@agoric/bundle-source": "^0.1.0",
"@agoric/captp": "^0.1.2",
"@agoric/captp": "^1.0.0",
"@agoric/ertp": "^0.1.8",
"@agoric/evaluate": "^2.1.2",
"@agoric/eventual-send": "^0.4.2",
"@agoric/eventual-send": "^0.4.4",
"@agoric/harden": "0.0.4",
"@agoric/swingset-vat": "^0.2.0",
"@iarna/toml": "^2.2.3",
Expand Down

0 comments on commit 0a19afd

Please sign in to comment.