This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
WIP: feat/pubsub #471
Closed
Closed
WIP: feat/pubsub #471
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
21e12f5
refactor(streams): Refactor response stream handling.
haadcode fb1f135
Improve function descriptions
haadcode b12abf2
Change variable name to be more descriptive in dagnode-stream
haadcode 220ca6d
Refactor tar-stream-to-objects to better show intent
haadcode fd1ea27
Use stream-to-value in Block command instead of bl
haadcode db91f3c
test: fix daemon config setting
dignifiedquire 241df6d
refactor(pubsub): Refactored and completed pubsub API
haadcode 8580554
fix: added missing test files
daviddias 91cbfa8
feat: move pubsub message tests to here, they are not interface-ipfs-…
daviddias 86b18ce
fix: mdns should be off
daviddias cf1015a
pubsub:handle topicCIDs and topicIDs
dignifiedquire af2b096
refactor to new event based pubsub api
dignifiedquire 5695f39
fix issues due to the new event pubsub api
dignifiedquire 3a7fc2d
pubsub.peers: do not throw on missing subscription
dignifiedquire dce5205
error on non buffer arguments to pubsub.publish
dignifiedquire File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
'use strict' | ||
|
||
const isStream = require('isstream') | ||
const addToDagNodesTransform = require('../add-to-dagnode-transform') | ||
const promisify = require('promisify-es6') | ||
const DAGNodeStream = require('../dagnode-stream') | ||
|
||
module.exports = (send) => { | ||
return promisify((files, callback) => { | ||
const good = Buffer.isBuffer(files) || | ||
const ok = Buffer.isBuffer(files) || | ||
isStream.isReadable(files) || | ||
Array.isArray(files) | ||
|
||
if (!good) { | ||
callback(new Error('"files" must be a buffer, readable stream, or array of objects')) | ||
if (!ok) { | ||
return callback(new Error('"files" must be a buffer, readable stream, or array of objects')) | ||
} | ||
|
||
const sendWithTransform = send.withTransform(addToDagNodesTransform) | ||
|
||
return sendWithTransform({ | ||
const request = { | ||
path: 'add', | ||
files: files | ||
}, callback) | ||
} | ||
|
||
// Transform the response stream to DAGNode values | ||
const transform = (res, callback) => DAGNodeStream.streamToValue(send, res, callback) | ||
send.andTransform(request, transform, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
const streamToValue = require('../stream-to-value') | ||
|
||
module.exports = (send) => { | ||
return promisify((id, callback) => { | ||
send({ | ||
const request = { | ||
path: 'ping', | ||
args: id, | ||
qs: { n: 1 } | ||
}, function (err, res) { | ||
if (err) { | ||
return callback(err, null) | ||
} | ||
callback(null, res[1]) | ||
}) | ||
} | ||
|
||
// Transform the response stream to a value: | ||
// { Success: <boolean>, Time: <number>, Text: <string> } | ||
const transform = (res, callback) => { | ||
streamToValue(res, (err, res) => { | ||
if (err) { | ||
return callback(err) | ||
} | ||
|
||
// go-ipfs http api currently returns 3 lines for a ping. | ||
// they're a little messed, so take the correct values from each lines. | ||
const pingResult = { | ||
Success: res[1].Success, | ||
Time: res[1].Time, | ||
Text: res[2].Text | ||
} | ||
|
||
callback(null, pingResult) | ||
}) | ||
} | ||
|
||
send.andTransform(request, transform, callback) | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated