sgns::crdt::GraphsyncDAGSyncer¶
A DAGSyncer is an abstraction to an IPLD-based p2p storage layer. A DAGSyncer is a DAGService with the ability to publish new ipld nodes to the network, and retrieving others from it.
#include <graphsync_dagsyncer.hpp>
Inherits from sgns::crdt::DAGSyncer, std::enable_shared_from_this< GraphsyncDAGSyncer >
Public Classes¶
| Name | |
|---|---|
| struct | BlacklistEntry |
Public Types¶
| Name | |
|---|---|
| enum class uint8_t | Error |
| using ipfs_lite::ipfs::IpfsDatastore | IpfsDatastore |
| using ipfs_lite::ipfs::graphsync::Graphsync | Graphsync |
| using ipfs_lite::ipfs::graphsync::ResponseMetadata | ResponseMetadata |
| using ipfs_lite::ipfs::graphsync::Extension | Extension |
| using ipfs_lite::ipfs::graphsync::ResponseStatusCode | ResponseStatusCode |
| using libp2p::multi::Multiaddress | Multiaddress |
| using libp2p::multi::Multihash | Multihash |
| using libp2p::peer::PeerId | PeerId |
| using libp2p::protocol::Subscription | Subscription |
| using base::Logger | Logger |
| using Graphsync::BlockCallback | BlockCallback |
| using size_t | PeerKey |
| using std::pair< PeerId, std::vector< Multiaddress > > | PeerEntry |
| using std::map< CID, std::vector< PeerKey > > | RouteMapType |
Public Functions¶
| Name | |
|---|---|
| GraphsyncDAGSyncer(std::shared_ptr< IpfsDatastore > block_datastore, std::shared_ptr< Graphsync > graphsync, std::shared_ptr< libp2p::Host > host) | |
| ~GraphsyncDAGSyncer() override | |
| outcome::result< void > | Listen(const Multiaddress & listen_to) |
| outcome::result< void > | StartSync() |
| void | AddRoute(const CID & cid, const PeerId & peer, std::vector< Multiaddress > address) |
| outcome::result< void > | addNode(std::shared_ptr< const ipfs_lite::ipld::IPLDNode > node) override |
| outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > | getNode(const CID & cid) const override |
| outcome::result< void > | removeNode(const CID & cid) override |
| outcome::result< void > | StageBlockRemoval(const CID & cid, const std::unique_ptr< storage::BufferBatch > & aBatch) |
| outcome::result< bool > | HasRawBlockBytes(const CID & cid) const |
| outcome::result< size_t > | select(gsl::span< const uint8_t > root_cid, gsl::span< const uint8_t > selector, std::function< bool(std::shared_ptr< const ipfs_lite::ipld::IPLDNode > node)> handler) const override |
| outcome::result< std::shared_ptr< ipfs_lite::ipfs::merkledag::Leaf > > | fetchGraph(const CID & cid) const override |
| outcome::result< std::shared_ptr< ipfs_lite::ipfs::merkledag::Leaf > > | fetchGraphOnDepth(const CID & cid, uint64_t depth) const override |
| virtual outcome::result< bool > | HasBlock(const CID & cid) const override |
| virtual outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > | GetNodeWithoutRequest(const CID & cid) const override |
| outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > | GetNodeFromMerkleDAG(const CID & cid) const |
| virtual std::pair< LinkInfoSet, LinkInfoSet > | TraverseCIDsLinks(ipfs_lite::ipld::IPLDNode & node, std::string link_name ="", LinkInfoSet visited ={}) const override |
| virtual outcome::result< void > | markResolved(const CID & cid) override |
| virtual outcome::result< bool > | isResolved(const CID & cid) const override |
| outcome::result< PeerId > | GetId() const |
| outcome::result< libp2p::peer::PeerInfo > | GetPeerInfo() const |
| void | AddToBlackList(const PeerId & peer) const |
| bool | IsOnBlackList(const PeerId & peer) const |
| virtual void | InitCIDBlock(const CID & cid) override |
| virtual bool | IsCIDInCache(const CID & cid) const override |
| virtual outcome::result< void > | DeleteCIDBlock(const CID & cid) override |
| virtual void | Stop() override |
| void | SetBlacklistBackoffTimeoutForTest(uint64_t override_ms) override Test-only configuration seam for the blacklist backoff timeout (developer directive 2026-09-03). |
Additional inherited members¶
Public Types inherited from sgns::crdt::DAGSyncer
| Name | |
|---|---|
| using std::pair< CID, std::string > | LinkInfoPair |
| using std::set< LinkInfoPair > | LinkInfoSet |
Public Types Documentation¶
enum Error¶
| Enumerator | Value | Description |
|---|---|---|
| CID_NOT_FOUND | 0 | The requested CID wasn't found. |
| ROUTE_NOT_FOUND | Route for the CID wasn't found. | |
| PEER_BLACKLISTED | The peer that has the CID is blacklisted. | |
| TIMED_OUT | The request has timed out. | |
| DAGSYNCER_NOT_STARTED | Start wasn't called, or StopSync was called. | |
| GRAPHSYNC_IS_NULL | Graphsync member is nullptr. | |
| HOST_IS_NULL | Graphsync member is nullptr. |
using IpfsDatastore¶
using Graphsync¶
using ResponseMetadata¶
using sgns::crdt::GraphsyncDAGSyncer::ResponseMetadata = ipfs_lite::ipfs::graphsync::ResponseMetadata;
using Extension¶
using ResponseStatusCode¶
using sgns::crdt::GraphsyncDAGSyncer::ResponseStatusCode = ipfs_lite::ipfs::graphsync::ResponseStatusCode;
using Multiaddress¶
using Multihash¶
using PeerId¶
using Subscription¶
using Logger¶
using BlockCallback¶
using PeerKey¶
using PeerEntry¶
using RouteMapType¶
Public Functions Documentation¶
function GraphsyncDAGSyncer¶
GraphsyncDAGSyncer(
std::shared_ptr< IpfsDatastore > block_datastore,
std::shared_ptr< Graphsync > graphsync,
std::shared_ptr< libp2p::Host > host
)
function ~GraphsyncDAGSyncer¶
function Listen¶
function StartSync¶
Starts instance and subscribes to blocks
function AddRoute¶
function addNode¶
function getNode¶
outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > getNode(
const CID & cid
) const override
function removeNode¶
function StageBlockRemoval¶
outcome::result< void > StageBlockRemoval(
const CID & cid,
const std::unique_ptr< storage::BufferBatch > & aBatch
)
Parameters:
- cid CID whose block bytes are staged for removal
- aBatch caller-owned batch to stage the remove into; never committed by this function
Return: outcome::success on success or outcome::failure otherwise
Stages the removal of a block's raw storage key into the caller-owned batch. The staged key is exactly CID::toBytes() – the block-bytes key of the vendored RocksdbDatastore (its encode() at thirdparty/ipfs-lite-cpp/ipfs_lite/ipfs/impl/datastore_rocksdb.cpp:14-18); this method is the ONE SuperGNUS-side home of that key format.
The seal marker (the vendored seal(), datastore_rocksdb.cpp:48-56) is a DIFFERENT key and is deliberately never constructed here: it is the traversal terminator that prevents re-fetch storms on the single DAG worker, so erasing a block must never erase its seal.
The immediate node-removal override directly above stays dormant (zero production callers) because its chain executes its own standalone db->Delete and cannot join an external WriteBatch; staging into the caller's batch is what makes the atomic one-commit erase of PRUNE-02 possible. The caller (the GlobalDB compose) owns the single commit.
function HasRawBlockBytes¶
Parameters:
- cid CID whose raw block bytes are probed
Return: true when bytes exist; false when absent; failure only on a store read error (fail closed at the caller)
Byte-level block presence: true iff raw block BYTES exist for cid in the block store, with NO parse attempted. This is the discriminator HasBlock cannot provide (HasBlock = parse success of the node OR an LRU hit, so a PRESENT-but-corrupt block answers false there); the erase-side block gate uses it to tell an ABSENT block (erased – erase-completing evidence) from a corrupt one (fail closed). Consults the same CID::toBytes() keying as StageBlockRemoval (the one block-key home) through the vendored RocksdbDatastore::contains.
function select¶
outcome::result< size_t > select(
gsl::span< const uint8_t > root_cid,
gsl::span< const uint8_t > selector,
std::function< bool(std::shared_ptr< const ipfs_lite::ipld::IPLDNode > node)> handler
) const override
function fetchGraph¶
outcome::result< std::shared_ptr< ipfs_lite::ipfs::merkledag::Leaf > > fetchGraph(
const CID & cid
) const override
function fetchGraphOnDepth¶
outcome::result< std::shared_ptr< ipfs_lite::ipfs::merkledag::Leaf > > fetchGraphOnDepth(
const CID & cid,
uint64_t depth
) const override
function HasBlock¶
Parameters:
- cid Content identifier of the node
Return: true if the block is locally available or outcome::failure on error
Reimplements: sgns::crdt::DAGSyncer::HasBlock
Check if the block with cid is locally available (therefore, it is considered processed).
function GetNodeWithoutRequest¶
virtual outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > GetNodeWithoutRequest(
const CID & cid
) const override
Reimplements: sgns::crdt::DAGSyncer::GetNodeWithoutRequest
function GetNodeFromMerkleDAG¶
outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > GetNodeFromMerkleDAG(
const CID & cid
) const
function TraverseCIDsLinks¶
virtual std::pair< LinkInfoSet, LinkInfoSet > TraverseCIDsLinks(
ipfs_lite::ipld::IPLDNode & node,
std::string link_name ="",
LinkInfoSet visited ={}
) const override
Reimplements: sgns::crdt::DAGSyncer::TraverseCIDsLinks
function markResolved¶
Reimplements: sgns::crdt::DAGSyncer::markResolved
function isResolved¶
Reimplements: sgns::crdt::DAGSyncer::isResolved
function GetId¶
function GetPeerInfo¶
function AddToBlackList¶
function IsOnBlackList¶
function InitCIDBlock¶
Reimplements: sgns::crdt::DAGSyncer::InitCIDBlock
function IsCIDInCache¶
Reimplements: sgns::crdt::DAGSyncer::IsCIDInCache
function DeleteCIDBlock¶
Reimplements: sgns::crdt::DAGSyncer::DeleteCIDBlock
function Stop¶
Reimplements: sgns::crdt::DAGSyncer::Stop
function SetBlacklistBackoffTimeoutForTest¶
Test-only configuration seam for the blacklist backoff timeout (developer directive 2026-09-03).
Parameters:
- override_ms flat backoff timeout in MILLISECONDS; 0 restores production defaults (50002^failures capped at 30000 ms ever-connected, 100002^failures capped at 1800000 ms never-connected).
Note: The value is milliseconds so tests may configure a sub-second backoff and observe blacklist expiry within a test window. No production caller may invoke this method.
Updated on 2026-10-23 at 16:46:18 +0000