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

Commit

Permalink
README and Doc updates
Browse files Browse the repository at this point in the history
Update README.md

Update README.md

Update README.md

README

doc updates
  • Loading branch information
aphelionz committed Sep 22, 2020
1 parent 5ef1ba4 commit 601d9bc
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 179 deletions.
126 changes: 125 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,125 @@
# orbit-db-powergate-io
# PowergateIO (orbit-db-powergate-io)

> 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/).
## Install

`npm install orbit-db-powergate-io`

### From Source

```bash
$ git clone https://github.com/orbitdb/orbit-db-powergate-io
$ cd orbit-db-powergate-io
$ npm install
```

## Usage

PowergateIO is designed to work with only one configuration option: the gRPC
endpoint of the Powergate node you want to connect to. Everything else should be handled
"under the hood" for you. See below.

### Initial Setup

```JavaScript
const PowergateIO = require('orbit-db-powergate-io')

const host = 'http://0.0.0.0:6002' // This is the default value
PowergateIO.create(host)
.then((powergateio) => {
console.log(powergateio.wallet) // Will be {} until funded
})
```

### Backing up an OrbitDB Snapshot

PowergateIO is meant to be used from one IPFS node to another, and to replicate
OrbitDB databases between them. So, let's assume that we have an IPFS node and
OrbitDB running locally, and we're going to interact with a _remote_ Powergate
instance.

```JavaScript
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
const PowergateIO = require('orbit-db-powergate-io')

;(async () => {
const ipfs = await IPFS.create()
const orbitdb = await OrbitDB.createInstance(ipfs)
powergateio = await PowergateIO.create('https://my.hosted.powergate.node')

const addresses = (await powergateio.ipfs.id()).addresses
await ipfs.swarm.connect(addresses[0].toString())

const db = await orbitdb.eventlog('powergate-test')
for (let i = 0; i < 10; i++) {
await db.add(`entry${i}`)
}

jobStatus = await powergateio.storeSnapshot(db.address.toString())
console.log(jobStatus)

// Wait until wallet is funded
// Can take up to 2 minute on testnet
console.log(powergateio.wallet)

await powergateio.stop()
await orbitdb.disconnect()
await ipfs.stop()
})()
```

### Retrieving an OrbitDB Snapshot

Once you've stored a snapshot and have made note of the DB address returned,
you can use that db address to retrieve the snapshot!

```JavaScript
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
const PowergateIO = require('orbit-db-powergate-io')

;(async () => {
const ipfs = await IPFS.create()
const orbitdb = await OrbitDB.createInstance(ipfs)
const powergateio = await PowergateIO.create('https://my.hosted.powergate.node')

const addresses = (await powergateio.ipfs.id()).addresses
await ipfs.swarm.connect(addresses[0].toString())

const dbAddr = '/orbitdb/zdpuAxkdoDum8Nk2VCxKkHZk8TzqAYPm86mVgoy7wagu2UcZB/powergate-test'
const db2 = await orbitdb.open(dbAddr, { create: true })
const snapshot = await powergateio.retrieveSnapshot(dbAddr)

await db2._oplog.join(snapshots[0].log)
await db2._updateIndex()
})()
```

For more information, see the [API docs](https://orbitdb.github.io/orbit-db-powergate-io/PowergateIO.html).

## Contributing

Issues and pull requests accepted. Please note that several issues have "[Help Wanted]"
and "[Good First Issue]" tags!

[Good First Issue]: (https://github.com/orbitdb/orbit-db-powergate-io/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
[Help Wanted]: (https://github.com/orbitdb/orbit-db-powergate-io/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)

### Developing Locally

It's highly recommended to install both Docker and Docker compose. From there, `make` is your
best friends. It gives you the following commands:

- `make up` - Spins up all the necessary docker images for local development
- `make lint` - Lints your JS code vi standard.js
- `make docs` - Compiles the README and JS docstrings into the docs/ folder
- `make down` - Spins down all the docker images
- `make clean` - Removes ephemeral files and folders like node_modules and package-lock.json
- `make test` - Does a whole bunch of the above, in order. *use it!*
- `make rebuild` - runs `make clean` and `make deps` to give you a clean slate.

## License

MIT © OrbitDB Community
166 changes: 155 additions & 11 deletions docs/PowergateIO.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,78 @@ <h3 class="subsection-title">Members</h3>



<h4 class="name" id="_jobWatchers"><span class="type-signature"></span>_jobWatchers<span class="type-signature"> :Array.&lt;intervalID></span></h4>




<div class="description">
An array of intervalIDs that watch jobs
</div>



<h5>Type:</h5>
<ul>
<li>

<span class="param-type">Array.&lt;intervalID></span>


</li>
</ul>





<dl class="details">


























<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line74">line 74</a>
</li></ul></dd>







</dl>








<h4 class="name" id="_orbitdb"><span class="type-signature"></span>_orbitdb<span class="type-signature"> :OrbitDB</span></h4>


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

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line77">line 77</a>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line83">line 83</a>
</li></ul></dd>







</dl>








<h4 class="name" id="wallet"><span class="type-signature"></span>wallet<span class="type-signature"> :Object</span></h4>




<div class="description">
FIL wallet info on the Powergate node
</div>



<h5>Type:</h5>
<ul>
<li>

<span class="param-type">Object</span>


</li>
</ul>





<dl class="details">


























<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="index.js.html">index.js</a>, <a href="index.js.html#line65">line 65</a>
</li></ul></dd>


Expand Down Expand Up @@ -541,7 +685,7 @@ <h5>Parameters:</h5>

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


Expand Down Expand Up @@ -688,7 +832,7 @@ <h5>Parameters:</h5>

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


Expand Down Expand Up @@ -844,7 +988,7 @@ <h5>Parameters:</h5>

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


Expand Down Expand Up @@ -1005,7 +1149,7 @@ <h5>Parameters:</h5>

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


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

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


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

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


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

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


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

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


Expand Down Expand Up @@ -1361,13 +1505,13 @@ <h5>Returns:</h5>
</div>

<nav>
<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>
<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>
</nav>

<br class="clear">

<footer>
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)
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)
</footer>

<script> prettyPrint(); </script>
Expand Down
4 changes: 2 additions & 2 deletions docs/external-IPFS.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ <h2>IPFS</h2>
</div>

<nav>
<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>
<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>
</nav>

<br class="clear">

<footer>
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)
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)
</footer>

<script> prettyPrint(); </script>
Expand Down
Loading

0 comments on commit 601d9bc

Please sign in to comment.