@@ -565,14 +565,6 @@ case class Commitment(fundingTxIndex: Long,
565
565
return Left (TooManyAcceptedHtlcs (params.channelId, maximum = params.localParams.maxAcceptedHtlcs))
566
566
}
567
567
568
- // Jamming protection
569
- // Must be the last checks so that they can be ignored for shadow deployment.
570
- for ((amountMsat, i) <- incomingHtlcs.toSeq.map(_.amountMsat).sorted.zipWithIndex) {
571
- if ((amountMsat.toLong < 1 ) || (math.log(amountMsat.toLong.toDouble) * params.localParams.maxAcceptedHtlcs / math.log(params.localParams.maxHtlcValueInFlightMsat.toLong.toDouble / params.localParams.maxAcceptedHtlcs) < i)) {
572
- return Left (TooManySmallHtlcs (params.channelId, number = i + 1 , below = amountMsat))
573
- }
574
- }
575
-
576
568
Right (())
577
569
}
578
570
@@ -901,7 +893,7 @@ case class Commitments(params: ChannelParams,
901
893
.getOrElse(Right (copy(changes = changes1, originChannels = originChannels1), add))
902
894
}
903
895
904
- def receiveAdd (add : UpdateAddHtlc , feerates : FeeratesPerKw , feeConf : OnChainFeeConf )( implicit log : LoggingAdapter ) : Either [ChannelException , Commitments ] = {
896
+ def receiveAdd (add : UpdateAddHtlc , feerates : FeeratesPerKw , feeConf : OnChainFeeConf ): Either [ChannelException , Commitments ] = {
905
897
if (add.id != changes.remoteNextHtlcId) {
906
898
return Left (UnexpectedHtlcId (channelId, expected = changes.remoteNextHtlcId, actual = add.id))
907
899
}
@@ -914,21 +906,8 @@ case class Commitments(params: ChannelParams,
914
906
915
907
val changes1 = changes.addRemoteProposal(add).copy(remoteNextHtlcId = changes.remoteNextHtlcId + 1 )
916
908
// we verify that this htlc is allowed in every active commitment
917
- val canReceiveAdds = active.map(_.canReceiveAdd(add.amountMsat, params, changes1, feerates, feeConf))
918
- // Log only for jamming protection.
919
- canReceiveAdds.collectFirst {
920
- case Left (f : TooManySmallHtlcs ) =>
921
- log.info(" TooManySmallHtlcs: {} incoming HTLCs are below {}}" , f.number, f.below)
922
- Metrics .dropHtlc(f, Tags .Directions .Incoming )
923
- }
924
- canReceiveAdds.flatMap { // TODO: We ignore jamming protection, delete this flatMap to activate jamming protection.
925
- case Left (_ : TooManySmallHtlcs ) | Left (_ : ConfidenceTooLow ) => None
926
- case x => Some (x)
927
- }
928
- .collectFirst { case Left (f) =>
929
- Metrics .dropHtlc(f, Tags .Directions .Incoming )
930
- Left (f)
931
- }
909
+ active.map(_.canReceiveAdd(add.amountMsat, params, changes1, feerates, feeConf))
910
+ .collectFirst { case Left (f) => Left (f) }
932
911
.getOrElse(Right (copy(changes = changes1)))
933
912
}
934
913
0 commit comments