Skip to content

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 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::MerkleDagBridgeImpl MerkleDagBridgeImpl
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, PeerKey > RouteMapType

Public Functions

Name
GraphsyncDAGSyncer(std::shared_ptr< IpfsDatastore > service, 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< 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

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 sgns::crdt::GraphsyncDAGSyncer::IpfsDatastore = ipfs_lite::ipfs::IpfsDatastore;

using Graphsync

using sgns::crdt::GraphsyncDAGSyncer::Graphsync = ipfs_lite::ipfs::graphsync::Graphsync;

using ResponseMetadata

using sgns::crdt::GraphsyncDAGSyncer::ResponseMetadata = ipfs_lite::ipfs::graphsync::ResponseMetadata;

using Extension

using sgns::crdt::GraphsyncDAGSyncer::Extension = ipfs_lite::ipfs::graphsync::Extension;

using MerkleDagBridgeImpl

using sgns::crdt::GraphsyncDAGSyncer::MerkleDagBridgeImpl = ipfs_lite::ipfs::graphsync::MerkleDagBridgeImpl;

using ResponseStatusCode

using sgns::crdt::GraphsyncDAGSyncer::ResponseStatusCode = ipfs_lite::ipfs::graphsync::ResponseStatusCode;

using Multiaddress

using sgns::crdt::GraphsyncDAGSyncer::Multiaddress = libp2p::multi::Multiaddress;

using Multihash

using sgns::crdt::GraphsyncDAGSyncer::Multihash = libp2p::multi::Multihash;

using PeerId

using sgns::crdt::GraphsyncDAGSyncer::PeerId = libp2p::peer::PeerId;

using Subscription

using sgns::crdt::GraphsyncDAGSyncer::Subscription = libp2p::protocol::Subscription;

using Logger

using sgns::crdt::GraphsyncDAGSyncer::Logger = base::Logger;

using BlockCallback

using sgns::crdt::GraphsyncDAGSyncer::BlockCallback = Graphsync::BlockCallback;

using PeerKey

using sgns::crdt::GraphsyncDAGSyncer::PeerKey = size_t;

using PeerEntry

using sgns::crdt::GraphsyncDAGSyncer::PeerEntry = std::pair<PeerId, std::vector<Multiaddress>>;

using RouteMapType

using sgns::crdt::GraphsyncDAGSyncer::RouteMapType = std::map<CID, PeerKey>;

Public Functions Documentation

function GraphsyncDAGSyncer

GraphsyncDAGSyncer(
    std::shared_ptr< IpfsDatastore > service,
    std::shared_ptr< Graphsync > graphsync,
    std::shared_ptr< libp2p::Host > host
)

function ~GraphsyncDAGSyncer

inline ~GraphsyncDAGSyncer() override

function Listen

outcome::result< void > Listen(
    const Multiaddress & listen_to
)

function StartSync

outcome::result< void > StartSync()

Starts instance and subscribes to blocks

function AddRoute

void AddRoute(
    const CID & cid,
    const PeerId & peer,
    std::vector< Multiaddress > address
)

function addNode

outcome::result< void > addNode(
    std::shared_ptr< const ipfs_lite::ipld::IPLDNode > node
) override

function getNode

outcome::result< std::shared_ptr< ipfs_lite::ipld::IPLDNode > > getNode(
    const CID & cid
) const override

function removeNode

outcome::result< void > removeNode(
    const CID & cid
) override

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

virtual outcome::result< bool > HasBlock(
    const CID & cid
) const override

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
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

virtual outcome::result< void > markResolved(
    const CID & cid
) override

Reimplements: sgns::crdt::DAGSyncer::markResolved

function isResolved

virtual outcome::result< bool > isResolved(
    const CID & cid
) const override

Reimplements: sgns::crdt::DAGSyncer::isResolved

function GetId

outcome::result< PeerId > GetId() const

function GetPeerInfo

outcome::result< libp2p::peer::PeerInfo > GetPeerInfo() const

function AddToBlackList

void AddToBlackList(
    const PeerId & peer
) const

function IsOnBlackList

bool IsOnBlackList(
    const PeerId & peer
) const

function InitCIDBlock

virtual void InitCIDBlock(
    const CID & cid
) override

Reimplements: sgns::crdt::DAGSyncer::InitCIDBlock

function IsCIDInCache

virtual bool IsCIDInCache(
    const CID & cid
) const override

Reimplements: sgns::crdt::DAGSyncer::IsCIDInCache

function DeleteCIDBlock

virtual outcome::result< void > DeleteCIDBlock(
    const CID & cid
) override

Reimplements: sgns::crdt::DAGSyncer::DeleteCIDBlock

function Stop

virtual void Stop() override

Reimplements: sgns::crdt::DAGSyncer::Stop


Updated on 2026-03-04 at 13:10:43 -0800