From: CryptoManiac Date: Mon, 12 Oct 2015 21:55:51 +0000 (-0700) Subject: RPC scaninput: Replace generic implementation with one-way assembler implementation... X-Git-Tag: nvc-v0.5.5~38 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=d32e0b108f1fb57e57e329b91b33fc55c59131ca RPC scaninput: Replace generic implementation with one-way assembler implementation if USE_ASM flag is set --- diff --git a/src/kernel.cpp b/src/kernel.cpp index 4a4a23c..e253ce8 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -456,6 +456,9 @@ static const uint32_t block2_suffix_4way[4 * 8] = { 0x00000100, 0x00000100, 0x00000100, 0x00000100 }; +// Sha256 initial state +static const uint32_t sha256_initial[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + extern "C" int sha256_use_4way(); extern "C" void sha256_init(uint32_t *state); extern "C" void sha256_transform(uint32_t *state, const uint32_t *block, int swap); @@ -511,10 +514,9 @@ public: bnTargetPerCoinDay.SetCompact(nBits); uint256 nMaxTarget = (bnTargetPerCoinDay * bnValueIn * nStakeMaxAge / COIN / nOneDay).getuint256(); - uint32_t state1[4 * 8] __attribute__((aligned(16))); - uint32_t state2[4 * 8] __attribute__((aligned(16))); uint32_t blocks1[4 * 16] __attribute__((aligned(16))); uint32_t blocks2[4 * 16] __attribute__((aligned(16))); + uint32_t candidates[4 * 8] __attribute__((aligned(16))); vector vRow = vector(4); uint32_t *pnKernel = (uint32_t *) kernel; @@ -535,8 +537,8 @@ public: // Stopping search in case of shutting down for (uint32_t nTimeTx=nIntervalBegin, nMaxTarget32 = nMaxTarget.Get32(7); nTimeTx nMaxTarget32) + if (nHash7 > nMaxTarget32) continue; + uint256 nHashProofOfStake; + uint32_t *pnHashProofOfStake = (uint32_t *) &nHashProofOfStake; + + for (int i = 0; i < 7; i++) + pnHashProofOfStake[i] = __builtin_bswap32(candidate[i]); + pnHashProofOfStake[7] = nHash7; + CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay; CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay; - if (bnTargetProofOfStake >= CBigNum(*pnHashProofOfStake)) - solutions.push_back(std::pair(*pnHashProofOfStake, nTimeTx)); + if (bnTargetProofOfStake >= CBigNum(nHashProofOfStake)) + solutions.push_back(std::pair(nHashProofOfStake, nTimeTx)); } } @@ -623,7 +631,7 @@ public: if (fUse4Way) Do_4way(); else - Do_generic(); + Do_oneway(); } vector >& GetSolutions()