Refactor blkmk_assemble_submission2_ to work with either extranonce/mdata or dataid/data
This commit is contained in:
15
blkmaker.c
15
blkmaker.c
@@ -556,9 +556,16 @@ static char *blkmk_assemble_submission2_internal(blktemplate_t * const tmpl, con
|
||||
return blkhex;
|
||||
}
|
||||
|
||||
char *blkmk_assemble_submission2_(blktemplate_t * const tmpl, const unsigned char * const data, const void * const extranonce, const size_t extranoncesz, const blknonce_t nonce, const bool foreign)
|
||||
char *blkmk_assemble_submission2_(blktemplate_t * const tmpl, const unsigned char * const data, const void *extranonce, size_t extranoncesz, const unsigned int dataid, const blknonce_t nonce, const bool foreign)
|
||||
{
|
||||
if (extranoncesz == sizeof(unsigned int)) {
|
||||
if (dataid) {
|
||||
if (extranoncesz) {
|
||||
// Cannot specify both!
|
||||
return NULL;
|
||||
}
|
||||
extranonce = &dataid;
|
||||
extranoncesz = sizeof(dataid);
|
||||
} else if (extranoncesz == sizeof(unsigned int)) {
|
||||
// Avoid overlapping with blkmk_get_data use
|
||||
unsigned char extended_extranonce[extranoncesz + 1];
|
||||
memcpy(extended_extranonce, extranonce, extranoncesz);
|
||||
@@ -570,7 +577,5 @@ char *blkmk_assemble_submission2_(blktemplate_t * const tmpl, const unsigned cha
|
||||
|
||||
char *blkmk_assemble_submission_(blktemplate_t * const tmpl, const unsigned char * const data, const unsigned int dataid, const blknonce_t nonce, const bool foreign)
|
||||
{
|
||||
const void * const extranonce = &dataid;
|
||||
const size_t extranoncesz = dataid ? sizeof(dataid) : 0;
|
||||
return blkmk_assemble_submission2_internal(tmpl, data, extranonce, extranoncesz, nonce, foreign);
|
||||
return blkmk_assemble_submission2_(tmpl, data, NULL, 0, dataid, nonce, foreign);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
extern bool _blkmk_dblsha256(void *hash, const void *data, size_t datasz);
|
||||
extern bool blkmk_sample_data_(blktemplate_t *, uint8_t *, unsigned int dataid);
|
||||
extern char *blkmk_assemble_submission_(blktemplate_t *, const unsigned char *data, unsigned int dataid, blknonce_t nonce, bool foreign);
|
||||
extern char *blkmk_assemble_submission2_(blktemplate_t *, const unsigned char *data, const void *extranonce, size_t extranoncesz, blknonce_t nonce, bool foreign);
|
||||
extern char *blkmk_assemble_submission2_(blktemplate_t *, const unsigned char *data, const void *extranonce, size_t extranoncesz, unsigned int dataid, blknonce_t nonce, bool foreign);
|
||||
|
||||
// blktemplate.c
|
||||
extern void _blktxn_free(struct blktxn_t *);
|
||||
|
||||
Reference in New Issue
Block a user