From 463cdbb4999505a45f0d2af3ec2141f8bf73523a Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 19 Nov 2019 13:36:03 -0600 Subject: [PATCH] Make extra extra sure that we won't get slashed License: MIT Signed-off-by: Jakub Sztandera --- miner/miner.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/miner/miner.go b/miner/miner.go index dbf647272..a85dff338 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -139,6 +139,7 @@ func (m *Miner) mine(ctx context.Context) { var lastBase MiningBase +eventLoop: for { select { case <-m.stop: @@ -198,6 +199,15 @@ func (m *Miner) mine(ctx context.Context) { "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 { if err := m.api.SyncSubmitBlock(ctx, b); err != nil { log.Errorf("failed to submit newly mined block: %s", err)