@@ -4,7 +4,7 @@ import akka.util.ByteString
4
4
import cats .implicits ._
5
5
import io .iohk .ethereum .consensus .blocks .BlockGenerator
6
6
import io .iohk .ethereum .domain .{Account , Address , Block , Blockchain , UInt256 }
7
- import io .iohk .ethereum .jsonrpc .ProofService .StorageValueProof .asRlpSerializedNode
7
+ import io .iohk .ethereum .jsonrpc .ProofService .StorageProof .asRlpSerializedNode
8
8
import io .iohk .ethereum .jsonrpc .ProofService .{
9
9
GetProofRequest ,
10
10
GetProofResponse ,
@@ -33,42 +33,45 @@ object ProofService {
33
33
case class GetProofResponse (proofAccount : ProofAccount )
34
34
35
35
sealed trait StorageProof {
36
- val key : StorageProofKey
37
- val value : BigInt
38
- val proof : Seq [ByteString ]
36
+ def key : StorageProofKey
37
+ def value : BigInt
38
+ def proof : Seq [ByteString ]
39
39
}
40
40
41
- /**
42
- * Object proving a relationship of a storage value to an account's storageHash
43
- *
44
- * @param key storage proof key
45
- * @param value the value of the storage slot in its account tree
46
- * @param proof the set of node values needed to traverse a patricia merkle tree (from root to leaf) to retrieve a value
47
- */
48
- case class StorageValueProof (
49
- key : StorageProofKey ,
50
- value : BigInt = BigInt (0 ),
51
- proof : Seq [ByteString ] = Seq .empty[MptNode ].map(asRlpSerializedNode)
52
- ) extends StorageProof
53
-
54
- object StorageValueProof {
55
- def apply (position : BigInt , value : Option [BigInt ], proof : Option [Vector [MptNode ]]): StorageValueProof =
41
+ object StorageProof {
42
+ def apply (position : BigInt , value : Option [BigInt ], proof : Option [Vector [MptNode ]]): StorageProof =
56
43
(value, proof) match {
57
44
case (Some (value), Some (proof)) =>
58
- new StorageValueProof (key = StorageProofKey (position), value = value, proof = proof.map(asRlpSerializedNode))
45
+ StorageValueProof (StorageProofKey (position), value, proof.map(asRlpSerializedNode))
59
46
case (None , Some (proof)) =>
60
- new StorageValueProof (key = StorageProofKey (position), proof = proof.map(asRlpSerializedNode))
61
- case (Some (value), None ) => new StorageValueProof (key = StorageProofKey (position), value = value)
62
- case (None , None ) => new StorageValueProof (key = StorageProofKey (position))
47
+ EmptyStorageValue ( StorageProofKey (position), proof.map(asRlpSerializedNode))
48
+ case (Some (value), None ) => EmptyStorageProof ( StorageProofKey (position), value)
49
+ case (None , None ) => EmptyStorageValueProof ( StorageProofKey (position))
63
50
}
64
51
65
- def apply (position : BigInt ): StorageValueProof =
66
- new StorageValueProof (key = StorageProofKey (position))
67
-
68
52
def asRlpSerializedNode (node : MptNode ): ByteString =
69
53
ByteString (MptTraversals .encodeNode(node))
70
54
}
71
55
56
+ /**
57
+ * Object proving a relationship of a storage value to an account's storageHash
58
+ *
59
+ * @param key storage proof key
60
+ * @param value the value of the storage slot in its account tree
61
+ * @param proof the set of node values needed to traverse a patricia merkle tree (from root to leaf) to retrieve a value
62
+ */
63
+ case class EmptyStorageValueProof (key : StorageProofKey ) extends StorageProof {
64
+ val value : BigInt = BigInt (0 )
65
+ val proof : Seq [ByteString ] = Seq .empty[MptNode ].map(asRlpSerializedNode)
66
+ }
67
+ case class EmptyStorageValue (key : StorageProofKey , proof : Seq [ByteString ]) extends StorageProof {
68
+ val value : BigInt = BigInt (0 )
69
+ }
70
+ case class EmptyStorageProof (key : StorageProofKey , value : BigInt ) extends StorageProof {
71
+ val proof : Seq [ByteString ] = Seq .empty[MptNode ].map(asRlpSerializedNode)
72
+ }
73
+ case class StorageValueProof (key : StorageProofKey , value : BigInt , proof : Seq [ByteString ]) extends StorageProof
74
+
72
75
/** The key used to get the storage slot in its account tree */
73
76
case class StorageProofKey (v : BigInt ) extends AnyVal
74
77
0 commit comments