Browse Source

Merge branch 'master' into peercoin

peercoin
Intel 11 years ago
parent
commit
2ff0db6b6c
  1. 1
      src/server/poolserver/Stratum/Client.cpp
  2. 3
      src/server/poolserver/Stratum/Client.h
  3. 7
      src/server/poolserver/Stratum/ShareLimiter.cpp
  4. 4
      src/server/shared/Bitcoin/Bitcoin.h
  5. 8
      src/server/shared/JSON/JSONReader.h
  6. 2
      src/server/shared/MySQL/DatabaseConnection.h
  7. 4
      src/server/shared/MySQL/DatabaseOperation.cpp
  8. 13
      src/server/shared/MySQL/DatabaseOperation.h
  9. 2
      src/server/shared/MySQL/DatabaseWorkerPool.h

1
src/server/poolserver/Stratum/Client.cpp

@ -359,7 +359,6 @@ namespace Stratum @@ -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;
}

3
src/server/poolserver/Stratum/Client.h

@ -15,8 +15,6 @@ @@ -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 @@ -31,7 +29,6 @@ namespace Stratum
{
_diff = sConfig.Get<uint32>("StratumMinDifficulty");
_minDiff = _diff;
_recvMessage.reserve(PACKET_ALLOC);
}
tcp::socket& GetSocket()

7
src/server/poolserver/Stratum/ShareLimiter.cpp

@ -21,11 +21,14 @@ namespace Stratum @@ -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));

4
src/server/shared/Bitcoin/Bitcoin.h

@ -29,7 +29,9 @@ namespace Bitcoin @@ -29,7 +29,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, BinaryData extras)

8
src/server/shared/JSON/JSONReader.h

@ -22,6 +22,14 @@ namespace JSONReader @@ -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)

2
src/server/shared/MySQL/DatabaseConnection.h

@ -87,7 +87,7 @@ namespace MySQL @@ -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;
}

4
src/server/shared/MySQL/DatabaseOperation.cpp

@ -21,9 +21,9 @@ namespace MySQL @@ -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());
}
}

13
src/server/shared/MySQL/DatabaseOperation.h

@ -40,22 +40,15 @@ namespace MySQL @@ -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;

2
src/server/shared/MySQL/DatabaseWorkerPool.h

@ -104,7 +104,7 @@ namespace MySQL @@ -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;

Loading…
Cancel
Save