commit
1e32aa36b7
|
@ -90,7 +90,6 @@ init(Handle<Object>);
|
||||||
* Private Global Variables
|
* Private Global Variables
|
||||||
* Used only by bitcoindjs functions.
|
* Used only by bitcoindjs functions.
|
||||||
*/
|
*/
|
||||||
static uv_mutex_t txmon_mutex;
|
|
||||||
static std::vector<std::string> txmon_messages;
|
static std::vector<std::string> txmon_messages;
|
||||||
static uv_async_t txmon_async;
|
static uv_async_t txmon_async;
|
||||||
static Eternal<Function> txmon_callback;
|
static Eternal<Function> txmon_callback;
|
||||||
|
@ -235,29 +234,31 @@ txmon(uv_async_t *handle) {
|
||||||
Isolate* isolate = Isolate::GetCurrent();
|
Isolate* isolate = Isolate::GetCurrent();
|
||||||
HandleScope scope(isolate);
|
HandleScope scope(isolate);
|
||||||
|
|
||||||
uv_mutex_lock(&txmon_mutex);
|
{
|
||||||
|
|
||||||
Local<Array> results = Array::New(isolate);
|
LOCK(cs_main);
|
||||||
int arrayIndex = 0;
|
|
||||||
|
Local<Array> results = Array::New(isolate);
|
||||||
|
int arrayIndex = 0;
|
||||||
|
|
||||||
|
BOOST_FOREACH(const std::string& message, txmon_messages) {
|
||||||
|
results->Set(arrayIndex, NanNew<String>(message));
|
||||||
|
arrayIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned argc = 1;
|
||||||
|
Local<Value> argv[argc] = {
|
||||||
|
Local<Value>::New(isolate, results)
|
||||||
|
};
|
||||||
|
|
||||||
|
Local<Function> cb = txmon_callback.Get(isolate);
|
||||||
|
|
||||||
|
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
|
||||||
|
|
||||||
|
txmon_messages.clear();
|
||||||
|
|
||||||
BOOST_FOREACH(const std::string& message, txmon_messages) {
|
|
||||||
results->Set(arrayIndex, NanNew<String>(message));
|
|
||||||
arrayIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned argc = 1;
|
|
||||||
Local<Value> argv[argc] = {
|
|
||||||
Local<Value>::New(isolate, results)
|
|
||||||
};
|
|
||||||
|
|
||||||
Local<Function> cb = txmon_callback.Get(isolate);
|
|
||||||
|
|
||||||
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
|
|
||||||
|
|
||||||
txmon_messages.clear();
|
|
||||||
|
|
||||||
uv_mutex_unlock(&txmon_mutex);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -316,10 +317,11 @@ process_messages(CNode* pfrom) {
|
||||||
|
|
||||||
string txHash = tx.GetHash().GetHex();
|
string txHash = tx.GetHash().GetHex();
|
||||||
|
|
||||||
uv_mutex_lock(&txmon_mutex);
|
{
|
||||||
txmon_messages.push_back(txHash);
|
LOCK(cs_main);
|
||||||
uv_mutex_unlock(&txmon_mutex);
|
txmon_messages.push_back(txHash);
|
||||||
uv_async_send(&txmon_async);
|
uv_async_send(&txmon_async);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue