[PrivateSend] Performance tweak: faster shuffling of Masternodes vector (#1063)
This commit is contained in:
parent
6795de7f1a
commit
e32e28afb9
@ -1151,7 +1151,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
|
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log, seed insecure_rand()
|
||||||
|
|
||||||
|
// Initialize fast PRNG
|
||||||
|
seed_insecure_rand(false);
|
||||||
|
|
||||||
// Initialize elliptic curve code
|
// Initialize elliptic curve code
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
|
@ -373,7 +373,7 @@ CMasternode *CMasternodeMan::FindRandomNotInVec(std::vector<CTxIn> &vecToExclude
|
|||||||
}
|
}
|
||||||
|
|
||||||
// shuffle pointers
|
// shuffle pointers
|
||||||
std::random_shuffle(vpMasternodesShuffled.begin(), vpMasternodesShuffled.end(), GetRandInt);
|
std::random_shuffle(vpMasternodesShuffled.begin(), vpMasternodesShuffled.end(), GetInsecureRand);
|
||||||
bool fExclude;
|
bool fExclude;
|
||||||
|
|
||||||
// loop through
|
// loop through
|
||||||
|
@ -46,4 +46,11 @@ static inline uint32_t insecure_rand(void)
|
|||||||
return (insecure_rand_Rw << 16) + insecure_rand_Rz;
|
return (insecure_rand_Rw << 16) + insecure_rand_Rz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for std::random_shuffle
|
||||||
|
*/
|
||||||
|
static inline uint32_t GetInsecureRand(uint32_t i){
|
||||||
|
return insecure_rand() % i;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BITCOIN_RANDOM_H
|
#endif // BITCOIN_RANDOM_H
|
||||||
|
Loading…
Reference in New Issue
Block a user