@@ -26,27 +26,33 @@ type unclesInfo struct {
26
26
}
27
27
28
28
func (m * modUncles ) apply (ctx * genBlockContext ) bool {
29
- merge := ctx .ChainConfig ().MergeNetsplitBlock
30
- if merge != nil && merge .Cmp (ctx .Number ()) <= 0 {
31
- return false // no uncles after merge
32
- }
33
- if ctx .NumberU64 () < 3 {
29
+ cfg := ctx .ChainConfig ()
30
+ merged := cfg .MergeNetsplitBlock != nil && cfg .MergeNetsplitBlock .Cmp (ctx .Number ()) <= 0
31
+ if merged || cfg .Ethash == nil || ctx .NumberU64 () < 3 {
34
32
return false
35
33
}
34
+
36
35
info := m .info [ctx .NumberU64 ()]
37
36
if len (info .Hashes ) >= 2 {
38
- return false
37
+ return false // block has enough uncles already
39
38
}
40
39
41
40
parent := ctx .ParentBlock ()
41
+ time := parent .Time () + 1
42
42
uncle := & types.Header {
43
43
Number : parent .Number (),
44
44
ParentHash : parent .ParentHash (),
45
+ Time : time ,
45
46
Extra : []byte (fmt .Sprintf ("hivechain uncle %d" , m .counter )),
46
47
}
48
+ // Initialize the remaining remaining header fields by converting to a full block.
47
49
ub := types .NewBlock (uncle , nil , nil , nil , trie .NewStackTrie (nil ))
48
50
uncle = ub .Header ()
51
+
52
+ // Add the uncle to the generated block.
53
+ // Note that AddUncle computes the difficulty and gas limit for us.
49
54
ctx .block .AddUncle (uncle )
55
+
50
56
info .Hashes = append (info .Hashes , uncle .Hash ())
51
57
m .info [ctx .NumberU64 ()] = info
52
58
m .counter ++
0 commit comments