Skip to content
Permalink
Browse files

Adding fallback to ALGO while creating block template

  • Loading branch information...
marpme committed Mar 3, 2019
1 parent b096447 commit 20b4edea6f1fd593202ad6f94661b4fc9f255c62
Showing with 19 additions and 20 deletions.
  1. +19 −20 src/rpc/mining.cpp
@@ -236,6 +236,22 @@ static std::string gbt_vb_name(const Consensus::DeploymentPos pos) {
return s;
}

static int32_t determineVersionForBlockTemplate(int32_t algo){
switch(algo) {
case ALGO_X17:
return BLOCK_VERSION_X17;
case ALGO_LYRA2RE:
return BLOCK_VERSION_LYRA2RE;
case ALGO_BLAKE:
return BLOCK_VERSION_BLAKE;
case ALGO_GROESTL:
return BLOCK_VERSION_GROESTL;
case ALGO_SCRYPT:
default:
return BLOCK_VERSION_SCRYPT;
}
}

static UniValue getblocktemplate(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() > 1)
@@ -592,27 +608,10 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
if(algorithm.isStr()){
std::string algorithmStr = algorithm.get_str();
int32_t algo = GetAlgoByName(algorithmStr);
switch(algo) {
case ALGO_X17:
version |= BLOCK_VERSION_X17;
break;
case ALGO_LYRA2RE :
version |= BLOCK_VERSION_LYRA2RE;
break;
case ALGO_BLAKE :
version |= BLOCK_VERSION_BLAKE;
break;
case ALGO_GROESTL:
version |= BLOCK_VERSION_GROESTL;
break;
case ALGO_SCRYPT:
default:
version |= BLOCK_VERSION_SCRYPT;
break;
}
version |= determineVersionForBlockTemplate(algo);
} else {
// defaulting to scrypt if nothing is given
version |= BLOCK_VERSION_SCRYPT;
// defaulting to ALGO, this either set via config or default script
version |= determineVersionForBlockTemplate(ALGO);
}
}
result.pushKV("version", version);

0 comments on commit 20b4ede

Please sign in to comment.
You can’t perform that action at this time.