Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for PR #299 #13

Merged
merged 3 commits into from
Aug 18, 2023
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
6 changes: 4 additions & 2 deletions libp2p/src/main/kotlin/io/libp2p/core/dsl/Builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import io.libp2p.transport.tcp.TcpTransport
import io.netty.channel.ChannelHandler
import io.netty.handler.logging.LogLevel
import io.netty.handler.logging.LoggingHandler
import java.util.concurrent.CopyOnWriteArrayList

typealias TransportCtor = (ConnectionUpgrader) -> Transport
typealias SecureChannelCtor = (PrivKey, List<StreamMuxer>) -> SecureChannel
Expand Down Expand Up @@ -173,7 +174,8 @@ open class Builder {
}
}

val muxers = muxers.map { it.createMuxer(streamMultistreamProtocol, protocols.values) }
val updatableProtocols: MutableList<ProtocolBinding<Any>> = CopyOnWriteArrayList(protocols.values)
val muxers = muxers.map { it.createMuxer(streamMultistreamProtocol, updatableProtocols) }

val secureChannels = secureChannels.values.map { it(privKey, muxers) }

Expand Down Expand Up @@ -201,7 +203,7 @@ open class Builder {
networkImpl,
addressBook,
network.listen.map { Multiaddr(it) },
protocols.values,
updatableProtocols,
broadcastConnHandler,
streamVisitors
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ import java.time.Duration
import java.util.concurrent.CompletableFuture

class MultistreamImpl<TController>(
initList: List<ProtocolBinding<TController>> = listOf(),
override val bindings: List<ProtocolBinding<TController>>,
val preHandler: P2PChannelHandler<*>? = null,
val postHandler: P2PChannelHandler<*>? = null,
val negotiationTimeLimit: Duration = DEFAULT_NEGOTIATION_TIME_LIMIT
) : Multistream<TController> {

override val bindings: List<ProtocolBinding<TController>> = initList

override fun initChannel(ch: P2PChannel): CompletableFuture<TController> {
return with(ch) {
preHandler?.also {
Expand Down