council

2.0.1 • Public • Published

Council

Fetch suitable hosts for any protocol

council of ricks

Client

const plugin = require('ilp-plugin')()
const council = require('council')({ plugin })

async function run () {
  console.log('hosts for org.codius:', await council('org.codius'))
}

run()

The client will take COUNCIL_HOSTS from the environment (containing a comma-separated list of hosts), or the module can take a second hosts parameter alongside plugin. hosts must be an array.

Server

# Set up two servers; The first server falls back to the second
$ DEBUG=* COUNCIL_CONFIG=../example-config.json COUNCIL_PORT=8002 node ./server/index.js &
$ ILP_CREDENTIALS='{"secret":"spkemkgDWHwZrJ88HNs7xd1wjT6Xu","server":"wss://s.altnet.rippletest.net:51233"}' DEBUG=* COUNCIL_CONFIG=../example-config-2.json COUNCIL_PORT=8001 node ./server/index.js &

$ ilp-curl -X GET localhost:8002/hosts/org.codius
[ { host: 'codius.org', depth: 1 } ]

$ ilp-curl -X GET localhost:8001/hosts/com.sharafian.sms
[ { host: 'twilio.com', depth: 1 },
  { host: 'google.com', depth: 1 } ]

# In this case, server 1 will pay server 2 for its hosts
$ ilp-curl -X GET localhost:8002/hosts/com.sharafian.sms
[ { host: 'twilio.com', depth: 2 },
  { host: 'google.com', depth: 2 } ]

Readme

Keywords

none

Package Sidebar

Install

npm i council

Weekly Downloads

23

Version

2.0.1

License

ISC

Last publish

Collaborators

  • interledger