Skip to content
This repository was archived by the owner on Aug 22, 2022. It is now read-only.

Commit 601d9bc

Browse files
committed
README and Doc updates
Update README.md Update README.md Update README.md README doc updates
1 parent 5ef1ba4 commit 601d9bc

File tree

10 files changed

+409
-179
lines changed

10 files changed

+409
-179
lines changed

README.md

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,125 @@
1-
# orbit-db-powergate-io
1+
# PowergateIO (orbit-db-powergate-io)
2+
3+
> A bridge between [OrbitDB](https://github.com/orbitdb/orbit-db) and [Powergate](https://docs.textile.io/powergate/), which is itself a bridge between [Filecoin](https://filecoin.io) and [IPFS](https://ipfs.io/).
4+
5+
## Install
6+
7+
`npm install orbit-db-powergate-io`
8+
9+
### From Source
10+
11+
```bash
12+
$ git clone https://github.com/orbitdb/orbit-db-powergate-io
13+
$ cd orbit-db-powergate-io
14+
$ npm install
15+
```
16+
17+
## Usage
18+
19+
PowergateIO is designed to work with only one configuration option: the gRPC
20+
endpoint of the Powergate node you want to connect to. Everything else should be handled
21+
"under the hood" for you. See below.
22+
23+
### Initial Setup
24+
25+
```JavaScript
26+
const PowergateIO = require('orbit-db-powergate-io')
27+
28+
const host = 'http://0.0.0.0:6002' // This is the default value
29+
PowergateIO.create(host)
30+
.then((powergateio) => {
31+
console.log(powergateio.wallet) // Will be {} until funded
32+
})
33+
```
34+
35+
### Backing up an OrbitDB Snapshot
36+
37+
PowergateIO is meant to be used from one IPFS node to another, and to replicate
38+
OrbitDB databases between them. So, let's assume that we have an IPFS node and
39+
OrbitDB running locally, and we're going to interact with a _remote_ Powergate
40+
instance.
41+
42+
```JavaScript
43+
const IPFS = require('ipfs')
44+
const OrbitDB = require('orbit-db')
45+
const PowergateIO = require('orbit-db-powergate-io')
46+
47+
;(async () => {
48+
const ipfs = await IPFS.create()
49+
const orbitdb = await OrbitDB.createInstance(ipfs)
50+
powergateio = await PowergateIO.create('https://my.hosted.powergate.node')
51+
52+
const addresses = (await powergateio.ipfs.id()).addresses
53+
await ipfs.swarm.connect(addresses[0].toString())
54+
55+
const db = await orbitdb.eventlog('powergate-test')
56+
for (let i = 0; i < 10; i++) {
57+
await db.add(`entry${i}`)
58+
}
59+
60+
jobStatus = await powergateio.storeSnapshot(db.address.toString())
61+
console.log(jobStatus)
62+
63+
// Wait until wallet is funded
64+
// Can take up to 2 minute on testnet
65+
console.log(powergateio.wallet)
66+
67+
await powergateio.stop()
68+
await orbitdb.disconnect()
69+
await ipfs.stop()
70+
})()
71+
```
72+
73+
### Retrieving an OrbitDB Snapshot
74+
75+
Once you've stored a snapshot and have made note of the DB address returned,
76+
you can use that db address to retrieve the snapshot!
77+
78+
```JavaScript
79+
const IPFS = require('ipfs')
80+
const OrbitDB = require('orbit-db')
81+
const PowergateIO = require('orbit-db-powergate-io')
82+
83+
;(async () => {
84+
const ipfs = await IPFS.create()
85+
const orbitdb = await OrbitDB.createInstance(ipfs)
86+
const powergateio = await PowergateIO.create('https://my.hosted.powergate.node')
87+
88+
const addresses = (await powergateio.ipfs.id()).addresses
89+
await ipfs.swarm.connect(addresses[0].toString())
90+
91+
const dbAddr = '/orbitdb/zdpuAxkdoDum8Nk2VCxKkHZk8TzqAYPm86mVgoy7wagu2UcZB/powergate-test'
92+
const db2 = await orbitdb.open(dbAddr, { create: true })
93+
const snapshot = await powergateio.retrieveSnapshot(dbAddr)
94+
95+
await db2._oplog.join(snapshots[0].log)
96+
await db2._updateIndex()
97+
})()
98+
```
99+
100+
For more information, see the [API docs](https://orbitdb.github.io/orbit-db-powergate-io/PowergateIO.html).
101+
102+
## Contributing
103+
104+
Issues and pull requests accepted. Please note that several issues have "[Help Wanted]"
105+
and "[Good First Issue]" tags!
106+
107+
[Good First Issue]: (https://github.com/orbitdb/orbit-db-powergate-io/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
108+
[Help Wanted]: (https://github.com/orbitdb/orbit-db-powergate-io/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
109+
110+
### Developing Locally
111+
112+
It's highly recommended to install both Docker and Docker compose. From there, `make` is your
113+
best friends. It gives you the following commands:
114+
115+
- `make up` - Spins up all the necessary docker images for local development
116+
- `make lint` - Lints your JS code vi standard.js
117+
- `make docs` - Compiles the README and JS docstrings into the docs/ folder
118+
- `make down` - Spins down all the docker images
119+
- `make clean` - Removes ephemeral files and folders like node_modules and package-lock.json
120+
- `make test` - Does a whole bunch of the above, in order. *use it!*
121+
- `make rebuild` - runs `make clean` and `make deps` to give you a clean slate.
122+
123+
## License
124+
125+
MIT © OrbitDB Community

docs/PowergateIO.html

Lines changed: 155 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,78 @@ <h3 class="subsection-title">Members</h3>
144144

145145

146146

147+
<h4 class="name" id="_jobWatchers"><span class="type-signature"></span>_jobWatchers<span class="type-signature"> :Array.&lt;intervalID></span></h4>
148+
149+
150+
151+
152+
<div class="description">
153+
An array of intervalIDs that watch jobs
154+
</div>
155+
156+
157+
158+
<h5>Type:</h5>
159+
<ul>
160+
<li>
161+
162+
<span class="param-type">Array.&lt;intervalID></span>
163+
164+
165+
</li>
166+
</ul>
167+
168+
169+
170+
171+
172+
<dl class="details">
173+
174+
175+
176+
177+
178+
179+
180+
181+
182+
183+
184+
185+
186+
187+
188+
189+
190+
191+
192+
193+
194+
195+
196+
197+
198+
199+
<dt class="tag-source">Source:</dt>
200+
<dd class="tag-source"><ul class="dummy"><li>
201+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line74">line 74</a>
202+
</li></ul></dd>
203+
204+
205+
206+
207+
208+
209+
210+
</dl>
211+
212+
213+
214+
215+
216+
217+
218+
147219
<h4 class="name" id="_orbitdb"><span class="type-signature"></span>_orbitdb<span class="type-signature"> :OrbitDB</span></h4>
148220

149221

@@ -393,7 +465,79 @@ <h4 class="name" id="ipfs"><span class="type-signature"></span>ipfs<span class="
393465

394466
<dt class="tag-source">Source:</dt>
395467
<dd class="tag-source"><ul class="dummy"><li>
396-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line77">line 77</a>
468+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line83">line 83</a>
469+
</li></ul></dd>
470+
471+
472+
473+
474+
475+
476+
477+
</dl>
478+
479+
480+
481+
482+
483+
484+
485+
486+
<h4 class="name" id="wallet"><span class="type-signature"></span>wallet<span class="type-signature"> :Object</span></h4>
487+
488+
489+
490+
491+
<div class="description">
492+
FIL wallet info on the Powergate node
493+
</div>
494+
495+
496+
497+
<h5>Type:</h5>
498+
<ul>
499+
<li>
500+
501+
<span class="param-type">Object</span>
502+
503+
504+
</li>
505+
</ul>
506+
507+
508+
509+
510+
511+
<dl class="details">
512+
513+
514+
515+
516+
517+
518+
519+
520+
521+
522+
523+
524+
525+
526+
527+
528+
529+
530+
531+
532+
533+
534+
535+
536+
537+
538+
<dt class="tag-source">Source:</dt>
539+
<dd class="tag-source"><ul class="dummy"><li>
540+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line65">line 65</a>
397541
</li></ul></dd>
398542

399543

@@ -541,7 +685,7 @@ <h5>Parameters:</h5>
541685

542686
<dt class="tag-source">Source:</dt>
543687
<dd class="tag-source"><ul class="dummy"><li>
544-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line98">line 98</a>
688+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line104">line 104</a>
545689
</li></ul></dd>
546690

547691

@@ -688,7 +832,7 @@ <h5>Parameters:</h5>
688832

689833
<dt class="tag-source">Source:</dt>
690834
<dd class="tag-source"><ul class="dummy"><li>
691-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line121">line 121</a>
835+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line127">line 127</a>
692836
</li></ul></dd>
693837

694838

@@ -844,7 +988,7 @@ <h5>Parameters:</h5>
844988

845989
<dt class="tag-source">Source:</dt>
846990
<dd class="tag-source"><ul class="dummy"><li>
847-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line133">line 133</a>
991+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line139">line 139</a>
848992
</li></ul></dd>
849993

850994

@@ -1005,7 +1149,7 @@ <h5>Parameters:</h5>
10051149

10061150
<dt class="tag-source">Source:</dt>
10071151
<dd class="tag-source"><ul class="dummy"><li>
1008-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line162">line 162</a>
1152+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line168">line 168</a>
10091153
</li></ul></dd>
10101154

10111155

@@ -1116,7 +1260,7 @@ <h4 class="name" id="stop"><span class="type-signature">(async) </span>stop<span
11161260

11171261
<dt class="tag-source">Source:</dt>
11181262
<dd class="tag-source"><ul class="dummy"><li>
1119-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line243">line 243</a>
1263+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line249">line 249</a>
11201264
</li></ul></dd>
11211265

11221266

@@ -1216,7 +1360,7 @@ <h4 class="name" id="storeSnapshot"><span class="type-signature">(async) </span>
12161360

12171361
<dt class="tag-source">Source:</dt>
12181362
<dd class="tag-source"><ul class="dummy"><li>
1219-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line180">line 180</a>
1363+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line186">line 186</a>
12201364
</li></ul></dd>
12211365

12221366

@@ -1261,7 +1405,7 @@ <h4 class="name" id="watchJob"><span class="type-signature"></span>watchJob<span
12611405

12621406
<div class="description">
12631407
Creates an interval to periodically check a job status and then updates the jobs database.
1264-
Then, adds the interval PowergateIO#_jobWatchers
1408+
Then, adds the interval <a href="PowergateIO.html#_jobWatchers">PowergateIO#_jobWatchers</a>
12651409
</div>
12661410

12671411

@@ -1305,7 +1449,7 @@ <h4 class="name" id="watchJob"><span class="type-signature"></span>watchJob<span
13051449

13061450
<dt class="tag-source">Source:</dt>
13071451
<dd class="tag-source"><ul class="dummy"><li>
1308-
<a href="index.js.html">index.js</a>, <a href="index.js.html#line218">line 218</a>
1452+
<a href="index.js.html">index.js</a>, <a href="index.js.html#line224">line 224</a>
13091453
</li></ul></dd>
13101454

13111455

@@ -1361,13 +1505,13 @@ <h5>Returns:</h5>
13611505
</div>
13621506

13631507
<nav>
1364-
<h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-IPFS.html">IPFS</a></li><li><a href="external-ipfs-log.html">ipfs-log</a></li><li><a href="external-OrbitDB.html">OrbitDB</a></li><li><a href="external-powergate-client.html">powergate-client</a></li></ul><h3>Classes</h3><ul><li><a href="PowergateIO.html">PowergateIO</a></li></ul><h3>Global</h3><ul><li><a href="global.html#an">an</a></li><li><a href="global.html#FIL">FIL</a></li></ul>
1508+
<h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-IPFS.html">IPFS</a></li><li><a href="external-ipfs-log.html">ipfs-log</a></li><li><a href="external-OrbitDB.html">OrbitDB</a></li><li><a href="external-powergate-client.html">powergate-client</a></li></ul><h3>Classes</h3><ul><li><a href="PowergateIO.html">PowergateIO</a></li></ul><h3><a href="global.html">Global</a></h3>
13651509
</nav>
13661510

13671511
<br class="clear">
13681512

13691513
<footer>
1370-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue Sep 22 2020 12:32:20 GMT-0400 (Eastern Daylight Time)
1514+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue Sep 22 2020 14:42:39 GMT-0400 (Eastern Daylight Time)
13711515
</footer>
13721516

13731517
<script> prettyPrint(); </script>

docs/external-IPFS.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ <h2>IPFS</h2>
124124
</div>
125125

126126
<nav>
127-
<h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-IPFS.html">IPFS</a></li><li><a href="external-ipfs-log.html">ipfs-log</a></li><li><a href="external-OrbitDB.html">OrbitDB</a></li><li><a href="external-powergate-client.html">powergate-client</a></li></ul><h3>Classes</h3><ul><li><a href="PowergateIO.html">PowergateIO</a></li></ul><h3>Global</h3><ul><li><a href="global.html#an">an</a></li><li><a href="global.html#FIL">FIL</a></li></ul>
127+
<h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-IPFS.html">IPFS</a></li><li><a href="external-ipfs-log.html">ipfs-log</a></li><li><a href="external-OrbitDB.html">OrbitDB</a></li><li><a href="external-powergate-client.html">powergate-client</a></li></ul><h3>Classes</h3><ul><li><a href="PowergateIO.html">PowergateIO</a></li></ul><h3><a href="global.html">Global</a></h3>
128128
</nav>
129129

130130
<br class="clear">
131131

132132
<footer>
133-
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue Sep 22 2020 12:32:20 GMT-0400 (Eastern Daylight Time)
133+
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue Sep 22 2020 14:42:39 GMT-0400 (Eastern Daylight Time)
134134
</footer>
135135

136136
<script> prettyPrint(); </script>

0 commit comments

Comments
 (0)