Browse Source

Code cleanup: use ECDSA_size() instead of fixed 10,000 byte sig buffer, and explicity init static var

0.8
Gavin Andresen 13 years ago
parent
commit
9ef7fa3447
  1. 11
      src/key.h
  2. 2
      src/main.cpp

11
src/key.h

@ -177,14 +177,15 @@ public: @@ -177,14 +177,15 @@ public:
}
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
unsigned int nSize = ECDSA_size(pkey);
vchSig.resize(nSize); // Make sure it is big enough
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
{
vchSig.clear();
unsigned char pchSig[10000];
unsigned int nSize = 0;
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
return false;
vchSig.resize(nSize);
memcpy(&vchSig[0], pchSig, nSize);
}
vchSig.resize(nSize); // Shrink to fit actual size
return true;
}

2
src/main.cpp

@ -1875,7 +1875,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) @@ -1875,7 +1875,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}
// Ask the first connected node for block updates
static int nAskedForBlocks;
static int nAskedForBlocks = 0;
if (!pfrom->fClient &&
(pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) &&
(nAskedForBlocks < 1 || vNodes.size() <= 1))

Loading…
Cancel
Save