| 129 | void Interrupt() { InterruptRPCServer(); } |
| 130 | |
| 131 | void Shutdown() { |
| 132 | LogPrint(BCLog::INFO, "Shutdown() : In progress...\n"); |
| 133 | static CCriticalSection cs_Shutdown; |
| 134 | TRY_LOCK(cs_Shutdown, lockShutdown); |
| 135 | if (!lockShutdown) |
| 136 | return; |
| 137 | |
| 138 | RenameThread("coin-shutoff"); |
| 139 | |
| 140 | StopRPCServer(); |
| 141 | |
| 142 | GenerateProduceBlockThread(false, nullptr, 0); |
| 143 | StartCommonGeneration(0, 0); |
| 144 | StartContractGeneration("", 0, 0); |
| 145 | |
| 146 | StopNode(); |
| 147 | UnregisterNodeSignals(GetNodeSignals()); |
| 148 | |
| 149 | { |
| 150 | LOCK(cs_main); |
| 151 | |
| 152 | if (pWalletMain) { |
| 153 | pWalletMain->SetBestChain(chainActive.GetLocator()); |
| 154 | bitdb.Flush(true); |
| 155 | } |
| 156 | |
| 157 | if (pCdMan != nullptr) { |
| 158 | pCdMan->Flush(); |
| 159 | delete pCdMan; |
| 160 | pCdMan = nullptr; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | boost::filesystem::remove(GetPidFile()); |
| 165 | UnregisterAllWallets(); |
| 166 | |
| 167 | delete pWalletMain; |
| 168 | pWalletMain = nullptr; |
| 169 | |
| 170 | // Uninitialize elliptic curve code |
| 171 | globalVerifyHandle.reset(); |
| 172 | ECC_Stop(); |
| 173 | |
| 174 | wasm_code_cache_free(); |
| 175 | |
| 176 | LogPrint(BCLog::INFO, "Shutdown() : done\n"); |
| 177 | } |
| 178 | |
| 179 | // |
| 180 | // Signal handlers are very limited in what they are allowed to do, so: |