Make extra extra sure that we won't get slashed

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2019-11-19 13:36:03 -06:00
parent 6e1bee3f8a
commit 463cdbb499
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -139,6 +139,7 @@ func (m *Miner) mine(ctx context.Context) {
var lastBase MiningBase var lastBase MiningBase
eventLoop:
for { for {
select { select {
case <-m.stop: case <-m.stop:
@ -198,6 +199,15 @@ func (m *Miner) mine(ctx context.Context) {
"time", time.Now(), "duration", time.Now().Sub(btime)) "time", time.Now(), "duration", time.Now().Sub(btime))
} }
mWon := make(map[address.Address]struct{})
for _, b := range blks {
_, notOk := mWon[b.Header.Miner]
if notOk {
log.Errorw("2 blocks for the same miner. Throwing hands in the air. Report this. It is important.", "bloks", blks)
continue eventLoop
}
mWon[b.Header.Miner] = struct{}{}
}
for _, b := range blks { for _, b := range blks {
if err := m.api.SyncSubmitBlock(ctx, b); err != nil { if err := m.api.SyncSubmitBlock(ctx, b); err != nil {
log.Errorf("failed to submit newly mined block: %s", err) log.Errorf("failed to submit newly mined block: %s", err)