mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
mining: Optimize get the block's votes tx.
The optimizes to check the height of the next block is greater than the threshold first since it is more likely in the NewBlockTemplate function.
This commit is contained in:
parent
73a60c8f02
commit
dcd2d701b5
32
mining.go
32
mining.go
@ -1589,25 +1589,25 @@ mempoolLoop:
|
||||
voters := 0
|
||||
var voteBitsVoters []uint16
|
||||
|
||||
for _, tx := range blockTxns {
|
||||
msgTx := tx.MsgTx()
|
||||
if nextBlockHeight < stakeValidationHeight {
|
||||
break // No SSGen should be present before this height.
|
||||
}
|
||||
// Have SSGen should be present after this height.
|
||||
if nextBlockHeight >= stakeValidationHeight {
|
||||
for _, tx := range blockTxns {
|
||||
msgTx := tx.MsgTx()
|
||||
|
||||
if stake.IsSSGen(msgTx) {
|
||||
txCopy := dcrutil.NewTxDeepTxIns(msgTx)
|
||||
if maybeInsertStakeTx(g.blockManager, txCopy, !knownDisapproved) {
|
||||
vb := stake.SSGenVoteBits(txCopy.MsgTx())
|
||||
voteBitsVoters = append(voteBitsVoters, vb)
|
||||
blockTxnsStake = append(blockTxnsStake, txCopy)
|
||||
voters++
|
||||
if stake.IsSSGen(msgTx) {
|
||||
txCopy := dcrutil.NewTxDeepTxIns(msgTx)
|
||||
if maybeInsertStakeTx(g.blockManager, txCopy, !knownDisapproved) {
|
||||
vb := stake.SSGenVoteBits(txCopy.MsgTx())
|
||||
voteBitsVoters = append(voteBitsVoters, vb)
|
||||
blockTxnsStake = append(blockTxnsStake, txCopy)
|
||||
voters++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't let this overflow, although probably it's impossible.
|
||||
if voters >= math.MaxUint16 {
|
||||
break
|
||||
// Don't let this overflow, although probably it's impossible.
|
||||
if voters >= math.MaxUint16 {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user