mirror of
https://github.com/ACINQ/eclair.git
synced 2025-02-22 22:25:26 +01:00
Share NioEventLoopGroup
across Electrum clients (#783)
`NioEventLoopGroup` is expensive to create and should be shared with all clients. This also prevents issues when several event loop groups are created and are not shutdown correctly.
This commit is contained in:
parent
723d0deed2
commit
521aa8adcd
1 changed files with 5 additions and 3 deletions
|
@ -26,7 +26,7 @@ import fr.acinq.eclair.blockchain.electrum.ElectrumClient.SSL
|
|||
import io.netty.bootstrap.Bootstrap
|
||||
import io.netty.channel._
|
||||
import io.netty.channel.nio.NioEventLoopGroup
|
||||
import io.netty.channel.socket.{SocketChannel, SocketChannelConfig}
|
||||
import io.netty.channel.socket.SocketChannel
|
||||
import io.netty.channel.socket.nio.NioSocketChannel
|
||||
import io.netty.handler.codec.string.{LineEncoder, StringDecoder}
|
||||
import io.netty.handler.codec.{LineBasedFrameDecoder, MessageToMessageDecoder, MessageToMessageEncoder}
|
||||
|
@ -48,8 +48,6 @@ class ElectrumClient(serverAddress: InetSocketAddress, ssl: SSL)(implicit val ec
|
|||
|
||||
implicit val formats = DefaultFormats
|
||||
|
||||
val workerGroup = new NioEventLoopGroup()
|
||||
|
||||
val b = new Bootstrap
|
||||
b.group(workerGroup)
|
||||
b.channel(classOf[NioSocketChannel])
|
||||
|
@ -308,6 +306,10 @@ class ElectrumClient(serverAddress: InetSocketAddress, ssl: SSL)(implicit val ec
|
|||
}
|
||||
|
||||
object ElectrumClient {
|
||||
|
||||
// this is expensive and shared with all clients
|
||||
val workerGroup = new NioEventLoopGroup()
|
||||
|
||||
/**
|
||||
* Utility function to converts a publicKeyScript to electrum's scripthash
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue