From 6699c2a8bc833ffa77491e830652b5541300f6a1 Mon Sep 17 00:00:00 2001 From: Bogdan Suierica Date: Tue, 26 Jan 2021 09:28:35 +0100 Subject: [PATCH] [ETCM-533] scalafmt --- .../ethereum/jsonrpc/EthProofService.scala | 19 +++++++++++++++---- .../ethereum/mpt/MerklePatriciaTrie.scala | 4 ++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/scala/io/iohk/ethereum/jsonrpc/EthProofService.scala b/src/main/scala/io/iohk/ethereum/jsonrpc/EthProofService.scala index f1eb87abda..64bba036e2 100644 --- a/src/main/scala/io/iohk/ethereum/jsonrpc/EthProofService.scala +++ b/src/main/scala/io/iohk/ethereum/jsonrpc/EthProofService.scala @@ -5,7 +5,14 @@ import cats.implicits._ import io.iohk.ethereum.consensus.blocks.BlockGenerator import io.iohk.ethereum.domain.{Account, Address, Block, Blockchain, UInt256} import io.iohk.ethereum.jsonrpc.ProofService.StorageValueProof.asRlpSerializedNode -import io.iohk.ethereum.jsonrpc.ProofService.{GetProofRequest, GetProofResponse, ProofAccount, StorageProof, StorageProofKey, StorageValueProof} +import io.iohk.ethereum.jsonrpc.ProofService.{ + GetProofRequest, + GetProofResponse, + ProofAccount, + StorageProof, + StorageProofKey, + StorageValueProof +} import io.iohk.ethereum.mpt.{MptNode, MptTraversals} import monix.eval.Task @@ -30,6 +37,7 @@ object ProofService { val value: BigInt val proof: Seq[ByteString] } + /** * Object proving a relationship of a storage value to an account's storageHash * @@ -40,13 +48,16 @@ object ProofService { case class StorageValueProof( key: StorageProofKey, value: BigInt = BigInt(0), - proof: Seq[ByteString] = Seq.empty[MptNode].map(asRlpSerializedNode)) extends StorageProof + proof: Seq[ByteString] = Seq.empty[MptNode].map(asRlpSerializedNode) + ) extends StorageProof object StorageValueProof { def apply(position: BigInt, value: Option[BigInt], proof: Option[Vector[MptNode]]): StorageValueProof = (value, proof) match { - case (Some(value), Some(proof)) => new StorageValueProof(key = StorageProofKey(position), value = value, proof = proof.map(asRlpSerializedNode)) - case (None, Some(proof)) => new StorageValueProof(key = StorageProofKey(position), proof = proof.map(asRlpSerializedNode)) + case (Some(value), Some(proof)) => + new StorageValueProof(key = StorageProofKey(position), value = value, proof = proof.map(asRlpSerializedNode)) + case (None, Some(proof)) => + new StorageValueProof(key = StorageProofKey(position), proof = proof.map(asRlpSerializedNode)) case (Some(value), None) => new StorageValueProof(key = StorageProofKey(position), value = value) case (None, None) => new StorageValueProof(key = StorageProofKey(position)) } diff --git a/src/main/scala/io/iohk/ethereum/mpt/MerklePatriciaTrie.scala b/src/main/scala/io/iohk/ethereum/mpt/MerklePatriciaTrie.scala index 0da42cf8ed..33783d0fef 100644 --- a/src/main/scala/io/iohk/ethereum/mpt/MerklePatriciaTrie.scala +++ b/src/main/scala/io/iohk/ethereum/mpt/MerklePatriciaTrie.scala @@ -9,7 +9,6 @@ import io.iohk.ethereum.rlp.RLPImplicits._ import io.iohk.ethereum.rlp.{encode => encodeRLP} import org.bouncycastle.util.encoders.Hex import io.iohk.ethereum.utils.ByteUtils.matchingLength - import scala.annotation.tailrec object MerklePatriciaTrie { @@ -103,7 +102,8 @@ class MerklePatriciaTrie[K, V] private (private[mpt] val rootNode: Option[MptNod def getProof(key: K): Option[Vector[MptNode]] = { pathTraverse[Vector[MptNode]](Vector.empty, mkKeyNibbles(key)) { case (acc, node) => node match { - case Some(nextNodeOnExt @ (_: BranchNode | _: ExtensionNode | _: LeafNode | _: HashNode)) => acc :+ nextNodeOnExt + case Some(nextNodeOnExt @ (_: BranchNode | _: ExtensionNode | _: LeafNode | _: HashNode)) => + acc :+ nextNodeOnExt case _ => acc } }