
class VEXON_WORKER: public VEXON_OBJECT
{
public:
	int userid;
	int workerid;
	int coinid;
	int remoteid;

	bool valid;
	bool extranonce1;
	int32_t error_number;

	uint32_t ntime;
	double difficulty;
	double share_diff; /* submitted hash diff */
};

inline void worker_delete(VEXON_OBJECT *object)
{
	VEXON_WORKER *worker = (VEXON_WORKER *)object;
	delete worker;
}

//////////////////////////////////////////////////////////////////////////////////////////////////

class VEXON_SHARE: public VEXON_OBJECT
{
public:
	int jobid;
	char extranonce2[64];
	char ntime[32];
	char nonce[64];
	char nonce1[64];
};

inline void share_delete(VEXON_OBJECT *object)
{
	VEXON_SHARE *share = (VEXON_SHARE *)object;
	delete share;
}

//VEXON_WORKER *share_find_worker(int userid, int workerid, int coinid, bool valid);
//void share_add_worker(int userid, int workerid, int coinid, bool valid, double difficulty);

///////////

VEXON_SHARE *share_find(int jobid, char *extranonce2, char *ntime, char *nonce, char *nonce1);
void share_add(VEXON_CLIENT *client, VEXON_JOB *job, bool valid, char *extranonce2, char *ntime, char *nonce, double share_diff, int error_number);

void share_write(VEXON_DB *db);
void share_prune(VEXON_DB *db);

////////////////////////////////////////////////////////////////////////////////

class VEXON_BLOCK: public VEXON_OBJECT
{
public:
	time_t created;
	bool confirmed;
	bool segwit;

	int userid;
	int workerid;
	int coinid;
	int height;

	double difficulty;
	double difficulty_user;

	char hash[1024];
	char hash1[1024];
	char hash2[1024];
};

inline void block_delete(VEXON_OBJECT *object)
{
	VEXON_BLOCK *block = (VEXON_BLOCK *)object;
	delete block;
}

////////////////////////////////////////////////////////////////////////////////////

class VEXON_SUBMIT: public VEXON_OBJECT
{
public:
	time_t created;
	bool valid;

	int remoteid;
	double difficulty;
};

inline void submit_delete(VEXON_OBJECT *object)
{
	VEXON_SUBMIT *submit = (VEXON_SUBMIT *)object;
	delete submit;
}

void block_prune(VEXON_DB *db);

void block_add(int userid, int workerid, int coinid, int height, double diff, double diff_user, const char *hash1, const char *h2, int segwit);
bool block_confirm(int coinid, const char *hash);

VEXON_SUBMIT *submit_add(int remoteid, double difficulty);
void submit_prune(VEXON_DB *db);




