Merge pull request #472 from embark-framework/remove_orbit

remove orbit
This commit is contained in:
Iuri Matias 2018-06-01 12:00:07 -04:00 committed by GitHub
commit d2b41be908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 130 additions and 742 deletions

View File

@ -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);
});
}

View File

@ -315,8 +315,6 @@ class CodeGenerator {
code += plugin.embarkjs_code.join('\n'); code += plugin.embarkjs_code.join('\n');
} }
//code += "\n" + fs.readFileSync(fs.embarkPath('js/embarkjs/orbit.js')).toString();
code += self.generateCommunicationInitialization(true); code += self.generateCommunicationInitialization(true);
code += self.generateStorageInitialization(true); code += self.generateStorageInitialization(true);
code += self.generateNamesInitialization(true); code += self.generateNamesInitialization(true);

View File

@ -250,7 +250,7 @@ Config.prototype.loadCommunicationConfigFile = function() {
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper", "orbit"], "available_providers": ["whisper"],
"connection": { "connection": {
"host": "localhost", "port": 8546, "type": "ws" "host": "localhost", "port": 8546, "type": "ws"
} }

765
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,6 @@
"ipfs-api": "17.2.4", "ipfs-api": "17.2.4",
"live-plugin-manager": "https://github.com/iurimatias/live-plugin-manager.git", "live-plugin-manager": "https://github.com/iurimatias/live-plugin-manager.git",
"merge": "^1.2.0", "merge": "^1.2.0",
"orbit-db": "^0.17.3",
"os-locale": "^2.1.0", "os-locale": "^2.1.0",
"parse-json": "^4.0.0", "parse-json": "^4.0.0",
"promptly": "^2.1.0", "promptly": "^2.1.0",
@ -82,7 +81,6 @@
"ethereum", "ethereum",
"dapps", "dapps",
"ipfs", "ipfs",
"orbit",
"solidity", "solidity",
"solc", "solc",
"blockchain", "blockchain",

View File

@ -2,7 +2,7 @@
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper", "orbit"], "available_providers": ["whisper"],
"connection": { "connection": {
"host": "localhost", "host": "localhost",
"port": 8546, "port": 8546,

View File

@ -2,7 +2,7 @@
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper", "orbit"], "available_providers": ["whisper"],
"connection": { "connection": {
"host": "localhost", "host": "localhost",
"port": 8546, "port": 8546,

View File

@ -2,7 +2,7 @@
"default": { "default": {
"enabled": true, "enabled": true,
"provider": "whisper", "provider": "whisper",
"available_providers": ["whisper", "orbit"], "available_providers": ["whisper"],
"connection": { "connection": {
"host": "localhost", "host": "localhost",
"port": 8546, "port": 8546,