From 5b6230c5fedb90e46b4d51721e062bf8c6c0f25c Mon Sep 17 00:00:00 2001 From: sentientwaffle Date: Thu, 7 Jan 2016 09:53:36 -0800 Subject: [PATCH] [TASK] bump five-bells-* deps; s/trader/connector --- README.md | 4 ++-- data/README.md | 2 +- package.json | 8 ++++---- scripts/accounts.js | 10 ++++++++-- scripts/create-account.js | 2 +- scripts/send.js | 2 +- src/lib/demo.js | 38 +++++++++++++++++++------------------- src/services/config.js | 6 +++--- 8 files changed, 39 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 3e8a05d..fae9b79 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Visit [`http://localhost:5001`](http://localhost:5001) to see it in action! ### Configuration * `DEMO_NUM_LEDGERS` - Number of [`five-bells-ledger`](https://github.com/interledger/five-bells-ledger) processes to start -* `DEMO_NUM_TRADERS` - Number of [`five-bells-trader`](https://github.com/interledger/five-bells-trader) processes to start +* `DEMO_NUM_CONNECTORS` - Number of [`five-bells-connector`](https://github.com/interledger/five-bells-connector) processes to start * `DEMO_CONNECTED_CORE` - How connected the core ledgers in the generated graph should be (default: 2) * `DEMO_CONNECTIONS_PER_NEW_NODE` - How many connections each ledger will be added with (default: 2, must be <= `DEMO_CONNECTED_CORE`) @@ -55,8 +55,8 @@ In the early 1800s, the group of clerks outgrew their space at the Five Bells an This demo uses the following modules: +* [`five-bells-connector`](https://github.com/interledger/five-bells-connector) * [`five-bells-ledger`](https://github.com/interledger/five-bells-ledger) -* [`five-bells-trader`](https://github.com/interledger/five-bells-trader) * [`five-bells-sender`](https://github.com/interledger/five-bells-sender) * [`five-bells-visualization`](https://github.com/interledger/five-bells-visualization) diff --git a/data/README.md b/data/README.md index 0aa629b..485ced2 100644 --- a/data/README.md +++ b/data/README.md @@ -2,4 +2,4 @@ This folder is reserved for data files created by the running demo. These files will automatically be deleted on every run. -Currently, if these files are not deleted between runs, ledgers will have trader accounts from previous runs which are no longer active. These can impair or slow down the pathfinding. +Currently, if these files are not deleted between runs, ledgers will have connector accounts from previous runs which are no longer active. These can impair or slow down the pathfinding. diff --git a/package.json b/package.json index 1a9f68f..a0a86fc 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,10 @@ "node": ">=4.0.0" }, "dependencies": { - "five-bells-ledger": "~5.0.0", - "five-bells-sender": "~3.0.0", - "five-bells-trader": "~1.0.1", - "five-bells-visualization": "~2.0.0", + "five-bells-connector": "~1.1.0", + "five-bells-ledger": "~5.1.1", + "five-bells-sender": "~3.1.0", + "five-bells-visualization": "~2.1.0", "co": "^4.6.0", "co-request": "^1.0.0", "lodash": "^3.10.1", diff --git a/scripts/accounts.js b/scripts/accounts.js index f6a4159..d4f72c0 100755 --- a/scripts/accounts.js +++ b/scripts/accounts.js @@ -16,11 +16,17 @@ co(function * () { let ledgers = yield pathfinder.getLedgers() console.log('Ledger\tAccount\tBalance') for (let ledger of ledgers) { - let accounts = yield request(ledger.uri + '/accounts', {json: true}) + let accounts = yield request(ledger.uri + '/accounts', { + auth: {user: 'admin', pass: 'admin'}, + json: true + }) + if (accounts.statusCode !== 200) { + throw new Error('Unexpected /accounts error: ' + accounts.statusCode + ' ' + JSON.stringify(accounts.body)) + } for (let account of accounts.body) { console.log( getPort(ledger.uri) + '\t' + - getName(account.id) + '\t' + + getName(account.name) + '\t' + account.balance) } } diff --git a/scripts/create-account.js b/scripts/create-account.js index 7c0e2ae..8d82f0b 100755 --- a/scripts/create-account.js +++ b/scripts/create-account.js @@ -41,7 +41,7 @@ function * createAccount (ledger, name) { auth: { user: adminUser, pass: adminPass }, json: true, body: { - name: account_uri, + name: name, password: name, balance: '1500000' } diff --git a/scripts/send.js b/scripts/send.js index d7e2489..c5f57ad 100755 --- a/scripts/send.js +++ b/scripts/send.js @@ -2,7 +2,7 @@ 'use strict' const co = require('co') -const send = require('five-bells-sender') +const send = require('five-bells-sender').default const argv = process.argv.slice(2) if (argv.length !== 2) { diff --git a/src/lib/demo.js b/src/lib/demo.js index f19e540..ae05116 100644 --- a/src/lib/demo.js +++ b/src/lib/demo.js @@ -3,7 +3,7 @@ const path = require('path') const randomgraph = require('randomgraph') -const traderNames = [ +const connectorNames = [ 'mark', 'mary', 'martin', 'millie', 'mia', 'mike', 'mesrop', 'michelle', 'milo', 'miles', 'michael', 'micah', 'max' @@ -24,11 +24,11 @@ class Demo { this.adminPass = opts.adminPass this.numLedgers = opts.numLedgers - this.numTraders = opts.numTraders + this.numConnectors = opts.numConnectors this.barabasiAlbertConnectedCore = opts.barabasiAlbertConnectedCore || 2 this.barabasiAlbertConnectionsPerNewNode = opts.barabasiAlbertConnectionsPerNewNode || 2 - // Trader graph + // Connector graph // Barabási–Albert (N, m0, M) // // N .. number of nodes @@ -38,16 +38,16 @@ class Demo { this.numLedgers, this.barabasiAlbertConnectedCore, this.barabasiAlbertConnectionsPerNewNode) - this.traderEdges = new Array(this.numTraders) - for (let i = 0; i < this.numTraders; i++) { - this.traderEdges[i] = [] + this.connectorEdges = new Array(this.numConnectors) + for (let i = 0; i < this.numConnectors; i++) { + this.connectorEdges[i] = [] } this.graph.edges.forEach(function (edge, i) { edge.source_currency = currencies[edge.source % currencies.length] edge.target_currency = currencies[edge.target % currencies.length] edge.source = 'http://localhost:' + (3001 + edge.source) edge.target = 'http://localhost:' + (3001 + edge.target) - _this.traderEdges[i % _this.numTraders].push(edge) + _this.connectorEdges[i % _this.numConnectors].push(edge) }) } @@ -78,7 +78,7 @@ class Demo { } } - createTrader (name, port, edges) { + createConnector (name, port, edges) { let creds = {} let pairs = [] for (let edge of edges) { @@ -96,19 +96,19 @@ class Demo { return { env: { - TRADER_CREDENTIALS: JSON.stringify(creds), - TRADER_DEBUG_AUTOFUND: '1', + CONNECTOR_CREDENTIALS: JSON.stringify(creds), + CONNECTOR_DEBUG_AUTOFUND: '1', TRADING_PAIRS: JSON.stringify(pairs), - TRADER_MAX_HOLD_TIME: 60, + CONNECTOR_MAX_HOLD_TIME: 60, PATH: process.env.PATH, - TRADER_HOSTNAME: 'localhost', - TRADER_PORT: port, - TRADER_ADMIN_USER: this.adminUser, - TRADER_ADMIN_PASS: this.adminPass + CONNECTOR_HOSTNAME: 'localhost', + CONNECTOR_PORT: port, + CONNECTOR_ADMIN_USER: this.adminUser, + CONNECTOR_ADMIN_PASS: this.adminPass }, - cwd: './node_modules/five-bells-trader', + cwd: './node_modules/five-bells-connector', cmd: 'npm start -- --color', - alias: 'trader-' + name + alias: 'connector-' + name } } @@ -155,8 +155,8 @@ class Demo { accounts.push(this.createAccount('http://localhost:' + port, 'bob')) } - for (let i = 0; i < this.numTraders; i++) { - processes.push(this.createTrader(traderNames[i] || 'trader' + i, 4001 + i, this.traderEdges[i])) + for (let i = 0; i < this.numConnectors; i++) { + processes.push(this.createConnector(connectorNames[i] || 'connector' + i, 4001 + i, this.connectorEdges[i])) } multiplexer(processes.concat([ diff --git a/src/services/config.js b/src/services/config.js index 6fb6f4e..3f29b8a 100644 --- a/src/services/config.js +++ b/src/services/config.js @@ -2,7 +2,7 @@ exports.graph = { numLedgers: 8, - numTraders: 7, + numConnectors: 7, barabasiAlbertConnectedCore: 2, barabasiAlbertConnectionsPerNewNode: 2, adminUser: process.env.ADMIN_USER || 'admin', @@ -13,8 +13,8 @@ if (process.env.DEMO_NUM_LEDGERS) { exports.graph.numLedgers = parseInt(process.env.DEMO_NUM_LEDGERS, 10) } -if (process.env.DEMO_NUM_TRADERS) { - exports.graph.numTraders = parseInt(process.env.DEMO_NUM_TRADERS, 10) +if (process.env.DEMO_NUM_CONNECTORS) { + exports.graph.numConnectors = parseInt(process.env.DEMO_NUM_CONNECTORS, 10) } // A higher number here will result in more highly connected central ledgers