Skip to content

Commit

Permalink
[ETCM-533] scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bsuieric committed Jan 26, 2021
1 parent 60c28af commit 6699c2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/main/scala/io/iohk/ethereum/jsonrpc/EthProofService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
*
Expand All @@ -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))
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/io/iohk/ethereum/mpt/MerklePatriciaTrie.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 6699c2a

Please sign in to comment.