mirror of https://github.com/embarklabs/embark.git
remove orbit
This commit is contained in:
parent
ac69f2f9fd
commit
f3e7d03204
|
@ -1,95 +0,0 @@
|
|||
EmbarkJS.Messages.Orbit = {};
|
||||
|
||||
EmbarkJS.Messages.Orbit.setProvider = function(options) {
|
||||
this.providerName = 'orbit';
|
||||
this.currentMessages = EmbarkJS.Messages.Orbit;
|
||||
if (options === undefined) {
|
||||
ipfs = HaadIpfsApi('localhost', '5001');
|
||||
} else {
|
||||
ipfs = HaadIpfsApi(options.host, options.port);
|
||||
}
|
||||
this.currentMessages.orbit = new Orbit(ipfs);
|
||||
if (typeof(web3) === "undefined") {
|
||||
this.currentMessages.orbit.connect(Math.random().toString(36).substring(2));
|
||||
} else {
|
||||
this.currentMessages.orbit.connect(web3.eth.accounts[0]);
|
||||
}
|
||||
};
|
||||
|
||||
EmbarkJS.Messages.Orbit.sendMessage = function(options) {
|
||||
var topics = options.topic || options.topics;
|
||||
var data = options.data || options.payload;
|
||||
|
||||
if (topics === undefined) {
|
||||
throw new Error("missing option: topic");
|
||||
}
|
||||
|
||||
if (data === undefined) {
|
||||
throw new Error("missing option: data");
|
||||
}
|
||||
|
||||
if (typeof topics === 'string') {
|
||||
topics = topics;
|
||||
} else {
|
||||
// TODO: better to just send to different channels instead
|
||||
topics = topics.join(',');
|
||||
}
|
||||
|
||||
this.orbit.join(topics);
|
||||
|
||||
var payload = JSON.stringify(data);
|
||||
|
||||
this.orbit.send(topics, data);
|
||||
};
|
||||
|
||||
EmbarkJS.Messages.Orbit.listenTo = function(options) {
|
||||
var self = this;
|
||||
var topics = options.topic || options.topics;
|
||||
|
||||
if (typeof topics === 'string') {
|
||||
topics = topics;
|
||||
} else {
|
||||
topics = topics.join(',');
|
||||
}
|
||||
|
||||
this.orbit.join(topics);
|
||||
|
||||
var messageEvents = function() {
|
||||
this.cb = function() {};
|
||||
};
|
||||
|
||||
messageEvents.prototype.then = function(cb) {
|
||||
this.cb = cb;
|
||||
};
|
||||
|
||||
messageEvents.prototype.error = function(err) {
|
||||
return err;
|
||||
};
|
||||
|
||||
var promise = new messageEvents();
|
||||
|
||||
this.orbit.events.on('message', (channel, message) => {
|
||||
// TODO: looks like sometimes it's receving messages from all topics
|
||||
if (topics !== channel) return;
|
||||
self.orbit.getPost(message.payload.value, true).then((post) => {
|
||||
var data = {
|
||||
topic: channel,
|
||||
data: post.content,
|
||||
from: post.meta.from.name,
|
||||
time: (new Date(post.meta.ts))
|
||||
};
|
||||
promise.cb(post.content, data, post);
|
||||
});
|
||||
});
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
// TODO: needs a real check for availability
|
||||
// TODO: not tested as orbit is not loaded and therefore the provider is not available
|
||||
EmbarkJS.Messages.Orbit.isAvailable = function(){
|
||||
return new Promise((resolve) => {
|
||||
if(!this.orbit) resolve(false);
|
||||
resolve(true);
|
||||
});
|
||||
}
|
|
@ -315,8 +315,6 @@ class CodeGenerator {
|
|||
code += plugin.embarkjs_code.join('\n');
|
||||
}
|
||||
|
||||
//code += "\n" + fs.readFileSync(fs.embarkPath('js/embarkjs/orbit.js')).toString();
|
||||
|
||||
code += self.generateCommunicationInitialization(true);
|
||||
code += self.generateStorageInitialization(true);
|
||||
code += self.generateNamesInitialization(true);
|
||||
|
|
|
@ -250,7 +250,7 @@ Config.prototype.loadCommunicationConfigFile = function() {
|
|||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"],
|
||||
"available_providers": ["whisper"],
|
||||
"connection": {
|
||||
"host": "localhost", "port": 8546, "type": "ws"
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -53,7 +53,6 @@
|
|||
"ipfs-api": "17.2.4",
|
||||
"live-plugin-manager": "https://github.com/iurimatias/live-plugin-manager.git",
|
||||
"merge": "^1.2.0",
|
||||
"orbit-db": "^0.17.3",
|
||||
"os-locale": "^2.1.0",
|
||||
"parse-json": "^4.0.0",
|
||||
"promptly": "^2.1.0",
|
||||
|
@ -82,7 +81,6 @@
|
|||
"ethereum",
|
||||
"dapps",
|
||||
"ipfs",
|
||||
"orbit",
|
||||
"solidity",
|
||||
"solc",
|
||||
"blockchain",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"],
|
||||
"available_providers": ["whisper"],
|
||||
"connection": {
|
||||
"host": "localhost",
|
||||
"port": 8546,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"],
|
||||
"available_providers": ["whisper"],
|
||||
"connection": {
|
||||
"host": "localhost",
|
||||
"port": 8546,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"],
|
||||
"available_providers": ["whisper"],
|
||||
"connection": {
|
||||
"host": "localhost",
|
||||
"port": 8546,
|
||||
|
|
Loading…
Reference in New Issue