Repository: bitcoin/bitcoin
File: src/node/interfaces.cpp (C++)

Code before:
            action = update_settings_func(value);
        });
        if (!action) return false;
        // Now dump value to disk if requested
        return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
    }
    bool overwriteRwSetting(const std::string& name, common::SettingsValue& value, bool write) override
    {
        if (value.isNull()) return deleteRwSettings(name, write);
        return updateRwSetting(name, [&](common::SettingsValue& settings) {
            settings = std::move(value);
            return write ? interfaces::SettingsAction::WRITE : interfaces::SettingsAction::SKIP_WRITE;
        });
    }
    bool deleteRwSettings(const std::string& name, bool write) override
    {
        args().LockSettings([&](common::Settings& settings) {
            settings.rw_settings.erase(name);
        });
        return !write || args().WriteSettingsFile();
    }
    void requestMempoolTransactions(Notifications& notifications) override
    {
        if (!m_node.mempool) return;
        LOCK2(::cs_main, m_node.mempool->cs);
        for (const CTxMemPoolEntry& entry : m_node.mempool->entryAll()) {
            notifications.transactionAddedToMempool(entry.GetSharedTx());
        }
    }
    bool hasAssumedValidChain() override
    {
        return chainman().IsSnapshotActive();
    }

    NodeContext* context() override { return &m_node; }
    ArgsManager& args() { return *Assert(m_node.args); }
    ChainstateManager& chainman() { return *Assert(m_node.chainman); }
    ValidationSignals& validation_signals() { return *Assert(m_node.validation_signals); }
    NodeContext& m_node;
};

class MinerImpl : public Mining
{
public:
    explicit MinerImpl(NodeContext& node) : m_node(node) {}

    bool isTestChain() override
    {
        return chainman().GetParams().IsTestChain();
    }


Review comment (performance):
In commit "Have createNewBlock return BlockTemplate interface" (b4782696a8ec5e21a41db3702d4b4dcc90ea40dd)

Could you move these member declarations to the bottom of the class? It makes it easier to see what state the interface accesses when state is declared at beginning or end of the class, not in the middle mixed with method definitions. 

I'm also wondering if it might be more efficient to avoid the call to CBlock::GetBlockHeader():

```diff
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -843,14 +843,10 @@ class BlockTemplateImpl : public BlockTemplate
 {
 public:
     explicit BlockTemplateImpl(std::unique_ptr<CBlockTemplate> block_template) : m_block_template(std::move(block_template)) {
-        m_block_header = m_block_template->block.GetBlockHeader();
     }
 
-    std::unique_ptr<CBlockTemplate> m_block_template;
-    CBlockHeader m_block_header;
-
     CBlockHeader getBlockHeader() override {
-        return m_block_header;
+        return Assert(m_block_template)->block;
     }
 
     CBlock getBlock() override
@@ -883,6 +879,7 @@ public:
         return GetWitnessCommitmentIndex(m_block_template->block);
     }
 
+    std::unique_ptr<CBlockTemplate> m_block_template;
 };
 
 class MinerImpl : public Mining
```



Code after:
            auto& value = ptr_value ? *ptr_value : settings.rw_settings[name];
            action = update_settings_func(value);
        });
        if (!action) return false;
        // Now dump value to disk if requested
        return *action == interfaces::SettingsAction::SKIP_WRITE || args().WriteSettingsFile();
    }
    bool overwriteRwSetting(const std::string& name, common::SettingsValue& value, bool write) override
    {
        if (value.isNull()) return deleteRwSettings(name, write);
        return updateRwSetting(name, [&](common::SettingsValue& settings) {
            settings = std::move(value);
            return write ? interfaces::SettingsAction::WRITE : interfaces::SettingsAction::SKIP_WRITE;
        });
    }
    bool deleteRwSettings(const std::string& name, bool write) override
    {
        args().LockSettings([&](common::Settings& settings) {
            settings.rw_settings.erase(name);
        });
        return !write || args().WriteSettingsFile();
    }
    void requestMempoolTransactions(Notifications& notifications) override
    {
        if (!m_node.mempool) return;
        LOCK2(::cs_main, m_node.mempool->cs);
        for (const CTxMemPoolEntry& entry : m_node.mempool->entryAll()) {
            notifications.transactionAddedToMempool(entry.GetSharedTx());
        }
    }
    bool hasAssumedValidChain() override
    {
        return chainman().IsSnapshotActive();
    }

    NodeContext* context() override { return &m_node; }
    ArgsManager& args() { return *Assert(m_node.args); }
    ChainstateManager& chainman() { return *Assert(m_node.chainman); }
    ValidationSignals& validation_signals() { return *Assert(m_node.validation_signals); }
    NodeContext& m_node;
};

class BlockTemplateImpl : public BlockTemplate
{
public:
    explicit BlockTemplateImpl(std::unique_ptr<CBlockTemplate> block_template) : m_block_template(std::move(block_template))
    {
        assert(m_block_template);
    }

    CBlockHeader getBlockHeader() override