
#define VEXON_REMOTE_CLOSED			0
#define VEXON_REMOTE_SUBSCRIBE		1
#define VEXON_REMOTE_AUTHORIZE		2
#define VEXON_REMOTE_EXTRANONCE		3
#define VEXON_REMOTE_READY			4
#define VEXON_REMOTE_RESET			5
#define VEXON_REMOTE_TERMINATE		6

class VEXON_SUBMIT;

class VEXON_RENTER: public VEXON_OBJECT
{
public:
	double balance;
	int updated;
};

class VEXON_REMOTE: public VEXON_OBJECT
{
public:
	bool touch;
//	bool allocated;

	bool kill;
//	bool reset_balance;

	int status;
	int updated;

	VEXON_RENTER *renter;

	pthread_t thread;
	VEXON_SOCKET *sock;

	char jobid[32];
	char nonce1[32];
	int nonce2size;
	char nonce1_next[32];
	int nonce2size_next;

	double difficulty_actual;
	double difficulty_next;
	double difficulty_written;

	double price;
	double speed;
	double speed_avg;

//	char session_id[1024];

	char host[1024];
	int port;

	char username[1024];
	char password[1024];

	VEXON_JOB *job;
	VEXON_SUBMIT *submit_last;
};

inline void remote_delete(VEXON_OBJECT *object)
{
	VEXON_REMOTE *remote = (VEXON_REMOTE *)object;

	object_delete(remote->job);
	socket_close(remote->sock);

	pthread_detach(remote->thread);
	delete remote;
}

bool remote_can_mine(VEXON_REMOTE *remote);
void remote_sort();

bool remote_connected(VEXON_REMOTE *remote);
void remote_close(VEXON_REMOTE *remote);
void *remote_thread(void *p);

void remote_create_job(VEXON_REMOTE *remote, json_value *json_params);
void remote_submit(VEXON_CLIENT *client, VEXON_JOB *job, VEXON_JOB_VALUES *submitvalues, char *extranonce2, char *ntime, char *nonce);















