Skip to content

Commit

Permalink
[TASK] bump five-bells-* deps; s/trader/connector
Browse files Browse the repository at this point in the history
  • Loading branch information
sentientwaffle committed Jan 7, 2016
1 parent e80dd9e commit 5b6230c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 33 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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`)

Expand All @@ -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)

2 changes: 1 addition & 1 deletion data/README.md
Expand Up @@ -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.
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions scripts/accounts.js
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-account.js
Expand Up @@ -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'
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/send.js
Expand Up @@ -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) {
Expand Down
38 changes: 19 additions & 19 deletions src/lib/demo.js
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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)
})
}

Expand Down Expand Up @@ -78,7 +78,7 @@ class Demo {
}
}

createTrader (name, port, edges) {
createConnector (name, port, edges) {
let creds = {}
let pairs = []
for (let edge of edges) {
Expand All @@ -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
}
}

Expand Down Expand Up @@ -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([
Expand Down
6 changes: 3 additions & 3 deletions src/services/config.js
Expand Up @@ -2,7 +2,7 @@

exports.graph = {
numLedgers: 8,
numTraders: 7,
numConnectors: 7,
barabasiAlbertConnectedCore: 2,
barabasiAlbertConnectionsPerNewNode: 2,
adminUser: process.env.ADMIN_USER || 'admin',
Expand All @@ -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
Expand Down

0 comments on commit 5b6230c

Please sign in to comment.