You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
IPFS Core is divided into separate subsystems, each of them exist in their own repo/module. The dependencies between each subsystem is assured by injection at the IPFS Core level. IPFS Core exposes an API, defined by the IPFS API spec. libp2p is the networking layer used by IPFS, but out of scope in IPFS core, follow that project [here](https://github.com/diasdavid/js-libp2p)
IPFS Core is the entry point module for IPFS. It exposes an interface defined on [IPFS Specs.](https://github.com/ipfs/specs/blob/ipfs/api/api/core/README.md)
71
+
72
+
#### Block Service
73
+
74
+
Block Service uses IPFS Repo (local storage) and Bitswap (network storage) to store and fetch blocks. A block is a serialized MerkleDAG node.
75
+
76
+
#### DAG Service
77
+
78
+
DAG Service offers some graph language semantics on top of the MerkleDAG, composed by DAG Nodes (which can have DAG Links). It uses the Block Service as its storage and discovery service.
79
+
80
+
#### IPFS Repo
81
+
82
+
IPFS Repo is storage driver of IPFS, follows the [IPFS Repo Spec](https://github.com/ipfs/specs/tree/master/repo) and supports the storage of different types of files.
83
+
84
+
#### Bitswap
85
+
86
+
Bitswap is the exchange protocol used by IPFS to 'trade' blocks with other IPFS nodes.
87
+
88
+
#### Files
89
+
90
+
Files is the API that lets us work with IPFS objects (DAG Nodes) as if they were Unix Files.
91
+
92
+
#### Importer
93
+
94
+
Importer are a set of layouts (e.g. UnixFS) and chunkers (e.g: fixed-size, rabin, etc) that convert data to a MerkleDAG representation inside IPFS.
Copy file name to clipboardexpand all lines: README.md
+108-122
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,7 @@ This repo contains the JavaScript implementation of the IPFS protocol, with feat
21
21
22
22
### Project status
23
23
24
-
Consult the [Roadmap](/ROADMAP.md) for a complete state description of the project, or you can find `in process` updates in our [`Captain.log`](https://github.com/ipfs/js-ipfs/issues/30). A lot of components can be used currently, but it is a WIP, so beware of the Dragons.
Consult the [Roadmap](/ROADMAP.md) for a complete state description of the project, or you can find `in process` updates in our [`Captain.log`](https://github.com/ipfs/js-ipfs/issues/30). A lot of components can be used currently, but it is a WIP, so beware of the Dragons 🐉.
27
25
28
26
## Table of Contents
29
27
@@ -37,15 +35,7 @@ Consult the [Roadmap](/ROADMAP.md) for a complete state description of the proje
@@ -97,155 +87,151 @@ Loading this module in a browser (using a `<script>` tag) makes the `Ipfs` ob
97
87
98
88
The last published version of the package become [available for download](https://unpkg.com/ipfs/dist/) from [unpkg](https://unpkg.com/) and thus you may use it as the source:
The `jsipfs` CLI, available when `js-ipfs` is installed globably, follows(should, it is a WIP) the same interface defined by `go-ipfs`, you can always use the `help` command for help menus.
117
104
118
-
### API
105
+
```
106
+
# Install js-ipfs globally
107
+
> npm install ipfs --global
108
+
> jsipfs --help
109
+
Commands:
110
+
bitswap A set of commands to manipulate the bitswap agent.
111
+
block Manipulate raw IPFS blocks.
112
+
bootstrap Show or edit the list of bootstrap peers.
113
+
commands List all available commands
114
+
config <key> [value] Get and set IPFS config values
115
+
daemon Start a long-running daemon process
116
+
# ...
117
+
```
119
118
120
-
A complete API definition will come, meanwhile, you can learn how to you use js-ipfs throught he standard interface at [](https://github.com/ipfs/interface-ipfs-core)
119
+
### HTTP-API
121
120
122
-
## Development
121
+
The HTTP-API exposed by the js-ipfs daemon follows the [`http-api-spec`](https://github.com/ipfs/http-api-spec). You can use any of the IPFS HTTP-API client libraries with it, such as: [js-ipfs-api](https://github.com/ipfs/js-ipfs-api).
123
122
124
-
### Clone
125
-
```
126
-
git clone https://github.com/ipfs/js-ipfs.git
127
-
cd js-ipfs
128
-
```
123
+
### IPFS Core examples (use IPFS as a module)
129
124
130
-
### Install Dependencies
131
-
```
132
-
npm install
133
-
```
125
+
#### Create a IPFS node instance
134
126
135
-
### Run Tests
136
-
```
137
-
npm test
138
-
```
127
+
```JavaScript
128
+
// IPFS will need a repo, it can create one for you or you can pass
129
+
// it a repo instance of the type IPFS Repo
130
+
// https://github.com/ipfs/js-ipfs-repo
131
+
constrepo=<IPFS Repo instance or repo path>
139
132
140
-
### Lint
133
+
// Create the IPFS node instance
134
+
constnode=newIPFS(repo)
2
Has conversations. Original line has conversations.
141
135
142
-
*Conforming to linting rules is a prerequisite to commit to js-ipfs.*
136
+
// We need to init our repo, in this case the repo was empty
137
+
// We are picking 2048 bits for the RSA key that will be our PeerId
// Once the repo is initiated, we have to load it so that the IPFS
142
+
// instance has its config values. This is useful when you have
143
+
// previous created repos and you don't need to generate a new one
144
+
ipfs.load((err) => {
145
+
if (err) { throw err }
147
146
148
-
### Build
149
-
```
150
-
npm run build
147
+
// Last but not the least, we want our IPFS node to use its peer
148
+
// connections to fetch and serve blocks from.
149
+
ipfs.goOnline((err) => {
150
+
if (err) { throw err }
151
+
// Here you should be good to go and call any IPFS function
152
+
})
153
+
})
151
154
```
152
155
153
-
The ES5 distributable build will be located in `lib/`. The browser distributable will be located in `dist/index.js`.
156
+
> We are working on making this init process better, see https://github.com/ipfs/js-ipfs/issues/556 for the discussion.
154
157
155
-
##Project structure
158
+
#### More to come
156
159
157
-
```
158
-
┌───┐ ┌───────────────┐ ┌──────────────┐
159
-
│CLI│───▶│ HTTP API ├───▶│IPFS Core Impl│
160
-
└───┘ └───────────────┘ └──────────────┘
161
-
△ △ △
162
-
└──────────────└──────────┬─────────┘
163
-
│
164
-
┌─────┐
165
-
│Tests│
166
-
└─────┘
167
-
```
160
+
> If you have built an example, please share it with the community by submitting a Pull Request to this repo!.
168
161
169
-
##IPFS Core implementation architecture
162
+
### API
170
163
171
-
IPFS Core is divided into separate subsystems, each of them exist in their own repo/module. The dependencies between each subsystem is assured by injection at the IPFS Core level. IPFS Core exposes an API, defined by the IPFS API spec. libp2p is the networking layer used by IPFS, but out of scope in IPFS core, follow that project [here](https://github.com/diasdavid/js-libp2p)
A complete API definition will come, meanwhile, you can learn how to you use js-ipfs throught he standard interface at [](https://github.com/ipfs/interface-ipfs-core).
Every IPFS instance also exposes the libp2p API at `ipfs.libp2p`. The formal interface for this API hasn't been defined by you can find documentation at its implementations:
IPFS Core is the entry point module for IPFS. It exposes an interface defined on [IPFS Specs.](https://github.com/ipfs/specs/blob/ipfs/api/api/core/README.md)
198
+
```sh
199
+
> npm install
200
+
```
225
201
226
-
#### Block Service
202
+
### Run Tests
227
203
228
-
Block Service uses IPFS Repo (local storage) and Bitswap (network storage) to store and fetch blocks. A block is a serialized MerkleDAG node.
204
+
```sh
205
+
> npm test
229
206
230
-
#### DAG Service
207
+
# run just IPFS core tests
208
+
> npm run test:node:core
231
209
232
-
DAG Service offers some graph language semantics on top of the MerkleDAG, composed by DAG Nodes (which can have DAG Links). It uses the Block Service as its storage and discovery service.
210
+
# run just IPFSHTTP-API tests
211
+
> npm run test:node:http
233
212
234
-
#### IPFS Repo
213
+
# run just IPFSCLI tests
214
+
> npm run test:node:cli
235
215
236
-
IPFS Repo is storage driver of IPFS, follows the [IPFS Repo Spec](https://github.com/ipfs/specs/tree/master/repo) and supports the storage of different types of files.
216
+
# run just IPFS Browser tests
217
+
> npm run test:browser
218
+
```
237
219
238
-
#### Bitswap
220
+
### Lint
239
221
240
-
Bitswap is the exchange protocol used by IPFS to 'trade' blocks with other IPFS nodes.
222
+
*Conforming to linting rules is a prerequisite to commit to js-ipfs.*
241
223
242
-
#### Files
224
+
```sh
225
+
> npm run lint
226
+
```
243
227
244
-
Files is the API that lets us work with IPFS objects (DAG Nodes) as if they were Unix Files.
228
+
### Build a dist version
245
229
246
-
#### Importer
230
+
```
231
+
> npm run build
232
+
```
247
233
248
-
Importer are a set of layouts (e.g. UnixFS) and chunkers (e.g: fixed-size, rabin, etc) that convert data to a MerkleDAG representation inside IPFS.
234
+
The ES5 distributable build will be located in `lib/`. The browser distributable will be located in `dist/index.js`.