The Aleph's diameter was probably little more than an inch, but all space was there, actual and undiminished. Each thing (a mirror's face, let us say) was infinite things, since I distinctly saw it from every angle of the universe¹
Aleph provides two main components. First is a client for the HTTP API exposed by concat, the reference go peer implementation. Second is a lightweight peer in its own right.
For system-wide Mediachain documentation see https://mediachain.github.io/mediachain-docs.
Aleph requires node 6 or greater, and has primarily been tested with 6.5 and above.
To globally install a release from npm:
npm install --global aleph. This will install the
aleph command, which
provides a remote query command and an interactive REPL for exploring the mediachain network. It also
mcclient command, which you can use to control and interact with a concat node.
If you'd prefer to install from the source repository, clone this repo and run
npm install, followed by
npm link, which will create a
aleph symlinks that run the latest compiled version of the code.
This is very useful during development.
If you don't want
aleph on your path at all, you can just run
npm install and execute
./bin/aleph.js directly instead.
aleph package will install two command line tools:
mcclient is a wrapper around the HTTP API exposed by concat, aleph's heavy-lifting counterpart.
mcclient contains several sub-commands, so the general invocation is
mcclient [global-options] <command> [command-options].
At the moment, the only global option is
-p, which sets the location of the remote node's
HTTP API. By default,
mcclient will attempt to connect to a concat node running on localhost at port 9002,
which is concat's default listen address for the HTTP API. If you've configured concat to run on a different
port or on a remote machine, use the
-p flag to pass in a new URL, e.g.
mcclient -p http://localhost:5678 id
Some useful commands include:
id: print the node's peer id and publisher id
- with no arguments, prints the current status (
- set the status with e.g.
mcclient status online
- with no arguments, prints the current status (
publish: publish JSON metadata to the node's local store. see
mcclient publish --helpfor more info.
statement: retrieve a statement by its id
query: run a mediachain query against the node's local store.
To see a full list of supported commands, run
mcclient is a front-end for the golang peer implementation concat, the
aleph command provides
so it can't be used to provide mediachain data. However,
aleph is useful for interacting with local and remote
concat nodes, and for exploring the mediachain network and peer-to-peer architecture.
There are currently two
aleph repl and
When you start the repl, a new peer identity is created and stored in the
~/.mediachain/aleph directory. You can
override that default with the
node object. This is an instance of the
MediachainNode class, which implements the peer-to-peer
The repl can be used to remotely interact with another node using the mediachain protocol. For example:
א > nodetrue
The long string above is a multiaddr, which is a format
for representing and combining addresses for multiple network protocols. The string above is for
the peer-to-peer node with id
QmeiY2eHMwK92Zt6X4kUUC3MsjMmVb2VnGZ17DhnhRPCEQ, located at the IP4 address
184.108.40.206, on tcp port
/p2p/ protocol identifier is not yet part of the multiaddr standard,
but it is in the works as a replacement for the
/ipfs/ identifier, and we've adopted it in anticipation of it being
integrated into the standard soon.
Let's make our addresses a bit simpler by connecting to the Mediachain Labs directory server:
א > node
Now we can just use the peer identifier portion of the address, and the directory will provide us with the full address behind the scenes:
א > nodetrue
You can also provide the directory server address at the command line when launching the repl:
$ aleph repl --dir /ip4/220.127.116.11/tcp/9000/p2p/QmSdJVceFki4rDbcSrW7JTJZgU9so25Ko7oKHE97mGmkU6
This will set the directory address on startup, and avoid the need for the
Pairing a remote node
Since the aleph repl is at its most useful when interacting with a remote node, there's built-in
To do so, just provide the
--remotePeer flag when launching the repl, and give it a multiaddr where
the peer is located:
$ aleph repl --remotePeer /ip4/18.104.22.168/tcp/9001/p2p/QmeiY2eHMwK92Zt6X4kUUC3MsjMmVb2VnGZ17DhnhRPCEQ
Now, in addition to the global
node object, you also have a
remote object that represents the
א > remotevalue: simple: Object
The query result is printed at the repl in condensed form. To examine it further, we can use the "magic"
which holds the result of the last repl command. Assign it to a new variable, and we can interact with it more easily:
var result = _consoledirresult0valuesimplestmt:id: '4XTTM4K8sqTb7xYviJJcRDJ5W6TpQxMoJ7GtBstTALgh5wzGm:1478267497:1'publisher: '4XTTM4K8sqTb7xYviJJcRDJ5W6TpQxMoJ7GtBstTALgh5wzGm'namespace: 'images.dpla'body:simple:object: 'QmeFJSTPKSEiNqebxZvYcduWH8UBmxqNq724gHEQnxV5D1'refs: 'dpla_1ff6b36174426026847c8f8ca216ffa9'tags:deps: 'QmYGRQYmWC3BAtTAi88mFb7GVeFsUKGM4nm25SBUB9vfc9'timestamp: 1478267497signature:Buffer ...
To also fetch the data objects associated with each result, use
remote.queryWithData instead of
aleph query --remotePeer <peerAddress> <queryString> will execute a query on a remote peer using the peer-to-peer
query protocol. This is very similar to the
mcclient query command, with the exception that the
argument is not optional, since the local aleph node does not have a local datastore.
Mediachain records are composed of two main components: statements and objects. Objects are the core metadata objects that represent a given artwork, person, or other resource. A statement is a mediachain-specific record that contextualizes an object within the mediachain network. For example, the statement includes the namespace in which the record was published, the ids of the publisher, the well-known identifiers attached to the record, etc.
By default, the
aleph query command will only show the statements that match the query results. However, it's
common that you'll want to see the content of the objects themselves.
-i flag to dereference the objects for each statement in the query results.
$ aleph query --remotePeer /ip4/22.214.171.124/tcp/9001/ipfs/QmeiY2eHMwK92Zt6X4kUUC3MsjMmVb2VnGZ17DhnhRPCEQ --includeData 'SELECT * FROM images.dpla LIMIT 1'
Development and contribution
Thanks! We welcome all contributions of ideas, bug reports, code, and whatever else you'd like to send our way. Please take a look at our contributing guidelines -- they are very friendly.
The code lives in
src, and is organized into a few main subdirectories:
RestClientclass, which provides a Promise-based wrapper around concat's HTTP API
client/clicontains the code for the
mcclientcommand line app, which uses
RestClientfor all of its functionality. The cli is powered by the yargs argument parser, and each subcommand is contained in its own module in
DirectoryNodethat corresponds to concat's
mcdircommand, and a
MediachainNodethat corresponds to concat's
mcnode. Both use the
LibP2PNodeclass (defined in src/peer/libp2p_node.js) for low-level peer-to-peer networking.
protobufcontains protocol-buffer definitions for messages exchanged between nodes, and is kept in sync with concat.