diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index a4ac981..02804b4 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -33,8 +33,10 @@ jobs: apk add git cmake gcc g++ make - name: Checkout repository - run: | - git clone --recursive --shallow-submodules --filter=blob:none https://github.com/${{ github.repository }} + uses: actions/checkout@v3 + with: + submodules: true + path: p2pool - name: Build libcurl shell: alpine.sh {0} diff --git a/src/side_chain.cpp b/src/side_chain.cpp index 7be1a7a..baffa36 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -778,11 +778,12 @@ bool SideChain::get_outputs_blob(PoolBlock* block, uint64_t total_reward, std::v struct Data { - FORCEINLINE Data() : counter(0) {} + FORCEINLINE Data() : blockMinerWallet(nullptr), counter(0) {} Data(Data&&) = delete; Data& operator=(Data&&) = delete; std::vector tmpShares; + Wallet blockMinerWallet; hash txkeySec; std::atomic counter; }; @@ -817,6 +818,7 @@ bool SideChain::get_outputs_blob(PoolBlock* block, uint64_t total_reward, std::v } data = std::make_shared(); + data->blockMinerWallet = block->m_minerWallet; data->txkeySec = block->m_txkeySec; if (!get_shares(block, data->tmpShares) || !split_reward(total_reward, data->tmpShares, tmpRewards) || (tmpRewards.size() != data->tmpShares.size())) { @@ -830,6 +832,14 @@ bool SideChain::get_outputs_blob(PoolBlock* block, uint64_t total_reward, std::v // Helper jobs call get_eph_public_key with indices in descending order // Current thread will process indices in ascending order so when they meet, everything will be cached if (loop) { + // Avoid accessing block->m_minerWallet from other threads in "parallel_run" below + for (MinerShare& share : data->tmpShares) { + if (share.m_wallet == &block->m_minerWallet) { + share.m_wallet = &data->blockMinerWallet; + break; + } + } + parallel_run(loop, [data]() { Data* d = data.get(); hash eph_public_key;