@@ -344,7 +344,7 @@ func (m *Miner) mine(ctx context.Context) {
344
344
if err := m .sf .PutBlock (ctx , & sharedTypes.BlockHeader {
345
345
Height : base .TipSet .Height () + base .NullRounds + 1 ,
346
346
Miner : res .addr ,
347
- }, base .TipSet .Height ()+ base . NullRounds , time.Time {}, types .ChainForked ); err != nil {
347
+ }, base .TipSet .Height (), time.Time {}, types .ChainForked ); err != nil {
348
348
log .Errorf ("failed to record chain forked: %s" , err )
349
349
}
350
350
@@ -467,15 +467,15 @@ func (m *Miner) mine(ctx context.Context) {
467
467
log .Info ("no block and increase nullround" )
468
468
}
469
469
470
- go m .tryGetBeacon (ctx , * base )
471
-
472
470
// Wait until the next epoch, plus the propagation delay, so a new tipset
473
471
// has enough time to form.
474
472
m .untilNextEpoch (base )
475
473
476
474
if len (winPoSts ) == 0 {
477
475
base .NullRounds ++
478
476
}
477
+
478
+ go m .tryGetBeacon (ctx , * base )
479
479
}
480
480
}
481
481
@@ -491,7 +491,7 @@ func (m *Miner) tryGetBeacon(ctx context.Context, base MiningBase) {
491
491
return
492
492
}
493
493
494
- round := head .Height () + 1
494
+ round := head .Height () + base . NullRounds + 1
495
495
nodes := m .submitNodes
496
496
497
497
log .Infof ("try get beacon at: %d" , round )
@@ -547,9 +547,9 @@ func (m *Miner) broadCastBlock(ctx context.Context, base MiningBase, bm *sharedT
547
547
return
548
548
}
549
549
550
- if err := m .sf .MinedBlock (ctx , bm .Header , base .TipSet .Height ()+ base . NullRounds ); err != nil {
550
+ if err := m .sf .MinedBlock (ctx , bm .Header , base .TipSet .Height ()); err != nil {
551
551
log .Errorf ("<!!> SLASH FILTER ERROR: %s" , err )
552
- if err = m .sf .PutBlock (ctx , bm .Header , base .TipSet .Height ()+ base . NullRounds , time.Time {}, types .Error ); err != nil {
552
+ if err = m .sf .PutBlock (ctx , bm .Header , base .TipSet .Height (), time.Time {}, types .Error ); err != nil {
553
553
log .Errorf ("failed to put block: %s" , err )
554
554
}
555
555
@@ -782,27 +782,10 @@ func (m *Miner) GetBestMiningCandidate(ctx context.Context) (*MiningBase, error)
782
782
return nil , err
783
783
}
784
784
785
- if m .lastWork != nil {
786
- if m .lastWork .TipSet .Equals (bts ) {
787
- return m .lastWork , nil
788
- }
789
-
790
- btsw , err := m .api .ChainTipSetWeight (ctx , bts .Key ())
791
- if err != nil {
792
- return nil , err
793
- }
794
- ltsw , err := m .api .ChainTipSetWeight (ctx , m .lastWork .TipSet .Key ())
795
- if err != nil {
796
- m .lastWork = nil
797
- return nil , err
798
- }
799
-
800
- if sharedTypes .BigCmp (btsw , ltsw ) <= 0 {
801
- return m .lastWork , nil
802
- }
785
+ if m .lastWork == nil || ! m .lastWork .TipSet .Equals (bts ) {
786
+ m .lastWork = & MiningBase {TipSet : bts }
803
787
}
804
788
805
- m .lastWork = & MiningBase {TipSet : bts }
806
789
return m .lastWork , nil
807
790
}
808
791
0 commit comments