You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to be able to "unreplicate" a core from a hypercore protocol stream, without destroying the underlying stream. I guess closing the protomux channel would do this, and it would remove the peer. However I'm not sure if there's a way to access the protomux channel from the stream returned from core.replicate()?
The text was updated successfully, but these errors were encountered:
The protomux instance can be access from the raw stream returned by const protocolStream = core.replicate(), via const protomux = protocolStream.noiseStream.userData.
Update: the function above was not working for two reasons:
Needed to unpair the protomux
If one peer unreplicated before the other, the other peer would remain "replicated"
Fixed unreplicate function:
/** * @param {import('hypercore')<'binary', any>} core Core to unreplicate. Must be ready. * @param {import('protomux')} protomux */exportfunctionunreplicate(core,protomux){assert(core.discoveryKey,'Core should have a discovery key')protomux.unpair({protocol: 'hypercore/alpha',id: core.discoveryKey,})for(constchannelofprotomux){if(channel.protocol!=='hypercore/alpha')continueif(!channel.id.equals(core.discoveryKey))continuechannel.close()}}
For our use-case, we would not need an unreplicate method if #556 was implemented.
This existed a while ago in #49
It would be useful to be able to "unreplicate" a core from a hypercore protocol stream, without destroying the underlying stream. I guess closing the protomux channel would do this, and it would remove the peer. However I'm not sure if there's a way to access the protomux channel from the stream returned from
core.replicate()
?The text was updated successfully, but these errors were encountered: