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

fix: pass subscriptions immediately on new peer connection #10

Merged
merged 4 commits into from
Dec 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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