mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Code cleanup: use ECDSA_size() instead of fixed 10,000 byte sig buffer, and explicity init static var
This commit is contained in:
parent
26ce92b352
commit
9ef7fa3447
13
src/key.h
13
src/key.h
@ -178,13 +178,14 @@ public:
|
|||||||
|
|
||||||
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
|
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
|
||||||
{
|
{
|
||||||
vchSig.clear();
|
unsigned int nSize = ECDSA_size(pkey);
|
||||||
unsigned char pchSig[10000];
|
vchSig.resize(nSize); // Make sure it is big enough
|
||||||
unsigned int nSize = 0;
|
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
|
||||||
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
|
{
|
||||||
|
vchSig.clear();
|
||||||
return false;
|
return false;
|
||||||
vchSig.resize(nSize);
|
}
|
||||||
memcpy(&vchSig[0], pchSig, nSize);
|
vchSig.resize(nSize); // Shrink to fit actual size
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1875,7 +1875,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ask the first connected node for block updates
|
// Ask the first connected node for block updates
|
||||||
static int nAskedForBlocks;
|
static int nAskedForBlocks = 0;
|
||||||
if (!pfrom->fClient &&
|
if (!pfrom->fClient &&
|
||||||
(pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) &&
|
(pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) &&
|
||||||
(nAskedForBlocks < 1 || vNodes.size() <= 1))
|
(nAskedForBlocks < 1 || vNodes.size() <= 1))
|
||||||
|
Loading…
Reference in New Issue
Block a user