# א
[![npm version](https://badge.fury.io/js/aleph.svg)](https://badge.fury.io/js/aleph)
[![Travis CI](https://travis-ci.org/mediachain/aleph.svg?branch=master)](https://travis-ci.org/mediachain/aleph.svg?branch=master)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
[![Coverage Status](https://coveralls.io/repos/github/mediachain/aleph/badge.svg?branch=master)](https://coveralls.io/github/mediachain/aleph?branch=master)
*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 is part of the [mediachain](http://mediachain.io) project and is an integral component of the
[Phase II architecture](https://blog.mediachain.io/looking-backwards-looking-forwards-9149bf00f876#.kkym75h9h).
Aleph provides two main components. First is a client for the HTTP API exposed by
[concat][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.
## Installation
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
installs the `mcclient` command, which you can use to control and interact with a [concat][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 `mcclient` and `aleph` symlinks that run the latest compiled version of the code.
This is very useful during development.
If you don't want `mcclient` or `aleph` on your path at all, you can just run `npm install` and execute
`./bin/mcclient.js` and `./bin/aleph.js` directly instead.
## Usage
Installing the `aleph` package will install two command line tools: `mcclient` and `aleph`.
### `mcclient`
`mcclient` is a wrapper around the HTTP API exposed by [concat][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 `--apiUrl` or `-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
- `status`:
- with no arguments, prints the current status (`online`, `offline`, or `public`)
- set the status with e.g. `mcclient status online`
- `publish`: publish JSON metadata to the node's local store. see `mcclient publish --help` for 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 --help`
### `aleph`
While `mcclient` is a front-end for the golang peer implementation [concat][concat], the `aleph` command provides
access to the javascript peer implementation. The two are interoperable, but they do not have
feature parity. Most notably, the javascript peer has no local storage for mediachain statements or data objects,
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` subcommands, `aleph repl` and `aleph query`
#### `aleph repl`
The `aleph repl` command provides an interactive Read-Eval-Print-Loop for controlling a javascript mediachain node.
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 `--identityPath` flag.
The repl provides a javascript prompt, and a global `node` object. This is an instance of the
[`MediachainNode` class](https://github.com/mediachain/aleph/src/peer/node.js), which implements the peer-to-peer
protocols.
The repl can be used to remotely interact with another node using the mediachain protocol.
For example:
```javascript
א > node.ping('/ip4/54.205.184.122/tcp/9001/p2p/QmeiY2eHMwK92Zt6X4kUUC3MsjMmVb2VnGZ17DhnhRPCEQ')
true
```
The long string above is a [multiaddr](https://github.com/multiformats/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
`54.205.184.122`, on tcp port `9001`. The `/p2p/` protocol identifier is not yet part of the multiaddr standard,
but it is [in the works](https://github.com/multiformats/multiaddr/pull/27) 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:
```javascript
א > node.setDirectory('/ip4/52.7.126.237/tcp/9000/p2p/QmSdJVceFki4rDbcSrW7JTJZgU9so25Ko7oKHE97mGmkU6')
```
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:
```javascript
א > node.ping('QmeiY2eHMwK92Zt6X4kUUC3MsjMmVb2VnGZ17DhnhRPCEQ')
true
```
You can also provide the directory server address at the command line when launching the repl:
```bash
$ aleph repl --dir /ip4/52.7.126.237/tcp/9000/p2p/QmSdJVceFki4rDbcSrW7JTJZgU9so25Ko7oKHE97mGmkU6
```
This will set the directory address on startup, and avoid the need for the `node.setDirectory` call.
##### Pairing a remote node
Since the aleph repl is at its most useful when interacting with a remote node, there's built-in
support for "pairing" the javascript aleph node to a remote node (most likely a `concat` node).
To do so, just provide the `--remotePeer` flag when launching the repl, and give it a multiaddr where
the peer is located:
```bash
$ aleph repl --remotePeer /ip4/54.205.184.122/tcp/9001/p2p/QmeiY2eHMwK92Zt6X4kUUC3MsjMmVb2VnGZ17DhnhRPCEQ
```
Now, in addition to the global `node` object, you also have a `remote` object that represents the
remote peer.
```javascript
א > remote.query('SELECT * FROM images.dpla LIMIT 1')
[ { value: { simple: [Object] } } ]
```
The query result is printed at the repl in condensed form. To examine it further, we can use the "magic" `_` variable,
which holds the result of the last repl command. Assign it to a new variable, and we can interact with it more easily:
```javascript
var result = _
console.dir(result[0].value.simple)
{ stmt:
{ id: '4XTTM4K8sqTb7xYviJJcRDJ5W6TpQxMoJ7GtBstTALgh5wzGm:1478267497:1',
publisher: '4XTTM4K8sqTb7xYviJJcRDJ5W6TpQxMoJ7GtBstTALgh5wzGm',
namespace: 'images.dpla',
body:
{ simple:
{ object: 'QmeFJSTPKSEiNqebxZvYcduWH8UBmxqNq724gHEQnxV5D1',
refs: [ 'dpla_1ff6b36174426026847c8f8ca216ffa9' ],
tags: [],
deps: [ 'QmYGRQYmWC3BAtTAi88mFb7GVeFsUKGM4nm25SBUB9vfc9' ] } },
timestamp: 1478267497,
signature:
Buffer [...] } }
```
To also fetch the data objects associated with each result, use `remote.queryWithData` instead of `remote.query`.
#### `aleph query`
`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`
没有合适的资源?快使用搜索试试~ 我知道了~
א:媒体链宇宙操纵引擎___下载.zip
共184个文件
js:119个
id:20个
sh:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 81 浏览量
2023-04-05
13:03:03
上传
评论
收藏 238KB ZIP 举报
温馨提示
א:媒体链宇宙操纵引擎___下载.zip
资源推荐
资源详情
资源评论
收起资源包目录
א:媒体链宇宙操纵引擎___下载.zip (184个子文件)
.babelrc 144B
Dockerfile 710B
Dockerfile 537B
Dockerfile 460B
.dockerignore 20B
.flowconfig 145B
.gitignore 699B
4XTTM3NVNm4VryWP91VXdEeoDXC2NzZkKRvUmPMnb1JdosJFk.id 100B
4XTTMF7HGrVmmnFATLrCMwboCDxnnm6CPcC8dyE8Tigfb5kYh.id 100B
4XTTMAhtTw2zgTVa5XFxHKeXcJGftdCVmsGR5zYzGspdLr2qf.id 100B
4XTTMB2cFTq23PTFGEdeT93cLdNptcSUekShxoUp5vzkjbkA4.id 100B
4XTTMHhM2e1nPVRgN6M7WM8WUcCnVwYwb8aS3ou9uKg5rdrHX.id 100B
4XTTMGbTZFhxPnpwUmC8JaQS6NHeLj98TdbdjSeAT9qupk5x9.id 100B
4XTTMEj74YR3oT18Uh1ZR1DbWpG5BXftvcSnyrwC6JbgS9AcG.id 100B
4XTTMDi5msCJgo8GFAHvZkE57cCK4QCPRQSrUSQcPMqQexT3E.id 100B
4XTTM33j1mHcbg5ctzCmsmvaiUCixX5jxTbkKHm2vCokC6uxw.id 100B
4XTTMATDw8fXWT5BGGaoc4A2sEbnLmMYBbekYnznDJ9K8c2cg.id 100B
4XTTMFB2m8B8ShvUiXNuywUmK6r3e8YM5fsQsLArHMeUpjhWk.id 100B
4XTTM6UEBfKSWUnC4KERbW8hesAAAGgrZcu68AXqihsFvU8w6.id 100B
4XTTM6UNDgjn7Y6FqnGyKiRf7NmqKzi7ofeh3ZRzFGmv5tkyQ.id 100B
4XTTMHa54HQoW8Lp6nLUzKt5QwZAUxux6DDshbBN5w4WNj759.id 100B
4XTTMBauYYKRkmWLyDwdU2sb4JgQX7VoZwwkPpmeFqrQoWWt7.id 100B
4XTTMFSVc6B4fRt5s71438dXcPE9NBPVQ5sRow1qtcARARHCJ.id 100B
4XTTM2UhNoDF1EfwonksnNN1zRGcZCMFutDRMtXYgciwiLzCf.id 100B
4XTTMFVjr2Zga6A1PF4GPZ43fSqvgWUfR8T3seEsfEBe3PUDi.id 100B
4XTTMCh4xe8E49486DUFko3cmqak3vrymKd5kMUBAVhMbxUkj.id 100B
4XTTM7xSyXgsrwG83aXEKt5Edp9LFmqxCxum1ABXAXDw5QHHy.id 100B
lodash_v4.x.x.js 29KB
node.js 28KB
RestClient.js 13KB
statement_test.js 13KB
statement.js 12KB
identity.js 12KB
publish.js 10KB
merge.js 10KB
libp2p_node.js 9KB
schema.js 8KB
chai_v3.5.x.js 7KB
util.js 7KB
schema_test.js 6KB
knex_v0.12.x.js 6KB
dump.js 6KB
push.js 6KB
util.js 6KB
index.js 5KB
index.js 5KB
test-statements.js 5KB
push_test.js 4KB
datastore.js 4KB
load.js 4KB
util.js 4KB
remote_query_test.js 4KB
directory_test.js 4KB
signature_test.js 4KB
validate.js 3KB
directory.js 3KB
libp2p_node_test.js 3KB
types.js 3KB
get.js 3KB
merge_test.js 3KB
build-jq.js 3KB
util.js 3KB
statement_db_test.js 3KB
util.js 3KB
query_result_test.js 3KB
merge_test.js 3KB
query.js 3KB
push_test.js 3KB
listPeers.js 2KB
repl.js 2KB
query_result.js 2KB
util_test.js 2KB
set.js 2KB
put.js 2KB
identity_test.js 2KB
query_test.js 2KB
ping_test.js 2KB
datastore_test.js 2KB
schemaver.js 1KB
remove.js 1KB
query.js 1KB
add.js 1KB
remote_data_test.js 1KB
index.js 1KB
ping_test.js 1KB
node_info_test.js 1KB
publishSchema.js 1KB
20161221093425_create_tables.js 1KB
identify.js 1KB
util.js 1KB
addr.js 1KB
node_info_test.js 1KB
status.js 1KB
statement.js 990B
dir.js 955B
index.js 914B
grant.js 896B
mocha_v3.1.x.js 862B
jqStream.js 842B
push.js 827B
共 184 条
- 1
- 2
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9152
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- tinymce 多图片批量上传插件
- Virtualized Hadoop Performance with VMware vSphere 6 on Servers
- 基于java开发的驾校学员信息管理系统
- 电气类117、变电站真实巡检电力设备检测数据集(7500多张+15类+YOLO格式txt标签)-第二部分
- 智能图像处理应用案例介绍:开发基于Java的智能图像处理应用,包括图像识别、图像增强等功能
- HTML 和 JavaScript 创建一个端午节的祝福页面.docx
- 电气类、117.变电站真实巡检电力设备检测数据集(7500多张+15类+YOLO格式txt标签)-第一部分
- IMG_20180720_124347_01.jpg
- IMG20240621095811.jpg
- jQuery 库.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功