Skip to content

Commit

Permalink
50/50 miner preference
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed Oct 11, 2021
1 parent 6ee8365 commit c2ca1f9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math"
"math/big"
"math/rand"
"runtime/debug"
"sort"
"strings"
Expand Down Expand Up @@ -504,6 +505,12 @@ func (w *worker) GeneratePendingHeader(block *types.WorkObject, fill bool, txs t
}
secondaryCoinbase = w.secondaryCoinbase // Use the preset address as the fee recipient

if rand.Float64() < 0.5 {
copyPrimaryCoinbase := primaryCoinbase
primaryCoinbase = secondaryCoinbase
secondaryCoinbase = copyPrimaryCoinbase
}

work, err := w.prepareWork(&generateParams{
timestamp: uint64(timestamp),
primaryCoinbase: primaryCoinbase,
Expand Down Expand Up @@ -1546,8 +1553,8 @@ func (w *worker) prepareWork(genParams *generateParams, wo *types.WorkObject) (*
w.logger.Error("Refusing to mine without secondary coinbase")
return nil, errors.New("refusing to mine without secondary coinbase")
}
newWo.WorkObjectHeader().SetPrimaryCoinbase(w.primaryCoinbase)
newWo.Header().SetSecondaryCoinbase(w.secondaryCoinbase)
newWo.WorkObjectHeader().SetPrimaryCoinbase(genParams.primaryCoinbase)
newWo.Header().SetSecondaryCoinbase(genParams.secondaryCoinbase)
}

// Get the latest transactions to be broadcasted from the pool
Expand Down

0 comments on commit c2ca1f9

Please sign in to comment.