add start_node function to start up net.cpp threads.

This commit is contained in:
Christopher Jeffrey 2014-08-20 16:47:18 -07:00
parent 70f4be4c40
commit f9eb3215e6

View File

@ -78,12 +78,15 @@ using namespace v8;
NAN_METHOD(StartBitcoind);
void
static void
async_work(uv_work_t *req);
void
static void
async_after(uv_work_t *req);
static int
start_node(void);
extern "C" void
init(Handle<Object>);
@ -124,12 +127,15 @@ NAN_METHOD(StartBitcoind) {
NanReturnValue(Undefined());
}
void async_work(uv_work_t *req) {
static void
async_work(uv_work_t *req) {
async_data* data = static_cast<async_data*>(req->data);
//start_node();
data->result = (char *)strdup("opened");
}
void async_after(uv_work_t *req) {
static void
async_after(uv_work_t *req) {
NanScope();
async_data* data = static_cast<async_data*>(req->data);
@ -165,6 +171,45 @@ void async_after(uv_work_t *req) {
delete req;
}
extern void (ThreadImport)(std::vector<boost::filesystem::path>);
extern void (DetectShutdownThread)(boost::thread_group*);
extern int nScriptCheckThreads;
// extern const int DEFAULT_SCRIPTCHECK_THREADS; // static!!
// Relevant:
// ~/bitcoin/src/init.cpp
// ~/bitcoin/src/bitcoind.cpp
// ~/bitcoin/src/main.h
static int
start_node(void) {
boost::thread_group threadGroup;
boost::thread *detectShutdownThread = NULL;
detectShutdownThread = new boost::thread(
boost::bind(&DetectShutdownThread, &threadGroup));
// int nScriptCheckThreads = 0;
for (int i = 0; i < nScriptCheckThreads - 1; i++) {
threadGroup.create_thread(&ThreadScriptCheck);
}
std::vector<boost::filesystem::path> vImportFiles;
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
StartNode(threadGroup);
#ifdef ENABLE_WALLET
if (pwalletMain) {
// Add wallet transactions that aren't already in a block to mapTransactions
pwalletMain->ReacceptWalletTransactions();
// Run a thread to flush wallet periodically
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
}
#endif
return 0;
}
/**
* Init
*/