blukecoin.h raw

   1  // Copyright (c) 2026 The Limenka developers
   2  // Distributed under the MIT software license, see the accompanying
   3  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   4  
   5  #ifndef LIMENKA_NODE_BLUKECOIN_H
   6  #define LIMENKA_NODE_BLUKECOIN_H
   7  
   8  #include <netaddress.h>
   9  #include <sync.h>
  10  #include <uint256.h>
  11  
  12  #include <optional>
  13  #include <set>
  14  #include <vector>
  15  
  16  class CBlockHeader;
  17  class CService;
  18  namespace Consensus { struct Params; }
  19  
  20  namespace node {
  21  
  22  //! A bitcoin-blake2b (blukecoin) node is a fork of the parent chain that
  23  //! keeps the parent's P2P identity (magic, port, genesis) but hashes block
  24  //! headers with blake2b instead of SHA256d.  Its blocks can therefore never
  25  //! be validated on the parent chain, which is exactly how it is detected:
  26  //! a transmitted header whose claimed difficulty is within the mainnet
  27  //! powLimit range but whose SHA256d hash does not meet it is on a foreign
  28  //! hashing chain.
  29  class BlukecoinManager
  30  {
  31  public:
  32      //! Test a single header for the blake2b-chain signature.  Returns
  33      //! std::nullopt when the header's nBits is outside the mainnet powLimit
  34      //! range (a low-work testnet fork, not blukecoin).
  35      static std::optional<bool> HeaderLooksBlake2b(const CBlockHeader& header, const Consensus::Params& params);
  36  
  37      //! Record a detected blukecoin node address (ip:port).
  38      void NoteDetected(const CService& addr);
  39  
  40      //! Whether the address is already known as a blukecoin node.
  41      bool IsKnown(const CService& addr) const;
  42  
  43      //! Snapshot of all known blukecoin node addresses.
  44      std::vector<CService> GetKnown() const;
  45  
  46  private:
  47      mutable Mutex m_mutex;
  48      std::set<CService> m_known GUARDED_BY(m_mutex);
  49  };
  50  
  51  } // namespace node
  52  
  53  #endif // LIMENKA_NODE_BLUKECOIN_H
  54