Skip to content

Commit

Permalink
Improve readability in 'EclairImpl.sendToChannel'
Browse files Browse the repository at this point in the history
  • Loading branch information
araspitzu committed Apr 23, 2019
1 parent 595b0a1 commit 125cbbf
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,12 @@ class EclairImpl(appKit: Kit) extends Eclair {
* @return
*/
def sendToChannel(channelIdentifier: String, request: Any)(implicit timeout: Timeout): Future[Any] = {
(Try(ForwardShortId(ShortChannelId(channelIdentifier), request)) match {
case Success(value) => Left(value.shortChannelId)
Try(ForwardShortId(ShortChannelId(channelIdentifier), request)) match {
case Success(shortChannelIdRequest) => appKit.register ? shortChannelIdRequest
case Failure(_) => Try(Forward(ByteVector32.fromValidHex(channelIdentifier), request)) match {
case Success(v) => Right(v.channelId)
case Success(channelIdRequest) => appKit.register ? channelIdRequest
case Failure(_) => throw new RuntimeException(s"invalid channel identifier '$channelIdentifier'") // unrecoverable
}
}) match {
case Left(shortChannelId) => appKit.register ? ForwardShortId(shortChannelId, request)
case Right(channelId) => appKit.register ? Forward(channelId, request)
}
}

Expand Down

0 comments on commit 125cbbf

Please sign in to comment.