-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNexusCore.m
81 lines (68 loc) · 1.76 KB
/
NexusCore.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// NexusCore.m
// Nexus Library
//
// Obj-c++ file that starts and stops the Nexus Core. Is objtective c so can interface with iOS Foundation
//
#import <Foundation/Foundation.h>
#include "NexusCore.h"
#include "entrypoint.hpp"
#include <assert.h>
#include <pthread.h>
NSArray *userCre;
//testnet=605 connect=test1.nexusminingpool.com
// Main Function for the thread
void* PosixThreadMainRoutine(void* data)
{
char *my_argv[] = {
NULL,
strdup("-client=true"),
strdup("-verbose=3"),
strdup("-timeout=30"),
strdup("-ssl=true"),
strdup("-apissl=true"),
strdup("-apisslport=7080"),
strdup("-apisslrequired=true"),
strdup("-connect=node2.nexus.io"),
strdup("-terminateauth=0"),
NULL
};
const char *com = [userCre[0] UTF8String];
const char *command = [userCre[1] UTF8String];
startNexus(10, my_argv,strdup(com),strdup(command));
return NULL;
}
// Start Nexus Core by launching a separate thread
void LaunchThread(NSArray *userCreds)
{
userCre = userCreds;
// Create the thread using POSIX routines.
pthread_attr_t attr;
pthread_t posixThreadID;
int returnVal;
returnVal = pthread_attr_init(&attr);
assert(!returnVal);
returnVal = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
assert(!returnVal);
int threadError = pthread_create(&posixThreadID, &attr, &PosixThreadMainRoutine, NULL);
returnVal = pthread_attr_destroy(&attr);
assert(!returnVal);
if (threadError != 0)
{
printf("$$ERROR");
// Report an error.
}
}
// Shutdown Nexus, Important so that the CG can close out the sockets and cache
void ShutdownNexus()
{
shutdownNexus();
}
void CloseSocket()
{
closeListening();
}
void OpenSocket()
{
openListening();
}