Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/impl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(ltc)
add_subdirectory(btc)
add_subdirectory(btc)
add_subdirectory(dgb)
2 changes: 1 addition & 1 deletion src/impl/dgb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# follows the OBJECT-lib convention PR; held ~2-3 heartbeats, not raced here.
if(COIN_DGB)
message(STATUS "c2pool: DGB Scrypt-only coin module enabled (skeleton)")
# add_subdirectory(coin)
add_subdirectory(coin)
# add_subdirectory(daemon)
# add_subdirectory(test)
endif()
19 changes: 14 additions & 5 deletions src/impl/dgb/coin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
# dgb_coin -- DGB coin-layer library (Path A minimal-stub surface).
# Mirrors src/impl/btc/coin/CMakeLists.txt, listing only the files that exist
# at this milestone. NOT yet referenced by any add_subdirectory(): top-level
# registration of src/impl/dgb follows the ci-steward OBJECT-lib convention
# (see ../CMakeLists.txt); staged here so that wiring is a one-line flip.
# dgb_coin -- DGB coin-layer library.
# Mirrors src/impl/btc/coin/CMakeLists.txt. Phase A (#82) adds the embedded
# P2P + mempool layer (non-MWEB, btc-shaped; Scrypt PoW lives in header_chain).
# NOT yet referenced by any add_subdirectory(): top-level registration of
# src/impl/dgb follows the ci-steward OBJECT-lib convention (see ../CMakeLists.txt);
# staged here so that wiring is a one-line flip.

set(dgb_coin_impl
rpc_data.hpp
rpc.hpp
p2p_connection.hpp p2p_connection.cpp
p2p_node.cpp p2p_node.hpp
p2p_messages.hpp
node.hpp
coin_node.hpp coin_node.cpp
)

set(dgb_coin_interface
txidcache.hpp
node_interface.hpp
block.hpp
transaction.hpp transaction.cpp
compact_blocks.hpp
header_chain.hpp
mempool.hpp
template_builder.hpp
)

Expand Down
125 changes: 125 additions & 0 deletions src/impl/dgb/coin/block.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#pragma once

// DGB block/header types. 1:1 mirror of src/impl/btc/coin/block.hpp (NON-MWEB).
//
// >>> MULTI-ALGO NOTE (project_v36_dgb_scrypt_only) <<<
// The 80-byte header layout (version|prev|merkle|time|bits|nonce) is identical
// across DGB`s 5 algos -- this serialization is algo-agnostic and correct as-is.
// The block version field additionally ENCODES the mining algo in its bits;
// DGB-Scrypt validation reads that algo selector in header_chain.hpp, NOT here.
// Do not add per-algo branching to (de)serialization -- it is single-format.

#include "transaction.hpp"

#include <core/uint256.hpp>
#include <core/pack_types.hpp>
#include <core/netaddress.hpp>

namespace dgb
{

namespace coin
{

struct SmallBlockHeaderType
{
uint64_t m_version {};
uint256 m_previous_block{};
uint32_t m_timestamp{};
uint32_t m_bits{};
uint32_t m_nonce{};

C2POOL_SERIALIZE_METHODS(SmallBlockHeaderType) { READWRITE(VarInt(obj.m_version), obj.m_previous_block, obj.m_timestamp, obj.m_bits, obj.m_nonce); }

SmallBlockHeaderType() {}

void SetNull()
{
m_version = 0;
m_previous_block.SetNull();
m_timestamp = 0;
m_bits = 0;
m_nonce = 0;
}

bool IsNull() const
{
return (m_bits == 0);
}
};

struct BlockHeaderType : SmallBlockHeaderType
{
uint256 m_merkle_root;

// Full block header uses fixed 4-byte int32 version (not VarInt like SmallBlockHeaderType)
template<typename Stream>
void Serialize(Stream& s) const {
uint32_t version32 = static_cast<uint32_t>(m_version);
::Serialize(s, version32);
::Serialize(s, m_previous_block);
::Serialize(s, m_merkle_root);
::Serialize(s, m_timestamp);
::Serialize(s, m_bits);
::Serialize(s, m_nonce);
}
template<typename Stream>
void Unserialize(Stream& s) {
uint32_t version32;
::Unserialize(s, version32);
m_version = version32;
::Unserialize(s, m_previous_block);
::Unserialize(s, m_merkle_root);
::Unserialize(s, m_timestamp);
::Unserialize(s, m_bits);
::Unserialize(s, m_nonce);
}

BlockHeaderType() : SmallBlockHeaderType() { }

void SetNull()
{
SmallBlockHeaderType::SetNull();
m_merkle_root.SetNull();
}

bool IsNull() const
{
return (m_bits == 0);
}

};

struct BlockType : BlockHeaderType
{
std::vector<MutableTransaction> m_txs;

template <typename Stream>
void Serialize(Stream& s) const {
BlockHeaderType::Serialize(s);
::Serialize(s, TX_WITH_WITNESS(m_txs));
}

template <typename Stream>
void Unserialize(Stream& s) {
BlockHeaderType::Unserialize(s);
::Unserialize(s, TX_WITH_WITNESS(m_txs));
}

BlockType() : BlockHeaderType() { }

void SetNull()
{
BlockHeaderType::SetNull();
m_txs.clear();
}

bool IsNull() const
{
return BlockHeaderType::IsNull();
}
};

} // namespace coin

} // namespace dgb
Loading
Loading