File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
src/main/scala/io/iohk/ethereum Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ object RLPCodecs {
45
45
implicit val nodeRLPCodec : RLPCodec [Node ] =
46
46
RLPCodec .instance[Node ](
47
47
{ case Node (id, address) =>
48
- RLPEncoder .encode(address).asInstanceOf [RLPList ] ++ RLPList (id)
48
+ RLPEncoder .encode(address).asInstanceOf [RLPList ] :+ id
49
49
},
50
50
{
51
51
case list @ RLPList (items @ _* ) if items.length >= 4 =>
@@ -62,10 +62,10 @@ object RLPCodecs {
62
62
{ case EthereumNodeRecord .Content (seq, attrs) =>
63
63
val kvs = attrs
64
64
.foldRight(RLPList ()) { case ((k, v), kvs) =>
65
- k.toArray :: v.toArray : : kvs
65
+ k.toArray +: v.toArray + : kvs
66
66
}
67
67
68
- seq : : kvs
68
+ seq + : kvs
69
69
},
70
70
{ case RLPList (seq, kvs @ _* ) =>
71
71
val attrs = kvs
@@ -89,7 +89,8 @@ object RLPCodecs {
89
89
implicit val enrRLPCodec : RLPCodec [EthereumNodeRecord ] =
90
90
RLPCodec .instance(
91
91
{ case EthereumNodeRecord (signature, content) =>
92
- signature.toByteArray :: RLPEncoder .encode(content).asInstanceOf [RLPList ]
92
+ val contentList = RLPEncoder .encode(content).asInstanceOf [RLPList ]
93
+ signature.toByteArray +: contentList
93
94
},
94
95
{ case RLPList (signature, content @ _* ) =>
95
96
EthereumNodeRecord (
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ object RLPImplicitDerivations {
58
58
}
59
59
60
60
private def decodeError [T ](subject : String , error : String , maybeEncodeable : Option [RLPEncodeable ] = None ): T =
61
- throw RLPException (s " error decoding $subject: $error" , maybeEncodeable)
61
+ throw RLPException (s " Cannot decode $subject: $error" , maybeEncodeable)
62
62
63
63
private def tryDecode [T ](subject : => String , encodeable : RLPEncodeable )(f : RLPEncodeable => T ): T = {
64
64
try {
Original file line number Diff line number Diff line change @@ -15,9 +15,12 @@ package object rlp {
15
15
sealed trait RLPEncodeable
16
16
17
17
case class RLPList (items : RLPEncodeable * ) extends RLPEncodeable {
18
- def : : (item : RLPEncodeable ): RLPList =
18
+ def + : (item : RLPEncodeable ): RLPList =
19
19
RLPList ((item +: items): _* )
20
20
21
+ def :+ (item : RLPEncodeable ): RLPList =
22
+ RLPList ((items :+ item): _* )
23
+
21
24
def ++ (other : RLPList ): RLPList =
22
25
RLPList ((items ++ other.items): _* )
23
26
}
@@ -96,7 +99,7 @@ package object rlp {
96
99
97
100
override def decode (rlp : RLPEncodeable ): T =
98
101
if (dec.isDefinedAt(rlp)) dec(rlp)
99
- else throw RLPException (s " Cannot decode type ${ct.runtimeClass.getSimpleName} from RLP. " , rlp)
102
+ else throw RLPException (s " Cannot decode type ${ct.runtimeClass.getSimpleName} from unexpected RLP. " , rlp)
100
103
}
101
104
102
105
def apply [T ](enc : RLPEncoder [T ], dec : RLPDecoder [T ]): RLPCodec [T ] =
You can’t perform that action at this time.
0 commit comments