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

Drop compat code for java 8 #2155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ object NodeParams extends Logging {
require(pluginFeatureSet.size == pluginMessageParams.size, "Duplicate plugin feature bits found")

val interceptOpenChannelPlugins = pluginParams.collect { case p: InterceptOpenChannelPlugin => p }
require(interceptOpenChannelPlugins.size <= 1, s"At most one plugin is allowed to intercept channel open messages, but multiple such plugins were registered: ${interceptOpenChannelPlugins.map(_.getClass.getSimpleName).mkString(", ")}. Disable conflicting plugins and restart eclair.")
require(interceptOpenChannelPlugins.size <= 1, s"At most one plugin is allowed to intercept channel open messages, but multiple such plugins were registered: ${interceptOpenChannelPlugins.map(_.getClass.getPrettySimpleName).mkString(", ")}. Disable conflicting plugins and restart eclair.")

val coreAndPluginFeatures: Features[Feature] = features.copy(unknown = features.unknown ++ pluginMessageParams.map(_.pluginFeature))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ case class RbfAttemptAborted (override val channelId: Byte
case class SpliceAttemptAborted (override val channelId: ByteVector32) extends ChannelException(channelId, "splice attempt aborted")
case class SpliceAttemptTimedOut (override val channelId: ByteVector32) extends ChannelException(channelId, "splice attempt took too long, disconnecting")
case class DualFundingAborted (override val channelId: ByteVector32) extends ChannelException(channelId, "dual funding aborted")
case class UnexpectedInteractiveTxMessage (override val channelId: ByteVector32, msg: InteractiveTxMessage) extends ChannelException(channelId, s"unexpected interactive-tx message (${msg.getClass.getSimpleName})")
case class UnexpectedInteractiveTxMessage (override val channelId: ByteVector32, msg: InteractiveTxMessage) extends ChannelException(channelId, s"unexpected interactive-tx message (${msg.getClass.getPrettySimpleName})")
case class UnexpectedFundingSignatures (override val channelId: ByteVector32) extends ChannelException(channelId, "unexpected funding signatures (tx_signatures)")
case class InvalidFundingFeerate (override val channelId: ByteVector32, targetFeerate: FeeratePerKw, actualFeerate: FeeratePerKw) extends ChannelException(channelId, s"invalid funding feerate: target=$targetFeerate actual=$actualFeerate")
case class InvalidFundingSignature (override val channelId: ByteVector32, txId_opt: Option[TxId]) extends ChannelException(channelId, s"invalid funding signature: txId=${txId_opt.map(_.toString()).getOrElse("n/a")}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ case class Commitments(params: ChannelParams,
def updateLocalFundingStatus(fundingTxId: TxId, status: LocalFundingStatus)(implicit log: LoggingAdapter): Either[Commitments, (Commitments, Commitment)] =
updateFundingStatus(fundingTxId, _ => {
case c if c.fundingTxId == fundingTxId =>
log.info(s"setting localFundingStatus=${status.getClass.getSimpleName} for fundingTxId=${c.fundingTxId} fundingTxIndex=${c.fundingTxIndex}")
log.info(s"setting localFundingStatus=${status.getClass.getPrettySimpleName} for fundingTxId=${c.fundingTxId} fundingTxIndex=${c.fundingTxIndex}")
c.copy(localFundingStatus = status)
case c => c
})
Expand All @@ -1191,7 +1191,7 @@ case class Commitments(params: ChannelParams,
updateFundingStatus(fundingTxId, fundingTxIndex => {
// all funding older than this one are considered locked
case c if c.fundingTxId == fundingTxId || c.fundingTxIndex < fundingTxIndex =>
log.info(s"setting remoteFundingStatus=${RemoteFundingStatus.Locked.getClass.getSimpleName} for fundingTxId=${c.fundingTxId} fundingTxIndex=${c.fundingTxIndex}")
log.info(s"setting remoteFundingStatus=${RemoteFundingStatus.Locked.getClass.getPrettySimpleName} for fundingTxId=${c.fundingTxId} fundingTxIndex=${c.fundingTxIndex}")
c.copy(remoteFundingStatus = RemoteFundingStatus.Locked)
case c => c
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with

when(NORMAL)(handleExceptions {
case Event(c: ForbiddenCommandDuringQuiescence, d: DATA_NORMAL) if d.spliceStatus.isInstanceOf[QuiescenceNegotiation] =>
val error = ForbiddenDuringQuiescence(d.channelId, c.getClass.getSimpleName)
val error = ForbiddenDuringQuiescence(d.channelId, c.getClass.getPrettySimpleName)
c match {
case c: CMD_ADD_HTLC => handleAddHtlcCommandError(c, error, Some(d.channelUpdate))
// Htlc settlement commands are ignored and will be replayed when not quiescent.
Expand All @@ -400,7 +400,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
}

case Event(c: ForbiddenCommandDuringSplice, d: DATA_NORMAL) if d.spliceStatus.isInstanceOf[QuiescentSpliceStatus] =>
val error = ForbiddenDuringSplice(d.channelId, c.getClass.getSimpleName)
val error = ForbiddenDuringSplice(d.channelId, c.getClass.getPrettySimpleName)
c match {
case c: CMD_ADD_HTLC => handleAddHtlcCommandError(c, error, Some(d.channelUpdate))
// Htlc settlement commands are ignored and will be replayed when not quiescent.
Expand All @@ -411,8 +411,8 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
}

case Event(msg: ForbiddenMessageDuringSplice, d: DATA_NORMAL) if d.spliceStatus.isInstanceOf[QuiescentSpliceStatus] =>
log.warning("received forbidden message {} during splicing with status {}", msg.getClass.getSimpleName, d.spliceStatus.getClass.getSimpleName)
val error = ForbiddenDuringSplice(d.channelId, msg.getClass.getSimpleName)
log.warning("received forbidden message {} during splicing with status {}", msg.getClass.getPrettySimpleName, d.spliceStatus.getClass.getPrettySimpleName)
val error = ForbiddenDuringSplice(d.channelId, msg.getClass.getPrettySimpleName)
// We forward preimages as soon as possible to the upstream channel because it allows us to pull funds.
msg match {
case fulfill: UpdateFulfillHtlc => d.commitments.receiveFulfill(fulfill) match {
Expand Down Expand Up @@ -1050,7 +1050,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
txBuilder ! InteractiveTxBuilder.ReceiveMessage(msg)
stay()
case _ =>
log.info("ignoring unexpected interactive-tx message: {}", msg.getClass.getSimpleName)
log.info("ignoring unexpected interactive-tx message: {}", msg.getClass.getPrettySimpleName)
stay() sending Warning(d.channelId, UnexpectedInteractiveTxMessage(d.channelId, msg).getMessage)
}

Expand Down Expand Up @@ -1094,7 +1094,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
if (sessionId == currentSessionId) {
stay() sending msg
} else {
log.info("ignoring outgoing interactive-tx message {} from previous session", msg.getClass.getSimpleName)
log.info("ignoring outgoing interactive-tx message {} from previous session", msg.getClass.getPrettySimpleName)
stay()
}
case InteractiveTxBuilder.Succeeded(signingSession, commitSig, liquidityPurchase_opt) =>
Expand All @@ -1113,7 +1113,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
}
case _ =>
// This can happen if we received a tx_abort right before receiving the interactive-tx result.
log.warning("ignoring interactive-tx result with spliceStatus={}", d.spliceStatus.getClass.getSimpleName)
log.warning("ignoring interactive-tx result with spliceStatus={}", d.spliceStatus.getClass.getPrettySimpleName)
stay()
}

Expand Down Expand Up @@ -2625,15 +2625,15 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
}

private def handleAddHtlcCommandError(c: CMD_ADD_HTLC, cause: ChannelException, channelUpdate: Option[ChannelUpdate]) = {
log.warning(s"${cause.getMessage} while processing cmd=${c.getClass.getSimpleName} in state=$stateName")
log.warning(s"${cause.getMessage} while processing cmd=${c.getClass.getPrettySimpleName} in state=$stateName")
val replyTo = if (c.replyTo == ActorRef.noSender) sender() else c.replyTo
replyTo ! RES_ADD_FAILED(c, cause, channelUpdate)
context.system.eventStream.publish(ChannelErrorOccurred(self, stateData.channelId, remoteNodeId, LocalError(cause), isFatal = false))
stay()
}

private def handleCommandError(cause: ChannelException, c: channel.Command) = {
log.warning(s"${cause.getMessage} while processing cmd=${c.getClass.getSimpleName} in state=$stateName")
log.warning(s"${cause.getMessage} while processing cmd=${c.getClass.getPrettySimpleName} in state=$stateName")
val replyTo_opt = c match {
case hasOptionalReplyTo: HasOptionalReplyToCommand => hasOptionalReplyTo.replyTo_opt
case hasReplyTo: HasReplyToCommand => if (hasReplyTo.replyTo == ActorRef.noSender) Some(sender()) else Some(hasReplyTo.replyTo)
Expand Down Expand Up @@ -2828,7 +2828,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
log.warning("quiescence timed out with no ongoing splice, did we forget to cancel the timer?")
stay()
} else {
log.warning("quiescence timed out in state {}, closing connection", d.spliceStatus.getClass.getSimpleName)
log.warning("quiescence timed out in state {}, closing connection", d.spliceStatus.getClass.getPrettySimpleName)
context.system.scheduler.scheduleOnce(2 second, peer, Peer.Disconnect(remoteNodeId))
stay() sending Warning(d.channelId, SpliceAttemptTimedOut(d.channelId).getMessage)
}
Expand Down Expand Up @@ -2869,7 +2869,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
override val supervisorStrategy: OneForOneStrategy = OneForOneStrategy(loggingEnabled = true) { case _ => SupervisorStrategy.Escalate }

override def aroundReceive(receive: Actor.Receive, msg: Any): Unit = {
KamonExt.time(ProcessMessage.withTag("MessageType", msg.getClass.getSimpleName)) {
KamonExt.time(ProcessMessage.withTag("MessageType", msg.getClass.getPrettySimpleName)) {
super.aroundReceive(receive, msg)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers {
rollbackFundingAttempt(d.signingSession.fundingTx.tx, Nil)
goto(CLOSED) sending TxAbort(d.channelId, DualFundingAborted(d.channelId).getMessage)
case msg: InteractiveTxConstructionMessage =>
log.info("received unexpected interactive-tx message: {}", msg.getClass.getSimpleName)
log.info("received unexpected interactive-tx message: {}", msg.getClass.getPrettySimpleName)
stay() sending Warning(d.channelId, UnexpectedInteractiveTxMessage(d.channelId, msg).getMessage)
case _: TxInitRbf =>
log.info("ignoring unexpected tx_init_rbf message")
Expand Down Expand Up @@ -631,7 +631,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers {
txBuilder ! InteractiveTxBuilder.ReceiveMessage(msg)
stay()
case _ =>
log.info("ignoring unexpected interactive-tx message: {}", msg.getClass.getSimpleName)
log.info("ignoring unexpected interactive-tx message: {}", msg.getClass.getPrettySimpleName)
stay() sending Warning(d.channelId, UnexpectedInteractiveTxMessage(d.channelId, msg).getMessage)
}

Expand Down Expand Up @@ -706,7 +706,7 @@ trait ChannelOpenDualFunded extends DualFundingHandlers with ErrorHandlers {
}
case _ =>
// This can happen if we received a tx_abort right before receiving the interactive-tx result.
log.warning("ignoring interactive-tx result with rbfStatus={}", d.rbfStatus.getClass.getSimpleName)
log.warning("ignoring interactive-tx result with rbfStatus={}", d.rbfStatus.getClass.getPrettySimpleName)
stay()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package fr.acinq.eclair.channel.fsm
import akka.actor.typed.scaladsl.adapter.actorRefAdapter
import akka.actor.{ActorRef, FSM}
import fr.acinq.bitcoin.scalacompat.{ByteVector32, OutPoint, SatoshiLong, Transaction, TxId}
import fr.acinq.eclair.NotificationsLogger
import fr.acinq.eclair.{NotificationsLogger, PrettySimpleClassName}
import fr.acinq.eclair.NotificationsLogger.NotifyNodeOperator
import fr.acinq.eclair.blockchain.bitcoind.ZmqWatcher.{RelativeDelay, WatchOutputSpent, WatchTxConfirmed}
import fr.acinq.eclair.channel.Helpers.Closing
Expand Down Expand Up @@ -71,9 +71,9 @@ trait ErrorHandlers extends CommonHandlers {
log.warning(s"force-closing channel at user request")
case _ if msg.exists(_.isInstanceOf[OpenChannel]) || msg.exists(_.isInstanceOf[AcceptChannel]) =>
// invalid remote channel parameters are logged as warning
log.warning(s"${cause.getMessage} while processing msg=${msg.getOrElse("n/a").getClass.getSimpleName} in state=$stateName")
log.warning(s"${cause.getMessage} while processing msg=${msg.getOrElse("n/a").getClass.getPrettySimpleName} in state=$stateName")
case _: ChannelException =>
log.error(s"${cause.getMessage} while processing msg=${msg.getOrElse("n/a").getClass.getSimpleName} in state=$stateName")
log.error(s"${cause.getMessage} while processing msg=${msg.getOrElse("n/a").getClass.getPrettySimpleName} in state=$stateName")
case _ =>
// unhandled error: we dump the channel data, and print the stack trace
log.error(cause, s"msg=${msg.getOrElse("n/a")} stateData=$stateData:")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import fr.acinq.eclair.crypto.ChaCha20Poly1305.ChaCha20Poly1305Error
import fr.acinq.eclair.crypto.Noise._
import fr.acinq.eclair.remote.EclairInternalsSerializer.RemoteTypes
import fr.acinq.eclair.wire.protocol.{AnnouncementSignatures, RoutingMessage}
import fr.acinq.eclair.{Diagnostics, FSMDiagnosticActorLogging, Logs, getSimpleClassName}
import fr.acinq.eclair.{Diagnostics, FSMDiagnosticActorLogging, Logs, PrettySimpleClassName}
import scodec.bits.ByteVector
import scodec.{Attempt, Codec, DecodeResult}

Expand Down Expand Up @@ -264,7 +264,7 @@ class TransportHandler[T: ClassTag](keyPair: KeyPair, rs: Option[ByteVector], co
case Event(msg, d) =>
d match {
case n: NormalData[_] => log.warning(s"unhandled message $msg in state normal unackedSent=${n.unackedSent.size} unackedReceived=${n.unackedReceived.size} sendBuffer.lowPriority=${n.sendBuffer.lowPriority.size} sendBuffer.normalPriority=${n.sendBuffer.normalPriority.size}")
case _ => log.warning(s"unhandled message $msg in state ${d.getClass.getSimpleName}")
case _ => log.warning(s"unhandled message $msg in state ${d.getClass.getPrettySimpleName}")
}
stay()
}
Expand All @@ -278,7 +278,7 @@ class TransportHandler[T: ClassTag](keyPair: KeyPair, rs: Option[ByteVector], co
stateData match {
case normal: NormalData[_] =>
// NB: we deduplicate on the class name: each class will appear once but there may be many instances (less verbose and gives debug hints)
log.info("stopping (unackedReceived={} unackedSent={})", normal.unackedReceived.keys.map(getSimpleClassName).toSet.mkString(","), normal.unackedSent.map(getSimpleClassName))
log.info("stopping (unackedReceived={} unackedSent={})", normal.unackedReceived.keys.map(_.getClass.getPrettySimpleName).toSet.mkString(","), normal.unackedSent.map(_.getClass.getPrettySimpleName))
case _ =>
log.info("stopping")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import fr.acinq.eclair.db.Monitoring.Tags.DbBackends
import fr.acinq.eclair.db._
import fr.acinq.eclair.payment._
import fr.acinq.eclair.transactions.Transactions.PlaceHolderPubKey
import fr.acinq.eclair.{MilliSatoshi, MilliSatoshiLong, Paginated, TimestampMilli}
import fr.acinq.eclair.{MilliSatoshi, MilliSatoshiLong, Paginated, PrettySimpleClassName, TimestampMilli}
import grizzled.slf4j.Logging

import java.sql.{Statement, Timestamp}
Expand Down Expand Up @@ -302,7 +302,7 @@ class PgAuditDb(implicit ds: DataSource) extends AuditDb with Logging {
inTransaction { pg =>
using(pg.prepareStatement("INSERT INTO audit.channel_errors VALUES (?, ?, ?, ?, ?, ?)")) { statement =>
val (errorName, errorMessage) = e.error match {
case LocalError(t) => (t.getClass.getSimpleName, t.getMessage)
case LocalError(t) => (t.getClass.getPrettySimpleName, t.getMessage)
case RemoteError(error) => ("remote", error.toAscii)
}
statement.setString(1, e.channelId.toHex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PgPaymentsDb(implicit ds: DataSource, lock: PgLock) extends PaymentsDb wit
}

override def addOutgoingPayment(sent: OutgoingPayment): Unit = withMetrics("payments/add-outgoing", DbBackends.Postgres) {
require(sent.status == OutgoingPaymentStatus.Pending, s"outgoing payment isn't pending (${sent.status.getClass.getSimpleName})")
require(sent.status == OutgoingPaymentStatus.Pending, s"outgoing payment isn't pending (${sent.status.getClass.getPrettySimpleName})")
withLock { pg =>
using(pg.prepareStatement("INSERT INTO payments.sent (id, parent_id, external_id, payment_hash, payment_type, amount_msat, recipient_amount_msat, recipient_node_id, created_at, payment_request, offer_id, payer_key) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { statement =>
statement.setString(1, sent.id.toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import fr.acinq.eclair.db.Monitoring.Tags.DbBackends
import fr.acinq.eclair.db._
import fr.acinq.eclair.payment._
import fr.acinq.eclair.transactions.Transactions.PlaceHolderPubKey
import fr.acinq.eclair.{MilliSatoshi, MilliSatoshiLong, Paginated, TimestampMilli}
import fr.acinq.eclair.{MilliSatoshi, MilliSatoshiLong, Paginated, PrettySimpleClassName, TimestampMilli}
import grizzled.slf4j.Logging

import java.sql.{Connection, Statement}
Expand Down Expand Up @@ -284,7 +284,7 @@ class SqliteAuditDb(val sqlite: Connection) extends AuditDb with Logging {
override def add(e: ChannelErrorOccurred): Unit = withMetrics("audit/add-channel-error", DbBackends.Sqlite) {
using(sqlite.prepareStatement("INSERT INTO channel_errors VALUES (?, ?, ?, ?, ?, ?)")) { statement =>
val (errorName, errorMessage) = e.error match {
case LocalError(t) => (t.getClass.getSimpleName, t.getMessage)
case LocalError(t) => (t.getClass.getPrettySimpleName, t.getMessage)
case RemoteError(error) => ("remote", error.toAscii)
}
statement.setBytes(1, e.channelId.toArray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class SqlitePaymentsDb(val sqlite: Connection) extends PaymentsDb with Logging {
}

override def addOutgoingPayment(sent: OutgoingPayment): Unit = withMetrics("payments/add-outgoing", DbBackends.Sqlite) {
require(sent.status == OutgoingPaymentStatus.Pending, s"outgoing payment isn't pending (${sent.status.getClass.getSimpleName})")
require(sent.status == OutgoingPaymentStatus.Pending, s"outgoing payment isn't pending (${sent.status.getClass.getPrettySimpleName})")
using(sqlite.prepareStatement("INSERT INTO sent_payments (id, parent_id, external_id, payment_hash, payment_type, amount_msat, recipient_amount_msat, recipient_node_id, created_at, payment_request, offer_id, payer_key) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { statement =>
statement.setString(1, sent.id.toString)
statement.setString(2, sent.parentId.toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private class MessageRelay(nodeParams: NodeParams,
case EncodedNodeId.WithPublicKey.Plain(nodeId) if nodeId == nodeParams.nodeId =>
OnionMessages.process(nodeParams.privateKey, msg) match {
case OnionMessages.DropMessage(reason) =>
Metrics.OnionMessagesNotRelayed.withTag(Tags.Reason, reason.getClass.getSimpleName).increment()
Metrics.OnionMessagesNotRelayed.withTag(Tags.Reason, reason.getClass.getPrettySimpleName).increment()
replyTo_opt.foreach(_ ! DroppedMessage(messageId, reason))
Behaviors.stopped
case OnionMessages.SendMessage(nextNode, nextMessage) =>
Expand Down
Loading
Loading