Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
fixes for peercoin
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 committed Apr 16, 2019
1 parent 9b27e47 commit 063fb52
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/server/poolserver/NetworkMgr/NetworkMgr.cpp
Expand Up @@ -3,7 +3,7 @@

NetworkMgr* NetworkMgr::singleton = 0;

NetworkMgr::NetworkMgr(asio::io_service& io_service) : _io_service(io_service), _blockNotifyTimer(io_service), _blockCheckTimer(io_service), _blockHeight(0)
NetworkMgr::NetworkMgr(asio::io_service& io_service) : _io_service(io_service), _blockNotifyTimer(io_service), _blockCheckTimer(io_service), _blockHeight(-1)
{
BlockCheckTimerStart();
BlockNotifyTimerStart();
Expand All @@ -21,7 +21,7 @@ void NetworkMgr::Connect(JSONRPCConnectionInfo coninfo)
JSONRPC* bitcoinrpc = new JSONRPC();
bitcoinrpc->Connect(coninfo);

JSON response = bitcoinrpc->Query("getinfo");
JSON response = bitcoinrpc->Query("getblockchaininfo");

if (response["error"].GetType() != JSON_NULL)
throw Exception(Util::FS("Failed to get response from bitcoin rpc: %s", response["error"].GetString().c_str()));
Expand Down Expand Up @@ -61,8 +61,10 @@ void NetworkMgr::UpdateBlockTemplate()

// Add coinbase tx
BinaryData pubkey = Util::ASCIIToBin(sConfig.Get<std::string>("MiningAddress"));
block->tx.push_back(Bitcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt(), Util::ASCIIToBin("D7PoolBeta")));


block->tx.push_back(Bitcoin::CreateCoinbaseTX(_blockHeight+1, pubkey, response["coinbasevalue"].GetInt(), Util::ASCIIToBin("537061726B6C6572")));

//block->tx.push_back(Bitcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt(), Util::ASCIIToBin("706f6f6c6f766572")));
// Fix nTime for coinbase tx
block->tx[0].time = block->time;

Expand Down Expand Up @@ -131,10 +133,10 @@ void NetworkMgr::BlockCheck()
for (int i = 0; i < _cons.size(); ++i)
{
try {
JSON response = _cons[i]->Query("getinfo");
JSON response = _cons[i]->Query("getblockchaininfo");
uint32 curBlock = response["blocks"].GetInt();

if (curBlock > _blockHeight) {
if ((curBlock > _blockHeight) || _blockHeight == -1) {
sLog.Debug(LOG_SERVER, "New block on network! Height: %u", curBlock);
_blockHeight = curBlock;

Expand Down
3 changes: 2 additions & 1 deletion src/server/poolserver/Stratum/Client.cpp
Expand Up @@ -345,11 +345,12 @@ namespace Stratum

// Split coinbase
// tx.version - 4 bytes
// tx.timestamp - 4 bytes
// tx.in[0].outpoint.hash - 32 bytes
// tx.in[0].outpoint.n - 4 bytes
// tx.script (varint) - 2 bytes
// tx.script (block height) - 4 bytes
uint32 cbsplit = 4 + 32 + 4 + 2 + 4;
uint32 cbsplit = 4 + 4 + 32 + 4 + 2 + 4;
job->coinbase1 = BinaryData(coinbase.begin(), coinbase.begin() + cbsplit);
job->coinbase2 = BinaryData(coinbase.begin() + cbsplit + 8, coinbase.end()); // plus extranonce size

Expand Down
4 changes: 3 additions & 1 deletion src/server/shared/Bitcoin/Bitcoin.h
Expand Up @@ -39,7 +39,9 @@ namespace Bitcoin
// Extranonce placeholder
BinaryData extranonce_ph(8, 0);
ByteBuffer scriptsig;
scriptsig << blockHeight << extranonce_ph << extras;
uint8 three=3;
scriptsig << three << blockHeight;
scriptsig << extranonce_ph << extras;

Bitcoin::OutPoint outpoint;
outpoint.hash.resize(32, 0);
Expand Down
4 changes: 2 additions & 2 deletions src/server/shared/Logging/Log.cpp
Expand Up @@ -99,12 +99,12 @@ void Log::Write(LogLevel level, LogType type, std::string msg)
case LOG_LEVEL_DEBUG:
if (sConfig.Get<uint32_t>("LogConsoleLevel") >= level) {
uint32_t debugmask = sConfig.Get<uint32_t>("LogConsoleDebugMask");
if (debugmask & uint32_t(pow(2, type)))
if (debugmask & uint32_t(pow(2, static_cast<double>(type))))
std::cout << timestamp << " [DEBUG] " << msg << std::endl;
}
if (sConfig.Get<uint32_t>("LogFileLevel") >= level) {
uint32_t debugmask = sConfig.Get<uint32_t>("LogFileDebugMask");
if (debugmask & uint32_t(pow(2, type)))
if (debugmask & uint32_t(pow(2, static_cast<double>(type))))
AppendFile(timestamp + " [DEBUG] " + msg);
}
break;
Expand Down

0 comments on commit 063fb52

Please sign in to comment.