This is a work in progress implementation of the IPFS integration of Chlu.
See CONTRIBUTING.md to hack on the code.
This module has not been released to NPM yet. Check out index.js to see the exposed API calls, read the API docs linked below or check out the examples.
Just require this module, then check out the JS API Docs below for usage information.
You can require/import this module from the browser through Webpack. Check out this example for the additional configuration needed by js-ipfs.
If you use create-react-app and don't want to eject, there is an issue preventing you from using IPFS or any library that
depends on IPFS because the IPFS code is not transpiled to ES5 and the uglify version used by create-react-app as of now
does not support ES6 code and crashes when encountering it. This will prevent you from making a production build of your
app, but thankfully there is a workaround you can use:
be careful to remove -c and -m options from the uglify-es call since they don't play well with IPFS.
For more information either check how we are building chlu-demo or open an issue.
If you don't have webpack, we also have a prebuilt minified version of the library that you can include in a <script> tag.
Check out the examples.
This is not supported right now, however everything should work if you follow the browser instructions and only run ChluIPFS in the renderer process of electron. Keep in mind that you will run into the same limitations of running ChluIPFS in the browser, and that this is not tested.
Check out CONTRIBUTING
Check out the Chlu Collector README.
Check out the Chlu Collector README.
https://ipfs.io/ipfs/QmZ2QNSTNwt61jrMQccZYd3uc5V626nafg6Fz2khDhQmNp
You can access the event emitter at chluIpfs.instance.events and listen to some events:
- Lifecycle
chlu-ipfs/starting,chlu-ipfs/ready,chlu-ipfs/stopping,chlu-ipfs/stoppedare self explanatorychlu-ipfs/errorgeneric internal non-fatal error. Mostly used for weird cases and debugging
- OrbitDB (check out orbit-db docs for more information)
db/replicatecalled withaddressto signal that a DB has started replicating from another peerdb/replicate/progressdb/replicatedwhen the replication is finished
- Persistence
persistence/savedafter saving Chlu specific informationpersistence/loadedafter loading Chlu specific information
- Pinning
pin/pinningwhen starting a pin, called withmultihashpin/pinnedafter finishing a pin, called withmultihashpin/errorwhen a pin operation goes wrong
- Review Records
reviewrecord/updatedwhen an update to a review record is discovered. Called with:multihashthe multihash of the review record that has been updatedupdatedMultihashthe multihash of the new version that has just been discoveredreviewRecordthe new version of the review record. The RR is already validated, otherwise the event would not have been emitted
reviewrecord/readwhen a review record is readreviewrecord/storedwhen a review record is stored (not necessarily published)reviewrecord/publishedwhen a review record is published
- Validation
validation/errorto keep track of invalid review records
- Discovery
discover/did/vendorto keep track of vendors encountered. Only emitted if the RR containing it is validdiscover/keys/vendor-marketplaceOnly emitted if the RR containing it is validdiscover/did/marketplaceto keep track of marketplaces encountered. Only emitted if the RR containing it is validdiscover/did/customeronly emitted if a customer signed RR containing it is valid
- PubSub
pubsub/subscribedpubsub/unsubscribedpubsub/messageyou can use this to listen to all Chlu chatter on pubsubpubsub/errorpubsub/peer/joinedcalled with IPFS peer IDpubsub/peer/leftcalled with IPFS peer ID
// Create a ChluIPFS node
const chluIpfs = new ChluIPFS()
// Start the node. It is possible to modify internal modules or set an existing IPFS instance
// to be used while the node has not been started yet
await chluIpfs.start() // this operation is async. Wait for the promise to resolve before doing anything else
// ChluIPFS logs to console in debug level by default. Pass a custom logger object to the constructor to
// change this behavior. The methods that the logger should contain are error, warn, info and debug
// Check out the JS API Docs above for moreAlso check out the browser examples
Note: browser examples are severely outdated and need refactoring
Note: This section is severely outdated and needs reviewing.
This is a collection of features and design choices not compatible with the Chlu Protocol. They exist to allow this to work before the protocol is finalized.
Chlu Service Nodes:
- chlu service nodes listen for chlu events and take actions to help replicate data. The events are written to IPFS Pubsub
- the review history and pointers to new versions are kept in a custom OrbitDB Store
Writing Reviews:
- when a review is written, the API will not return until a service node has replied saying it successfully pinned the review
- an OrbitDB database with a custom store is used to write all new review records and all updates
All of these are subject to change.