@@ -7,14 +7,12 @@ import io.iohk.ethereum.domain.{BlockHeader, Blockchain}
7
7
import io .iohk .ethereum .ommers .OmmersPool .{AddOmmers , GetOmmers , RemoveOmmers }
8
8
import scala .annotation .tailrec
9
9
10
- class OmmersPool (blockchain : Blockchain , ommersPoolSize : Int , ommerGenerationLimit : Int )
10
+ class OmmersPool (blockchain : Blockchain , ommersPoolSize : Int , ommerGenerationLimit : Int , returnedOmmersSizeLimit : Int )
11
11
extends Actor
12
12
with ActorLogging {
13
13
14
14
var ommersPool : Seq [BlockHeader ] = Nil
15
15
16
- val ommerSizeLimit : Int = 2
17
-
18
16
override def receive : Receive = {
19
17
case AddOmmers (ommers) =>
20
18
ommersPool = (ommers ++ ommersPool).take(ommersPoolSize).distinct
@@ -32,7 +30,7 @@ class OmmersPool(blockchain: Blockchain, ommersPoolSize: Int, ommerGenerationLim
32
30
val notAncestor = ancestors.find(_.hash == b.hash).isEmpty
33
31
ancestors.find(_.hash == b.parentHash).isDefined && notAncestor
34
32
}
35
- .take(ommerSizeLimit )
33
+ .take(returnedOmmersSizeLimit )
36
34
logStatus(event = s " Ommers given parent block ${Hex .toHexString(parentBlockHash.toArray)}" , ommers)
37
35
sender() ! OmmersPool .Ommers (ommers)
38
36
}
@@ -57,9 +55,21 @@ class OmmersPool(blockchain: Blockchain, ommersPoolSize: Int, ommerGenerationLim
57
55
58
56
object OmmersPool {
59
57
60
- // ommerGenerationLimit should be === 6 as is stated on section 11.1, eq. (143) of the YP
61
- def props (blockchain : Blockchain , ommersPoolSize : Int , ommerGenerationLimit : Int = 6 ): Props = Props (
62
- new OmmersPool (blockchain, ommersPoolSize, ommerGenerationLimit)
58
+ /**
59
+ * As is stated on section 11.1, eq. (143) of the YP
60
+ *
61
+ * @param ommerGenerationLimit should be === 6
62
+ * @param returnedOmmersSizeLimit should be === 2
63
+ *
64
+ * ^ Probably not worthy but those params could be placed in consensus config.
65
+ */
66
+ def props (
67
+ blockchain : Blockchain ,
68
+ ommersPoolSize : Int ,
69
+ ommerGenerationLimit : Int = 6 ,
70
+ returnedOmmersSizeLimit : Int = 2
71
+ ): Props = Props (
72
+ new OmmersPool (blockchain, ommersPoolSize, ommerGenerationLimit, returnedOmmersSizeLimit)
63
73
)
64
74
65
75
case class AddOmmers (ommers : List [BlockHeader ])
0 commit comments