1
0
mirror of https://github.com/GOSTSec/poolserver synced 2025-01-14 08:47:53 +00:00
This commit is contained in:
Intel 2014-05-05 11:39:51 -04:00
parent 62fcdc805a
commit c8e00cd64d
9 changed files with 23 additions and 21 deletions

View File

@ -359,7 +359,6 @@ namespace Stratum
sLog.Error(LOG_SERVER, "Exception caught while parsing json: %s", e.what());
}
_recvMessage.clear();
_recvMessage.reserve(PACKET_ALLOC);
} else
_recvMessage += c;
}

View File

@ -15,8 +15,6 @@
#include <boost/enable_shared_from_this.hpp>
#include <set>
#define PACKET_ALLOC 128
using namespace boost;
using namespace boost::asio::ip;
@ -31,7 +29,6 @@ namespace Stratum
{
_diff = sConfig.Get<uint32>("StratumMinDifficulty");
_minDiff = _diff;
_recvMessage.reserve(PACKET_ALLOC);
}
tcp::socket& GetSocket()

View File

@ -21,11 +21,14 @@ namespace Stratum
_lastRetarget = curTime;
// Check if miner is ok
if (_totalShares > 20 && (double(_totalBadShares)/double(_totalShares)) > 0.8)
if (_totalShares > 50 && (double(_totalBadShares)/double(_totalShares)) > 0.8)
_client->Ban(60);
while (_shares.size() && (_shares.front() < curTime - RETARGET_TIME_BUFFER))
while (_shares.size()) {
if (_shares.front() > curTime - RETARGET_TIME_BUFFER)
break;
_shares.pop_front();
}
uint32 interval = std::min(curTime - _startTime, uint64(RETARGET_TIME_BUFFER));

View File

@ -28,7 +28,9 @@ namespace Bitcoin
mpz_t power;
mpz_init(power);
mpz_ui_pow_ui(power, 2, 8 * (nbytes - 3));
return BigInt(bits & 0xFFFFFF) * BigInt(power);
BigInt result = BigInt(bits & 0xFFFFFF) * BigInt(power);
mpz_clear(power);
return result;
}
inline Transaction CreateCoinbaseTX(uint32 blockHeight, BinaryData pubkey, int64 value)

View File

@ -22,6 +22,14 @@ namespace JSONReader
_stack.push_back(&node);
}
~SemanticFunctions()
{
for (uint32 i = 0; i+1 < _stack.size(); ++i) {
delete _stack.back();
_stack.pop_back();
}
}
void BeginObject(char ch)
{
if (_stack.back()->GetType() == JSON_NULL)

View File

@ -87,7 +87,7 @@ namespace MySQL
char* buf = new char[text.length()*2 + 1];
mysql_real_escape_string(_mysql, buf, text.c_str(), text.length());
std::string result(buf);
delete buf;
delete[] buf;
return result;
}

View File

@ -21,9 +21,9 @@ namespace MySQL
void DatabaseQueryOperation::Execute()
{
if (_callback) {
ResultSet* result = _conn->Query(_query);
ResultSet* result = _conn->Query(_query.c_str());
_callback(QueryResult(result));
} else
_conn->Execute(_query);
_conn->Execute(_query.c_str());
}
}

View File

@ -40,22 +40,15 @@ namespace MySQL
class DatabaseQueryOperation : public DatabaseOperation
{
public:
DatabaseQueryOperation(const char* query, DatabaseCallback callback = NULL): DatabaseOperation(), _callback(callback)
{
_query = new char[strlen(query)];
strcpy(_query, const_cast<char *>(query));
}
DatabaseQueryOperation(const char* query, DatabaseCallback callback = NULL): DatabaseOperation(), _callback(callback), _query(query) {}
~DatabaseQueryOperation()
{
delete[] _query;
}
~DatabaseQueryOperation() {}
void Execute();
private:
DatabaseCallback _callback;
char* _query;
std::string _query;
};
typedef Util::SynchronisedQueue<DatabaseOperation*> DatabaseWorkQueue;

View File

@ -104,7 +104,7 @@ namespace MySQL
private:
DatabaseConnection* GetSyncConnection()
{
uint32 i;
uint32 i = 0;
uint8 conn_size = _connections[MYSQL_CONN_SYNC].size();
DatabaseConnection* conn = NULL;