| 96 | } |
| 97 | |
| 98 | void CLKeySearchDevice::initializeBloomFilter(const std::vector<struct hash160> &targets, uint64_t mask) |
| 99 | { |
| 100 | size_t sizeInWords = (mask + 1) / 32; |
| 101 | |
| 102 | uint32_t *buf = new uint32_t[sizeInWords]; |
| 103 | |
| 104 | for(size_t i = 0; i < sizeInWords; i++) { |
| 105 | buf[i] = 0; |
| 106 | } |
| 107 | |
| 108 | for(unsigned int k = 0; k < targets.size(); k++) { |
| 109 | |
| 110 | unsigned int hash[5]; |
| 111 | unsigned int h5 = 0; |
| 112 | |
| 113 | uint64_t idx[5]; |
| 114 | |
| 115 | undoRMD160FinalRound(targets[k].h, hash); |
| 116 | |
| 117 | for(int i = 0; i < 5; i++) { |
| 118 | h5 += hash[i]; |
| 119 | } |
| 120 | |
| 121 | idx[0] = ((hash[0] << 6) | (h5 & 0x3f)) & mask; |
| 122 | idx[1] = ((hash[1] << 6) | ((h5 >> 6) & 0x3f)) & mask; |
| 123 | idx[2] = ((hash[2] << 6) | ((h5 >> 12) & 0x3f)) & mask; |
| 124 | idx[3] = ((hash[3] << 6) | ((h5 >> 18) & 0x3f)) & mask; |
| 125 | idx[4] = ((hash[4] << 6) | ((h5 >> 24) & 0x3f)) & mask; |
| 126 | |
| 127 | for(int i = 0; i < 5; i++) { |
| 128 | uint64_t j = idx[i]; |
| 129 | buf[j / 32] |= 1 << (j % 32); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | |
| 134 | _targetMemSize = sizeInWords * sizeof(uint32_t); |
| 135 | |
| 136 | _deviceTargetList.mask = mask; |
| 137 | _deviceTargetList.ptr = _clContext->malloc(sizeInWords * sizeof(uint32_t)); |
| 138 | _deviceTargetList.size = targets.size(); |
| 139 | _clContext->copyHostToDevice(buf, _deviceTargetList.ptr, sizeInWords * sizeof(uint32_t)); |
| 140 | |
| 141 | delete[] buf; |
| 142 | } |
| 143 | |
| 144 | void CLKeySearchDevice::allocateBuffers() |
| 145 | { |
nothing calls this directly
no test coverage detected