mirror of
https://github.com/GOSTSec/poolserver
synced 2025-01-14 08:47:53 +00:00
rename Bitcoin to Gostcoin
This commit is contained in:
parent
e7ccdfa9db
commit
1f12b4f30d
@ -28,7 +28,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Logging
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/JSON
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/JSONRPC
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Bitcoin
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Gostcoin
|
||||
${Boost_INCLUDE_DIR}
|
||||
${MYSQL_INCLUDE_DIR}
|
||||
${GMP_INCLUDE_DIR}
|
||||
|
@ -15,20 +15,20 @@ NetworkMgr::~NetworkMgr()
|
||||
delete _cons[i];
|
||||
}
|
||||
|
||||
// Bitcoin daemon connection
|
||||
// Gostcoin daemon connection
|
||||
void NetworkMgr::Connect(JSONRPCConnectionInfo coninfo)
|
||||
{
|
||||
JSONRPC* bitcoinrpc = new JSONRPC();
|
||||
bitcoinrpc->Connect(coninfo);
|
||||
JSONRPC* gostcoinrpc = new JSONRPC();
|
||||
gostcoinrpc->Connect(coninfo);
|
||||
|
||||
JSON response = bitcoinrpc->Query("getinfo");
|
||||
JSON response = gostcoinrpc->Query("getinfo");
|
||||
|
||||
if (response["error"].GetType() != JSON_NULL)
|
||||
throw Exception(Util::FS("Failed to get response from bitcoin rpc: %s", response["error"].GetString().c_str()));
|
||||
throw Exception(Util::FS("Failed to get response from gostcoin rpc: %s", response["error"].GetString().c_str()));
|
||||
|
||||
sLog.Info(LOG_SERVER, "Connected to Bitcoin RPC at %s:%s", coninfo.Host.c_str(), coninfo.Port.c_str());
|
||||
sLog.Info(LOG_SERVER, "Connected to Gostcoin RPC at %s:%s", coninfo.Host.c_str(), coninfo.Port.c_str());
|
||||
|
||||
_cons.push_back(bitcoinrpc);
|
||||
_cons.push_back(gostcoinrpc);
|
||||
|
||||
// Fetch block height on first connection
|
||||
if (_cons.size() == 1)
|
||||
@ -50,7 +50,7 @@ void NetworkMgr::UpdateBlockTemplate()
|
||||
if (response["height"].GetInt() < _blockHeight)
|
||||
continue;
|
||||
|
||||
Bitcoin::BlockPtr block = Bitcoin::BlockPtr(new Bitcoin::Block());
|
||||
Gostcoin::BlockPtr block = Gostcoin::BlockPtr(new Gostcoin::Block());
|
||||
|
||||
block->version = response["version"].GetInt();
|
||||
block->prevBlockHash = Util::Reverse(Util::ASCIIToBin(response["previousblockhash"].GetString()));
|
||||
@ -61,13 +61,13 @@ 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()));
|
||||
block->tx.push_back(Gostcoin::CreateCoinbaseTX(_blockHeight, pubkey, response["coinbasevalue"].GetInt()));
|
||||
|
||||
// Add other transactions
|
||||
JSON trans = response["transactions"];
|
||||
for (uint64 tidx = 0; tidx < trans.Size(); ++tidx) {
|
||||
ByteBuffer txbuf(Util::ASCIIToBin(trans[tidx]["data"].GetString()));
|
||||
Bitcoin::Transaction tx;
|
||||
Gostcoin::Transaction tx;
|
||||
txbuf >> tx;
|
||||
block->tx.push_back(tx);
|
||||
}
|
||||
@ -89,7 +89,7 @@ void NetworkMgr::UpdateBlockTemplate()
|
||||
}
|
||||
|
||||
// Submit new block
|
||||
bool NetworkMgr::SubmitBlock(Bitcoin::Block block)
|
||||
bool NetworkMgr::SubmitBlock(Gostcoin::Block block)
|
||||
{
|
||||
// Serialize block
|
||||
ByteBuffer blockbuf;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#ifndef NETWORKMGR_H_
|
||||
#define NETWORKMGR_H_
|
||||
|
||||
// Provides high level interaction with bitcoin daemon
|
||||
// Provides high level interaction with gostcoin daemon
|
||||
|
||||
#include "JSONRPC.h"
|
||||
#include "Bitcoin.h"
|
||||
#include "Gostcoin.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <vector>
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
using namespace boost;
|
||||
|
||||
typedef boost::function<void (Bitcoin::BlockPtr /*blockTmpl*/, bool /*newBlock*/)> FBlockNotify;
|
||||
typedef boost::function<void (Gostcoin::BlockPtr /*blockTmpl*/, bool /*newBlock*/)> FBlockNotify;
|
||||
|
||||
class NetworkMgr
|
||||
{
|
||||
@ -36,14 +36,14 @@ public:
|
||||
NetworkMgr(asio::io_service& io_service);
|
||||
~NetworkMgr();
|
||||
|
||||
// Bitcoin daemon connection
|
||||
// Gostcoin daemon connection
|
||||
void Connect(JSONRPCConnectionInfo coninfo);
|
||||
|
||||
// Get new block template
|
||||
void UpdateBlockTemplate();
|
||||
|
||||
// Submit new block
|
||||
bool SubmitBlock(Bitcoin::Block block);
|
||||
bool SubmitBlock(Gostcoin::Block block);
|
||||
|
||||
// Checking for blocks
|
||||
void BlockCheck();
|
||||
@ -70,11 +70,11 @@ private:
|
||||
boost::mutex _mtxBlockCheck;
|
||||
uint32 _blockHeight;
|
||||
|
||||
// Connections to bitcoin rpc
|
||||
// Connections to gostcoin rpc
|
||||
std::vector<JSONRPC*> _cons;
|
||||
|
||||
// Current block template
|
||||
Bitcoin::BlockPtr _curBlockTmpl;
|
||||
Gostcoin::BlockPtr _curBlockTmpl;
|
||||
boost::mutex _mtxBlockTmpl;
|
||||
|
||||
// ASIO
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "Stratum/Server.h"
|
||||
#include "ServerDatabaseEnv.h"
|
||||
#include "Crypto.h"
|
||||
#include "Bitcoin.h"
|
||||
#include "Gostcoin.h"
|
||||
#include "DataMgr.h"
|
||||
#include "NetworkMgr.h"
|
||||
#include "Exception.h"
|
||||
|
@ -199,14 +199,14 @@ namespace Stratum
|
||||
}
|
||||
|
||||
// Copy block we are working on
|
||||
Bitcoin::Block block = *job->block;
|
||||
Gostcoin::Block block = *job->block;
|
||||
|
||||
// Start assembling the block
|
||||
timebuf >> block.time;
|
||||
noncebuf >> block.nonce;
|
||||
|
||||
// Assemble coinbase
|
||||
Bitcoin::Transaction coinbasetx;
|
||||
Gostcoin::Transaction coinbasetx;
|
||||
ByteBuffer coinbasebuf;
|
||||
coinbasebuf << job->coinbase1 << _extranonce << extranonce2 << job->coinbase2;
|
||||
coinbasebuf >> coinbasetx;
|
||||
@ -335,8 +335,8 @@ namespace Stratum
|
||||
Job* job = new Job();
|
||||
job->block = _server->GetWork();
|
||||
job->diff = _diff;
|
||||
job->jobTarget = Bitcoin::DiffToTarget(job->diff);
|
||||
job->blockTarget = Bitcoin::TargetFromBits(job->block->bits);
|
||||
job->jobTarget = Gostcoin::DiffToTarget(job->diff);
|
||||
job->blockTarget = Gostcoin::TargetFromBits(job->block->bits);
|
||||
|
||||
// Serialize transaction
|
||||
ByteBuffer coinbasebuf;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef STRATUM_JOB_H_
|
||||
#define STRATUM_JOB_H_
|
||||
|
||||
#include "Bitcoin.h"
|
||||
#include "Gostcoin.h"
|
||||
#include "Crypto.h"
|
||||
#include "Util.h"
|
||||
#include "BigNum.h"
|
||||
@ -14,7 +14,7 @@ namespace Stratum
|
||||
{
|
||||
public:
|
||||
uint64 diff;
|
||||
Bitcoin::BlockPtr block;
|
||||
Gostcoin::BlockPtr block;
|
||||
BinaryData coinbase1;
|
||||
BinaryData coinbase2;
|
||||
std::set<uint64> shares;
|
||||
|
@ -30,7 +30,7 @@ namespace Stratum
|
||||
_io_service.post(boost::bind(&Client::SendJob, (*it), resetWork));
|
||||
}
|
||||
|
||||
bool Server::SubmitBlock(Bitcoin::Block block)
|
||||
bool Server::SubmitBlock(Gostcoin::Block block)
|
||||
{
|
||||
return NetworkMgr::Instance()->SubmitBlock(block);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "Log.h"
|
||||
#include "JSON.h"
|
||||
#include "JSONRPC.h"
|
||||
#include "Bitcoin.h"
|
||||
#include "Gostcoin.h"
|
||||
#include "Util.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "NetworkMgr.h"
|
||||
@ -76,14 +76,14 @@ namespace Stratum
|
||||
}
|
||||
|
||||
// Returns current work
|
||||
Bitcoin::BlockPtr GetWork()
|
||||
Gostcoin::BlockPtr GetWork()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> guard(_mtxCurrentWork);
|
||||
return _currentWork;
|
||||
}
|
||||
|
||||
// Block template update event
|
||||
void BlockNotify(Bitcoin::BlockPtr block, bool newBlock)
|
||||
void BlockNotify(Gostcoin::BlockPtr block, bool newBlock)
|
||||
{
|
||||
sLog.Debug(LOG_STRATUM, "Received block template update");
|
||||
_mtxCurrentWork.lock();
|
||||
@ -95,8 +95,8 @@ namespace Stratum
|
||||
// Resets work for all clients
|
||||
void SendBlockTmpl(bool resetWork);
|
||||
|
||||
// Submits block to bitcoind
|
||||
bool SubmitBlock(Bitcoin::Block block);
|
||||
// Submits block to gostcoind
|
||||
bool SubmitBlock(Gostcoin::Block block);
|
||||
|
||||
// Disconnects client
|
||||
void Disconnect(ClientPtr client)
|
||||
@ -173,7 +173,7 @@ namespace Stratum
|
||||
boost::mutex _mtxBans;
|
||||
|
||||
// Work
|
||||
Bitcoin::BlockPtr _currentWork;
|
||||
Gostcoin::BlockPtr _currentWork;
|
||||
boost::mutex _mtxCurrentWork;
|
||||
uint32 _extranonce;
|
||||
boost::mutex _mtxExtranonce;
|
||||
|
@ -4,7 +4,7 @@ file(GLOB_RECURSE sources_MySQL MySQL/*.cpp MySQL/*.h)
|
||||
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
|
||||
file(GLOB_RECURSE sources_JSON JSON/*.cpp JSON/*.h)
|
||||
file(GLOB_RECURSE sources_JSONRPC JSONRPC/*.cpp JSONRPC/*.h)
|
||||
file(GLOB_RECURSE sources_Bitcoin Bitcoin/*.cpp Bitcoin/*.h)
|
||||
file(GLOB_RECURSE sources_Gostcoin Gostcoin/*.cpp Gostcoin/*.h)
|
||||
|
||||
file(GLOB sources_localdir *.cpp *.h)
|
||||
|
||||
@ -14,7 +14,7 @@ set(sources_Shared
|
||||
${sources_Logging}
|
||||
${sources_JSON}
|
||||
${sources_JSONRPC}
|
||||
${sources_Bitcoin}
|
||||
${sources_Gostcoin}
|
||||
${sources_localdir}
|
||||
)
|
||||
|
||||
@ -25,7 +25,7 @@ include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Logging
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/JSON
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/JSONRPC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Bitcoin
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Gostcoin
|
||||
${Boost_INCLUDE_DIR}
|
||||
${MYSQL_INCLUDE_DIR}
|
||||
${GMP_INCLUDE_DIR}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "Block.h"
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
void Block::BuildMerkleTree()
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
#ifndef BITCOIN_BLOCK_H_
|
||||
#define BITCOIN_BLOCK_H_
|
||||
#ifndef GOSTCOIN_BLOCK_H_
|
||||
#define GOSTCOIN_BLOCK_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "Transaction.h"
|
||||
@ -7,7 +7,7 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
class BlockHeader
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
#ifndef BITCOIN_H_
|
||||
#define BITCOIN_H_
|
||||
#ifndef GOSTCOIN_H_
|
||||
#define GOSTCOIN_H_
|
||||
|
||||
#include "Block.h"
|
||||
#include "Transaction.h"
|
||||
@ -8,7 +8,7 @@
|
||||
#include "BigNum.h"
|
||||
#include <gmpxx.h>
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
inline BigInt TargetToDiff(BigInt val)
|
||||
{
|
||||
@ -40,7 +40,7 @@ namespace Bitcoin
|
||||
ByteBuffer scriptsig;
|
||||
scriptsig << blockHeight << extranonce_ph;
|
||||
|
||||
Bitcoin::OutPoint outpoint;
|
||||
Gostcoin::OutPoint outpoint;
|
||||
outpoint.hash.resize(32, 0);
|
||||
outpoint.n = 0xFFFFFFFF;
|
||||
|
||||
@ -51,7 +51,7 @@ namespace Bitcoin
|
||||
|
||||
TxOut txout;
|
||||
txout.value = value;
|
||||
txout.scriptPubKey = Bitcoin::Script(pubkey) + Bitcoin::OP_CHECKSIG;
|
||||
txout.scriptPubKey = Gostcoin::Script(pubkey) + Gostcoin::OP_CHECKSIG;
|
||||
|
||||
Transaction tx;
|
||||
tx.version = 1;
|
@ -1,5 +1,5 @@
|
||||
#ifndef BITCOIN_SCRIPT_H_
|
||||
#define BITCOIN_SCRIPT_H_
|
||||
#ifndef GOSTCOIN_SCRIPT_H_
|
||||
#define GOSTCOIN_SCRIPT_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "ByteBuffer.h"
|
||||
@ -7,7 +7,7 @@
|
||||
#include <boost/range/join.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
enum ScriptOPCode
|
||||
{
|
@ -3,10 +3,10 @@
|
||||
#include "Transaction.h"
|
||||
#include "Block.h"
|
||||
|
||||
using namespace Bitcoin;
|
||||
using namespace Gostcoin;
|
||||
|
||||
// VarInt
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, VarInt& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, VarInt& b)
|
||||
{
|
||||
if (b.value < 0xfd) {
|
||||
a.Append<uint8>(b.value);
|
||||
@ -22,7 +22,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, VarInt& b)
|
||||
}
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, VarInt& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, VarInt& b)
|
||||
{
|
||||
uint8 size = a.Read<uint8>();
|
||||
|
||||
@ -37,14 +37,14 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, VarInt& b)
|
||||
}
|
||||
|
||||
// Script
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Script& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, Script& b)
|
||||
{
|
||||
VarInt size(b.script.size());
|
||||
a << size;
|
||||
a << b.script;
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Script& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, Script& b)
|
||||
{
|
||||
VarInt size;
|
||||
a >> size;
|
||||
@ -53,13 +53,13 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Script& b)
|
||||
}
|
||||
|
||||
// OutPoint
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, OutPoint& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, OutPoint& b)
|
||||
{
|
||||
a << b.hash;
|
||||
a << b.n;
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, OutPoint& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, OutPoint& b)
|
||||
{
|
||||
b.hash = a.ReadBinary(32);
|
||||
a >> b.n;
|
||||
@ -67,14 +67,14 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, OutPoint& b)
|
||||
}
|
||||
|
||||
// TxIn
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, TxIn& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, TxIn& b)
|
||||
{
|
||||
a << b.prevout;
|
||||
a << b.script;
|
||||
a << b.n;
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxIn& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, TxIn& b)
|
||||
{
|
||||
a >> b.prevout;
|
||||
a >> b.script;
|
||||
@ -83,13 +83,13 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxIn& b)
|
||||
}
|
||||
|
||||
// TxOut
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, TxOut& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, TxOut& b)
|
||||
{
|
||||
a << b.value;
|
||||
a << b.scriptPubKey;
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxOut& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, TxOut& b)
|
||||
{
|
||||
a >> b.value;
|
||||
a >> b.scriptPubKey;
|
||||
@ -97,7 +97,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, TxOut& b)
|
||||
}
|
||||
|
||||
// Transaction
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, Transaction& b)
|
||||
{
|
||||
a << b.version;
|
||||
|
||||
@ -117,7 +117,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Transaction& b)
|
||||
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Transaction& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, Transaction& b)
|
||||
{
|
||||
a >> b.version;
|
||||
|
||||
@ -143,7 +143,7 @@ ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Transaction& b)
|
||||
}
|
||||
|
||||
// Block
|
||||
ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Block& b)
|
||||
ByteBuffer& Gostcoin::operator<<(ByteBuffer& a, Block& b)
|
||||
{
|
||||
a << b.version;
|
||||
a << b.prevBlockHash;
|
||||
@ -160,7 +160,7 @@ ByteBuffer& Bitcoin::operator<<(ByteBuffer& a, Block& b)
|
||||
|
||||
return a;
|
||||
}
|
||||
ByteBuffer& Bitcoin::operator>>(ByteBuffer& a, Block& b)
|
||||
ByteBuffer& Gostcoin::operator>>(ByteBuffer& a, Block& b)
|
||||
{
|
||||
a >> b.version;
|
||||
b.prevBlockHash = a.ReadBinary(32);
|
@ -1,7 +1,7 @@
|
||||
#include "Transaction.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
BinaryData Transaction::GetHash()
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
#ifndef BITCOIN_TRANSACTION_H_
|
||||
#define BITCOIN_TRANSACTION_H_
|
||||
#ifndef GOSTCOIN_TRANSACTION_H_
|
||||
#define GOSTCOIN_TRANSACTION_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "ByteBuffer.h"
|
||||
@ -7,7 +7,7 @@
|
||||
#include "Script.h"
|
||||
#include "Crypto.h"
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
class OutPoint
|
||||
{
|
@ -1,10 +1,10 @@
|
||||
#ifndef BITCOIN_VARINT_H_
|
||||
#define BITCOIN_VARINT_H_
|
||||
#ifndef GOSTCOIN_VARINT_H_
|
||||
#define GOSTCOIN_VARINT_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "ByteBuffer.h"
|
||||
|
||||
namespace Bitcoin
|
||||
namespace Gostcoin
|
||||
{
|
||||
class VarInt
|
||||
{
|
Loading…
Reference in New Issue
Block a user