Skip to content

Commit aca891a

Browse files
authored
Merge pull request #722 from input-output-hk/ETCM-129-remove-unicode
[ETCM-129] prepare for Scala 2.13 replace ⇒ to =>
2 parents ba42652 + 6fc2486 commit aca891a

22 files changed

+87
-87
lines changed

src/main/scala/io/iohk/ethereum/consensus/ConsensusBuilder.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait ConsensusBuilder {
1717
* [[io.iohk.ethereum.consensus.ethash.EthashConsensus EthashConsensus]],
1818
*/
1919
trait StdConsensusBuilder extends ConsensusBuilder {
20-
self: VmBuilder with BlockchainBuilder with BlockchainConfigBuilder with ConsensusConfigBuilder with Logger
20+
self: VmBuilder with BlockchainBuilder with BlockchainConfigBuilder with ConsensusConfigBuilder with Logger =>
2121

2222
private lazy val mantisConfig = Config.config
2323

@@ -38,7 +38,7 @@ trait StdConsensusBuilder extends ConsensusBuilder {
3838

3939
val consensus =
4040
config.protocol match {
41-
case Protocol.Ethash | Protocol.MockedPow buildEthashConsensus()
41+
case Protocol.Ethash | Protocol.MockedPow => buildEthashConsensus()
4242
}
4343
log.info(s"Using '${protocol.name}' consensus [${consensus.getClass.getName}]")
4444

src/main/scala/io/iohk/ethereum/consensus/ConsensusConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object ConsensusConfig extends Logger {
4141
Protocol.Names.MockedPow
4242
)
4343

44-
final val AllowedProtocolsError = (s: String) Keys.Consensus +
44+
final val AllowedProtocolsError = (s: String) => Keys.Consensus +
4545
" is configured as '" + s + "'" +
4646
" but it should be one of " +
4747
AllowedProtocols.map("'" + _ + "'").mkString(",")

src/main/scala/io/iohk/ethereum/consensus/ConsensusConfigBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.iohk.ethereum.consensus
33
import io.iohk.ethereum.nodebuilder.ShutdownHookBuilder
44
import io.iohk.ethereum.utils.Config
55

6-
trait ConsensusConfigBuilder { self: ShutdownHookBuilder
6+
trait ConsensusConfigBuilder { self: ShutdownHookBuilder =>
77
protected def buildConsensusConfig(): ConsensusConfig = ConsensusConfig(Config.config)(this)
88

99
lazy val consensusConfig: ConsensusConfig = buildConsensusConfig()

src/main/scala/io/iohk/ethereum/consensus/TestConsensusBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import io.iohk.ethereum.utils.Logger
77
* A [[io.iohk.ethereum.consensus.ConsensusBuilder ConsensusBuilder]] that builds a
88
* [[io.iohk.ethereum.consensus.TestConsensus TestConsensus]]
99
*/
10-
trait TestConsensusBuilder { self: StdConsensusBuilder
10+
trait TestConsensusBuilder { self: StdConsensusBuilder =>
1111
protected def buildTestConsensus(): TestConsensus =
1212
buildConsensus().asInstanceOf[TestConsensus] // we are in tests, so if we get an exception, so be it
1313
}

src/main/scala/io/iohk/ethereum/consensus/ethash/EthashConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.iohk.ethereum
22
package consensus
33
package ethash
44

5-
import com.typesafe.config.{Config TypesafeConfig}
5+
import com.typesafe.config.{Config => TypesafeConfig}
66

77
import scala.concurrent.duration.{FiniteDuration, _}
88

src/main/scala/io/iohk/ethereum/consensus/ethash/EthashConsensus.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ class EthashConsensus private(
5454

5555
private[this] def startMiningProcess(node: Node): Unit = {
5656
atomicMiner.get() match {
57-
case None
57+
case None =>
5858
val miner = config.generic.protocol match {
5959
case Ethash => EthashMiner(node)
6060
case MockedPow => MockedMiner(node)
6161
}
6262
atomicMiner.set(Some(miner))
6363
sendMiner(MinerProtocol.StartMining)
6464

65-
case _
65+
case _ =>
6666
}
6767
}
6868

@@ -95,7 +95,7 @@ class EthashConsensus private(
9595
/** Internal API, used for testing */
9696
protected def newBlockGenerator(validators: Validators): EthashBlockGenerator = {
9797
validators match {
98-
case _validators: ValidatorsExecutor
98+
case _validators: ValidatorsExecutor =>
9999
val blockPreparator = new BlockPreparator(
100100
vm = vm,
101101
signedTxValidator = validators.signedTransactionValidator,
@@ -112,7 +112,7 @@ class EthashConsensus private(
112112
blockTimestampProvider = blockGenerator.blockTimestampProvider
113113
)
114114

115-
case _
115+
case _ =>
116116
wrongValidatorsArgument[ValidatorsExecutor](validators)
117117
}
118118
}
@@ -121,7 +121,7 @@ class EthashConsensus private(
121121
/** Internal API, used for testing */
122122
def withValidators(validators: Validators): EthashConsensus = {
123123
validators match {
124-
case _validators: ValidatorsExecutor
124+
case _validators: ValidatorsExecutor =>
125125
val blockGenerator = newBlockGenerator(validators)
126126

127127
new EthashConsensus(
@@ -133,7 +133,7 @@ class EthashConsensus private(
133133
blockGenerator = blockGenerator
134134
)
135135

136-
case _
136+
case _ =>
137137
wrongValidatorsArgument[ValidatorsExecutor](validators)
138138
}
139139
}

src/main/scala/io/iohk/ethereum/consensus/ethash/EthashMiner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ object EthashMiner {
198198

199199
def apply(node: Node): ActorRef = {
200200
node.consensus match {
201-
case consensus: EthashConsensus
201+
case consensus: EthashConsensus =>
202202
val blockCreator = new EthashBlockCreator(
203203
pendingTransactionsManager = node.pendingTransactionsManager,
204204
getTransactionFromPoolTimeout = node.txPoolConfig.getTransactionFromPoolTimeout,
@@ -212,7 +212,7 @@ object EthashMiner {
212212
ethService = node.ethService
213213
)
214214
node.system.actorOf(minerProps)
215-
case consensus
215+
case consensus =>
216216
wrongConsensusArgument[EthashConsensus](consensus)
217217
}
218218
}

src/main/scala/io/iohk/ethereum/consensus/ethash/MockedMiner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ object MockedMiner {
107107

108108
def apply(node: Node): ActorRef = {
109109
node.consensus match {
110-
case consensus: EthashConsensus
110+
case consensus: EthashConsensus =>
111111
val blockCreator = new EthashBlockCreator(
112112
pendingTransactionsManager = node.pendingTransactionsManager,
113113
getTransactionFromPoolTimeout = node.txPoolConfig.getTransactionFromPoolTimeout,
@@ -120,7 +120,7 @@ object MockedMiner {
120120
syncEventListener = node.syncController
121121
)
122122
node.system.actorOf(minerProps)
123-
case consensus
123+
case consensus =>
124124
wrongConsensusArgument[EthashConsensus](consensus)
125125
}
126126
}

src/main/scala/io/iohk/ethereum/consensus/package.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import scala.reflect.ClassTag
1313
* Different consensus protocols are implemented in sub-packages.
1414
*/
1515
package object consensus {
16-
final type GetBlockHeaderByHash = ByteString Option[BlockHeader]
17-
final type GetNBlocksBack = (ByteString, Int) Seq[Block]
16+
final type GetBlockHeaderByHash = ByteString => Option[BlockHeader]
17+
final type GetNBlocksBack = (ByteString, Int) => Seq[Block]
1818

1919
def wrongConsensusArgument[T <: Consensus : ClassTag](consensus: Consensus): Nothing = {
2020
val requiredClass = implicitly[ClassTag[T]].runtimeClass
@@ -42,10 +42,10 @@ package object consensus {
4242
* if we run under [[io.iohk.ethereum.consensus.ethash.EthashConsensus EthashConsensus]]
4343
* then the `_then` function is called, otherwise the `_else` value is computed.
4444
*/
45-
def ifEthash[A](_then: EthashConsensus A)(_else: A): A =
45+
def ifEthash[A](_then: EthashConsensus => A)(_else: => A): A =
4646
consensus match {
47-
case ethash: EthashConsensus _then(ethash)
48-
case _ _else
47+
case ethash: EthashConsensus => _then(ethash)
48+
case _ => _else
4949
}
5050
}
5151
}

src/main/scala/io/iohk/ethereum/healthcheck/Healthcheck.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ import scala.util.{Failure, Success}
1818
*/
1919
case class Healthcheck[Error, Result](
2020
description: String,
21-
f: () Future[Either[Error, Result]],
22-
mapResultToError: Result Option[String] = (_: Result) None,
23-
mapErrorToError: Error Option[String] = (error: Error) Some(String.valueOf(error)),
24-
mapExceptionToError: Throwable Option[String] = (t: Throwable) Some(String.valueOf(t))
21+
f: () => Future[Either[Error, Result]],
22+
mapResultToError: Result => Option[String] = (_: Result) => None,
23+
mapErrorToError: Error => Option[String] = (error: Error) => Some(String.valueOf(error)),
24+
mapExceptionToError: Throwable => Option[String] = (t: Throwable) => Some(String.valueOf(t))
2525
) {
2626

2727
def apply()(implicit ec: ExecutionContext): Future[HealthcheckResult] = {
2828
f().transform {
29-
case Success(Left(error))
29+
case Success(Left(error)) =>
3030
Success(HealthcheckResult(description, mapErrorToError(error)))
31-
case Success(Right(result))
31+
case Success(Right(result)) =>
3232
Success(HealthcheckResult(description, mapResultToError(result)))
33-
case Failure(t)
33+
case Failure(t) =>
3434
Success(HealthcheckResult(description, mapExceptionToError(t)))
3535
}
3636
}

src/main/scala/io/iohk/ethereum/healthcheck/HealthcheckResult.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object HealthcheckResult {
1212
def apply(description: String, error: Option[String]): HealthcheckResult =
1313
new HealthcheckResult(
1414
description = description,
15-
status = error.fold(HealthcheckStatus.OK)(_ HealthcheckStatus.ERROR),
15+
status = error.fold(HealthcheckStatus.OK)(_ => HealthcheckStatus.ERROR),
1616
error = error
1717
)
1818
}

src/main/scala/io/iohk/ethereum/jsonrpc/EthService.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ class EthService(
219219
private[this] def fullConsensusConfig = consensus.config
220220
private[this] def consensusConfig: ConsensusConfig = fullConsensusConfig.generic
221221

222-
private[this] def ifEthash[Req, Res](req: Req)(f: Req Res): ServiceResponse[Res] = {
222+
private[this] def ifEthash[Req, Res](req: Req)(f: Req => Res): ServiceResponse[Res] = {
223223
@inline def F[A](x: A): Future[A] = Future.successful(x)
224-
consensus.ifEthash[ServiceResponse[Res]](_ F(Right(f(req))))(F(Left(JsonRpcErrors.ConsensusIsNotEthash)))
224+
consensus.ifEthash[ServiceResponse[Res]](_ => F(Right(f(req))))(F(Left(JsonRpcErrors.ConsensusIsNotEthash)))
225225
}
226226

227227
def protocolVersion(req: ProtocolVersionRequest): ServiceResponse[ProtocolVersionResponse] =
@@ -435,7 +435,7 @@ class EthService(
435435
}
436436

437437
def submitHashRate(req: SubmitHashRateRequest): ServiceResponse[SubmitHashRateResponse] =
438-
ifEthash(req) { req
438+
ifEthash(req) { req =>
439439
reportActive()
440440
hashRate.updateAndGet((t: Map[ByteString, (BigInt, Date)]) => {
441441
val now = new Date
@@ -464,7 +464,7 @@ class EthService(
464464
}
465465

466466
def getMining(req: GetMiningRequest): ServiceResponse[GetMiningResponse] =
467-
ifEthash(req) { _
467+
ifEthash(req) { _ =>
468468
val isMining = lastActive
469469
.updateAndGet((e: Option[Date]) => {
470470
e.filter { time =>
@@ -478,11 +478,11 @@ class EthService(
478478

479479
private def reportActive(): Option[Date] = {
480480
val now = new Date()
481-
lastActive.updateAndGet(_ Some(now))
481+
lastActive.updateAndGet(_ => Some(now))
482482
}
483483

484484
def getHashRate(req: GetHashRateRequest): ServiceResponse[GetHashRateResponse] =
485-
ifEthash(req) { _
485+
ifEthash(req) { _ =>
486486
val hashRates: Map[ByteString, (BigInt, Date)] = hashRate.updateAndGet((t: Map[ByteString, (BigInt, Date)]) => {
487487
removeObsoleteHashrates(new Date, t)
488488
})
@@ -502,7 +502,7 @@ class EthService(
502502
}
503503

504504
def getWork(req: GetWorkRequest): ServiceResponse[GetWorkResponse] =
505-
consensus.ifEthash(ethash {
505+
consensus.ifEthash(ethash => {
506506
reportActive()
507507
import io.iohk.ethereum.consensus.ethash.EthashUtils.{epoch, seed}
508508

@@ -531,7 +531,7 @@ class EthService(
531531
})(Future.successful(Left(JsonRpcErrors.ConsensusIsNotEthash)))
532532

533533
private def getOmmersFromPool(blockNumber: BigInt): Future[OmmersPool.Ommers] =
534-
consensus.ifEthash(ethash {
534+
consensus.ifEthash(ethash => {
535535
val miningConfig = ethash.config.specific
536536
implicit val timeout: Timeout = Timeout(miningConfig.ommerPoolQueryTimeout)
537537

@@ -559,7 +559,7 @@ class EthService(
559559
Future.successful(Right(GetCoinbaseResponse(consensusConfig.coinbase)))
560560

561561
def submitWork(req: SubmitWorkRequest): ServiceResponse[SubmitWorkResponse] =
562-
consensus.ifEthash[ServiceResponse[SubmitWorkResponse]](ethash {
562+
consensus.ifEthash[ServiceResponse[SubmitWorkResponse]](ethash => {
563563
reportActive()
564564
Future {
565565
ethash.blockGenerator.getPrepared(req.powHeaderHash) match {

src/main/scala/io/iohk/ethereum/jsonrpc/JsonRpcHealthcheck.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ import io.iohk.ethereum.healthcheck.Healthcheck
55
object JsonRpcHealthcheck {
66
type T[R] = Healthcheck[JsonRpcError, R]
77

8-
def apply[R](description: String, f: () ServiceResponse[R]): T[R] = Healthcheck(description, f)
8+
def apply[R](description: String, f: () => ServiceResponse[R]): T[R] = Healthcheck(description, f)
99
}

src/main/scala/io/iohk/ethereum/jsonrpc/NodeJsonRpcHealthChecker.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ class NodeJsonRpcHealthChecker(
1414

1515
protected def mainService: String = "node health"
1616

17-
final val listeningHC = JsonRpcHealthcheck("listening", () netService.listening(NetService.ListeningRequest()))
18-
final val peerCountHC = JsonRpcHealthcheck("peerCount", () netService.peerCount(PeerCountRequest()))
17+
final val listeningHC = JsonRpcHealthcheck("listening", () => netService.listening(NetService.ListeningRequest()))
18+
final val peerCountHC = JsonRpcHealthcheck("peerCount", () => netService.peerCount(PeerCountRequest()))
1919
final val earliestBlockHC = JsonRpcHealthcheck(
2020
"earliestBlock",
21-
() ethService.getBlockByNumber(BlockByNumberRequest(BlockParam.Earliest, true))
21+
() => ethService.getBlockByNumber(BlockByNumberRequest(BlockParam.Earliest, true))
2222
)
2323
final val latestBlockHC = JsonRpcHealthcheck(
2424
"latestBlock",
25-
() ethService.getBlockByNumber(BlockByNumberRequest(BlockParam.Latest, true))
25+
() => ethService.getBlockByNumber(BlockByNumberRequest(BlockParam.Latest, true))
2626
)
2727
final val pendingBlockHC = JsonRpcHealthcheck(
2828
"pendingBlock",
29-
() ethService.getBlockByNumber(BlockByNumberRequest(BlockParam.Pending, true))
29+
() => ethService.getBlockByNumber(BlockByNumberRequest(BlockParam.Pending, true))
3030
)
3131

3232
override def healthCheck(): Future[HealthcheckResponse] = {

src/main/scala/io/iohk/ethereum/jsonrpc/server/http/JsonRpcHttpServer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ trait JsonRpcHttpServer extends Json4sSupport {
6464
val responseF = jsonRpcHealthChecker.healthCheck()
6565
val httpResponseF =
6666
responseF.map {
67-
case response if response.isOK
67+
case response if response.isOK =>
6868
HttpResponse(
6969
status = StatusCodes.OK,
7070
entity = HttpEntity(ContentTypes.`application/json`, serialization.writePretty(response))
7171
)
72-
case response
72+
case response =>
7373
HttpResponse(
7474
status = StatusCodes.InternalServerError,
7575
entity = HttpEntity(ContentTypes.`application/json`, serialization.writePretty(response))

src/main/scala/io/iohk/ethereum/metrics/DeltaSpikeGauge.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DeltaSpikeGauge(name: String, metrics: Metrics) {
2121
}
2222
}
2323

24-
private[this] final val gauge = metrics.gauge(name, () getValue)
24+
private[this] final val gauge = metrics.gauge(name, () => getValue)
2525

2626
def trigger(): Unit = {
2727
if (isTriggeredRef.compareAndSet(false, true)) {

src/main/scala/io/iohk/ethereum/metrics/Metrics.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ case class Metrics(metricsPrefix: String, registry: MeterRegistry, serverPort: I
3131
* Returns a [[io.micrometer.core.instrument.Gauge Gauge]].
3232
* @param computeValue A function that computes the current gauge value.
3333
*/
34-
def gauge(name: String, computeValue: () Double): Gauge =
34+
def gauge(name: String, computeValue: () => Double): Gauge =
3535
Gauge
3636
// Note Never use `null` as the value for the second parameter.
3737
// If you do, you risk getting no metrics out of the gauge.
3838
// So we just use a vanilla `this` but any other non-`null`
3939
// value would also do.
40-
.builder(mkName(name), this, (_: Any) computeValue())
40+
.builder(mkName(name), this, (_: Any) => computeValue())
4141
.register(registry)
4242

4343
/**

src/main/scala/io/iohk/ethereum/metrics/MetricsConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.iohk.ethereum.metrics
22

3-
import com.typesafe.config.{Config TypesafeConfig}
3+
import com.typesafe.config.{Config => TypesafeConfig}
44

55
final case class MetricsConfig(
66
enabled: Boolean,

src/main/scala/io/iohk/ethereum/nodebuilder/NodeBuilder.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ trait SyncControllerBuilder {
498498
}
499499

500500
trait ShutdownHookBuilder {
501-
self: Logger
501+
self: Logger =>
502502
def shutdown(): Unit = {
503503
/* No default behaviour during shutdown. */
504504
}
@@ -511,10 +511,10 @@ trait ShutdownHookBuilder {
511511
}
512512
})
513513

514-
def shutdownOnError[A](f: A): A = {
514+
def shutdownOnError[A](f: => A): A = {
515515
Try(f) match {
516-
case Success(v) v
517-
case Failure(t)
516+
case Success(v) => v
517+
case Failure(t) =>
518518
log.error(t.getMessage, t)
519519
shutdown()
520520
throw t

src/main/scala/io/iohk/ethereum/utils/Ref.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class Ref[T <: AnyRef] {
99
private[this] final val ref = new AtomicReference[Option[T]](None)
1010

1111
// set once (but not necessarily compute once)
12-
final def setOnce(t: T): Boolean = ref.get().isEmpty && ref.compareAndSet(None, Some(t))
12+
final def setOnce(t: => T): Boolean = ref.get().isEmpty && ref.compareAndSet(None, Some(t))
1313

1414
final def isDefined: Boolean = ref.get().isDefined
1515
final def isEmpty: Boolean = ref.get().isEmpty
1616

17-
final def map[U](f: T U): Option[U] = ref.get().map(f)
18-
final def foreach[U](f: T U): Unit = map(f)
17+
final def map[U](f: T => U): Option[U] = ref.get().map(f)
18+
final def foreach[U](f: T => U): Unit = map(f)
1919
}

0 commit comments

Comments
 (0)