Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
fix: pass subscriptions immediately on new peer connection (#10)
Browse files Browse the repository at this point in the history
* fix: pass subscriptions immediately on new peer connection

* test: add test to ensure subs are passed on connection

* test: remove .only
  • Loading branch information
gavinmcdermott authored and daviddias committed Dec 11, 2016
1 parent 7391fe7 commit 078383a
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 135 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
"Gavin McDermott <gavinmcdermott@gmail.com>",
"Haad <haadcode@users.noreply.github.com>"
]
}
}
14 changes: 13 additions & 1 deletion src/dial-floodsub.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const config = require('./config')
const pb = require('./message')
const log = config.log
const multicodec = config.multicodec
const stream = require('stream')
Expand Down Expand Up @@ -50,8 +51,19 @@ module.exports = (libp2pNode, peerSet, subscriptions) => {
conn
)

// Immediately send my own subscriptions to the newly established conn
if (subscriptions.length > 0) {
// TODO send my subscriptions through the new conn
const subopts = subscriptions.map((topic) => {
return {
subscribe: true,
topicCID: topic
}
})
const rpc = pb.rpc.RPC.encode({
subscriptions: subopts
})

peerSet[idB58Str].stream.write(rpc)
}
}
}
Expand Down
Loading

0 comments on commit 078383a

Please sign in to comment.