Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
// Copyright (c) 2018 The Bitcoin Core developers | // Copyright (c) 2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <threadsafety.h> | |||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <memory> | #include <memory> | ||||
#include <utility> | #include <utility> | ||||
namespace interfaces { | namespace interfaces { | ||||
namespace { | namespace { | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | class LockImpl : public Chain::Lock { | ||||
Optional<int> findLocatorFork(const CBlockLocator &locator) override { | Optional<int> findLocatorFork(const CBlockLocator &locator) override { | ||||
LockAnnotation lock(::cs_main); | LockAnnotation lock(::cs_main); | ||||
if (CBlockIndex *fork = | if (CBlockIndex *fork = | ||||
FindForkInGlobalIndex(::ChainActive(), locator)) { | FindForkInGlobalIndex(::ChainActive(), locator)) { | ||||
return fork->nHeight; | return fork->nHeight; | ||||
} | } | ||||
return nullopt; | return nullopt; | ||||
} | } | ||||
bool contextualCheckTransactionForCurrentBlock( | |||||
const Consensus::Params ¶ms, const CTransaction &tx, | |||||
CValidationState &state) override { | |||||
LockAnnotation lock(::cs_main); | |||||
return ContextualCheckTransactionForCurrentBlock(params, tx, state); | |||||
} | |||||
}; | }; | ||||
class LockingStateImpl : public LockImpl, | class LockingStateImpl : public LockImpl, | ||||
public UniqueLock<CCriticalSection> { | public UniqueLock<CCriticalSection> { | ||||
using UniqueLock::UniqueLock; | using UniqueLock::UniqueLock; | ||||
}; | }; | ||||
class ChainImpl : public Chain { | class ChainImpl : public Chain { | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |