Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
catena2w committed Jun 3, 2016
1 parent 6c13607 commit 07a5489
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NxtLikeConsensusModule(AvgDelay: Duration = 5.seconds)
val BaseTargetGamma = normalize(64)

private val AvgDelayInSeconds: Long = AvgDelay.toSeconds

private def normalize(value: Long): Double = value * AvgDelayInSeconds / (60: Double)

override def isValid[TT](block: Block)(implicit transactionModule: TransactionModule[TT]): Boolean = Try {
Expand Down Expand Up @@ -106,7 +107,8 @@ class NxtLikeConsensusModule(AvgDelay: Duration = 5.seconds)
}

private def effectiveBalance[TT](account: Account)(implicit transactionModule: TransactionModule[TT]) =
transactionModule.blockStorage.state.asInstanceOf[BalanceSheet].balanceWithConfirmations(account.address, EffectiveBalanceDepth)
transactionModule.blockStorage.state.asInstanceOf[BalanceSheet]
.balanceWithConfirmations(account.address, EffectiveBalanceDepth)

private def calcGeneratorSignature(lastBlockData: NxtLikeConsensusBlockData, generator: PublicKeyAccount) =
hash(lastBlockData.generationSignature ++ generator.publicKey)
Expand All @@ -130,12 +132,11 @@ class NxtLikeConsensusModule(AvgDelay: Duration = 5.seconds)
}) / 1000

val baseTarget = (if (blocktimeAverage > AvgDelayInSeconds) {
(prevBaseTarget * Math.min(blocktimeAverage, MaxBlocktimeLimit)) / AvgDelayInSeconds
} else {
prevBaseTarget -
prevBaseTarget * BaseTargetGamma * (AvgDelayInSeconds - Math.max(blocktimeAverage, MinBlocktimeLimit)) /
(AvgDelayInSeconds * 100)
}).toLong
(prevBaseTarget * Math.min(blocktimeAverage, MaxBlocktimeLimit)) / AvgDelayInSeconds
} else {
prevBaseTarget - prevBaseTarget * BaseTargetGamma *
(AvgDelayInSeconds - Math.max(blocktimeAverage, MinBlocktimeLimit)) / (AvgDelayInSeconds * 100)
}).toLong
bounded(baseTarget, 1, Long.MaxValue).toLong
} else {
prevBaseTarget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class UnconfirmedPoolSynchronizer(application: Application) extends ViewSynchron
case m => log.error(s"Got unexpected transaction: $m")
}
}
}
}

0 comments on commit 07a5489

Please sign in to comment.