static inline void xor_salsa8_sse2(__m128i B[4], const __m128i Bx[4])
{
- __m128i X0, X1, X2, X3;
- __m128i T;
- int i;
+ __m128i X0 = B[0] = _mm_xor_si128(B[0], Bx[0]);
+ __m128i X1 = B[1] = _mm_xor_si128(B[1], Bx[1]);
+ __m128i X2 = B[2] = _mm_xor_si128(B[2], Bx[2]);
+ __m128i X3 = B[3] = _mm_xor_si128(B[3], Bx[3]);
- X0 = B[0] = _mm_xor_si128(B[0], Bx[0]);
- X1 = B[1] = _mm_xor_si128(B[1], Bx[1]);
- X2 = B[2] = _mm_xor_si128(B[2], Bx[2]);
- X3 = B[3] = _mm_xor_si128(B[3], Bx[3]);
-
- for (i = 0; i < 8; i += 2) {
+ for (uint32_t i = 0; i < 8; i += 2) {
/* Operate on "columns". */
- T = _mm_add_epi32(X0, X3);
+ __m128i T = _mm_add_epi32(X0, X3);
X1 = _mm_xor_si128(X1, _mm_slli_epi32(T, 7));
X1 = _mm_xor_si128(X1, _mm_srli_epi32(T, 25));
T = _mm_add_epi32(X1, X0);
uint256 scrypt_blockhash(const uint8_t* input)
{
- uint256 result = 0;
uint8_t scratchpad[SCRYPT_BUFFER_SIZE];
+ __m128i *V = (__m128i *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));
+
uint8_t B[128];
+ void *const tmp = const_cast<uint8_t*>(input);
+ PKCS5_PBKDF2_HMAC(static_cast<const char*>(tmp), 80, input, 80, 1, EVP_sha256(), 128, B);
+
union {
__m128i i128[8];
uint32_t u32[32];
} X;
- __m128i *V;
- uint32_t i, j, k;
-
- V = (__m128i *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));
-
- void *const tmp = const_cast<uint8_t*>(input);
- PKCS5_PBKDF2_HMAC(static_cast<const char*>(tmp), 80, input, 80, 1, EVP_sha256(), 128, B);
-
+ uint32_t i, k;
for (k = 0; k < 2; k++) {
for (i = 0; i < 16; i++) {
X.u32[k * 16 + i] = le32dec(&B[(k * 16 + (i * 5 % 16)) * 4]);
xor_salsa8_sse2(&X.i128[4], &X.i128[0]);
}
for (i = 0; i < 1024; i++) {
- j = 8 * (X.u32[16] & 1023);
+ uint32_t j = 8 * (X.u32[16] & 1023);
for (k = 0; k < 8; k++)
X.i128[k] = _mm_xor_si128(X.i128[k], V[j + k]);
xor_salsa8_sse2(&X.i128[0], &X.i128[4]);
}
}
+ uint256 result = 0;
PKCS5_PBKDF2_HMAC(static_cast<const char*>(tmp), 80, B, 128, 1, EVP_sha256(), 32, (unsigned char*)&result);
return result;
// ********************************************************* Step 2: parameter interactions
- nNodeLifespan = (unsigned int)(GetArg("-addrlifespan", 7));
+ nNodeLifespan = GetArgUInt("-addrlifespan", 7);
fUseFastIndex = GetBoolArg("-fastindex", true);
fUseMemoryLog = GetBoolArg("-memorylog", true);
unsigned char pchData[65536];
do {
fseek(blkdat, nPos, SEEK_SET);
- int nRead = fread(pchData, 1, sizeof(pchData), blkdat);
+ size_t nRead = fread(pchData, 1, sizeof(pchData), blkdat);
if (nRead <= 8)
{
nPos = std::numeric_limits<uint32_t>::max();
}
// find last block in inv vector
- unsigned int nLastBlock = std::numeric_limits<uint32_t>::max();
- for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) {
+ size_t nLastBlock = std::numeric_limits<size_t>::max();
+ for (size_t nInv = 0; nInv < vInv.size(); nInv++) {
if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) {
nLastBlock = vInv.size() - 1 - nInv;
break;
}
}
CTxDB txdb("r");
- for (unsigned int nInv = 0; nInv < vInv.size(); nInv++)
+ for (size_t nInv = 0; nInv < vInv.size(); nInv++)
{
const CInv &inv = vInv[nInv];
}
// Largest block you're willing to create:
- unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
+ unsigned int nBlockMaxSize = GetArgUInt("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
- nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
+ nBlockMaxSize = std::max(1000u, std::min(MAX_BLOCK_SIZE-1000u, nBlockMaxSize));
// How much of the block should be dedicated to high-priority transactions,
// included regardless of the fees they pay
- unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000);
+ unsigned int nBlockPrioritySize = GetArgUInt("-blockprioritysize", 27000);
nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize);
// Minimum block size you want to create; block will be filled with free transactions
// until there are no more or the block reaches this size:
- unsigned int nBlockMinSize = GetArg("-blockminsize", 0);
+ unsigned int nBlockMinSize = GetArgUInt("-blockminsize", 0);
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
// Fee-per-kilobyte amount considered the same as "free"
}
#undef X
-
-
-
-
+void Release(CNode* node) {
+ node->Release();
+}
}
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodesCopy)
- pnode->Release();
+ for_each(vNodesCopy.begin(), vNodesCopy.end(), Release);
}
Sleep(10);
{
LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodesCopy)
- pnode->Release();
+ for_each(vNodesCopy.begin(), vNodesCopy.end(), Release);
}
// Wait and allow messages to bunch up.