|
17 | 17 | #include "swifttx.h" |
18 | 18 | #include "util.h" |
19 | 19 |
|
| 20 | +#include <boost/thread/thread.hpp> |
20 | 21 |
|
21 | 22 | #define MN_WINNER_MINIMUM_AGE 8000 // Age in seconds. This should be > MASTERNODE_REMOVAL_SECONDS to avoid misconfigured new nodes in the list. |
22 | 23 |
|
@@ -868,24 +869,33 @@ void ThreadCheckMasternodes() |
868 | 869 |
|
869 | 870 | unsigned int c = 0; |
870 | 871 |
|
871 | | - while (true) { |
872 | | - MilliSleep(1000); |
| 872 | + try { |
| 873 | + while (true) { |
873 | 874 |
|
874 | | - // try to sync from all available nodes, one step at a time |
875 | | - masternodeSync.Process(); |
| 875 | + if (ShutdownRequested()) { |
| 876 | + break; |
| 877 | + } |
876 | 878 |
|
877 | | - if (masternodeSync.IsBlockchainSynced()) { |
878 | | - c++; |
| 879 | + MilliSleep(1000); |
| 880 | + boost::this_thread::interruption_point(); |
| 881 | + // try to sync from all available nodes, one step at a time |
| 882 | + masternodeSync.Process(); |
879 | 883 |
|
880 | | - // check if we should activate or ping every few minutes, |
881 | | - // start right after sync is considered to be done |
882 | | - if (c % MASTERNODE_PING_SECONDS == 1) activeMasternode.ManageStatus(); |
| 884 | + if (masternodeSync.IsBlockchainSynced()) { |
| 885 | + c++; |
883 | 886 |
|
884 | | - if (c % 60 == 0) { |
885 | | - mnodeman.CheckAndRemove(); |
886 | | - masternodePayments.CleanPaymentList(); |
887 | | - CleanTransactionLocksList(); |
| 887 | + // check if we should activate or ping every few minutes, |
| 888 | + // start right after sync is considered to be done |
| 889 | + if (c % MASTERNODE_PING_SECONDS == 1) activeMasternode.ManageStatus(); |
| 890 | + |
| 891 | + if (c % 60 == 0) { |
| 892 | + mnodeman.CheckAndRemove(); |
| 893 | + masternodePayments.CleanPaymentList(); |
| 894 | + CleanTransactionLocksList(); |
| 895 | + } |
888 | 896 | } |
889 | 897 | } |
| 898 | + } catch (boost::thread_interrupted&) { |
| 899 | + // nothing, thread interrupted. |
890 | 900 | } |
891 | 901 | } |
0 commit comments