Documentation ¶
Index ¶
- Variables
- func ExternFetchCid(cid cid.Cid) ([]byte, error)
- func GenCid(ctx context.Context, src any, opts CidOpts) (cid.Cid, error)
- func NewDagNode(t pb.Data_DataType, cb cid.Builder, tag any) *dagNode
- func NewDataProvider(r io.Reader, splitSize int64) dataProvider
- type Chunk
- type CidOpts
- type Config
- type DagType
- type ExtendedNode
- type Node
- func (n *Node) BlockService() blockservice.BlockService
- func (n *Node) BlockStore() blockstore.Blockstore
- func (n *Node) Exchange() exchange.Interface
- func (n *Node) GetObject(ctx context.Context, c cid.Cid) (ReadSeekCloser, error)
- func (n *Node) HasBlock(ctx context.Context, c cid.Cid) (bool, error)
- func (n *Node) NumPeers() int
- func (n *Node) PutObject(ctx context.Context, src any, opts PutOpts) (ipld.Node, error)
- func (n *Node) Session(ctx context.Context) ipld.NodeGetter
- type NoopDAGService
- func (_ NoopDAGService) Add(context.Context, ipld.Node) error
- func (_ NoopDAGService) AddMany(context.Context, []ipld.Node) error
- func (_ NoopDAGService) Get(context.Context, cid.Cid) (ipld.Node, error)
- func (_ NoopDAGService) GetMany(context.Context, []cid.Cid) <-chan *ipld.NodeOption
- func (_ NoopDAGService) Remove(context.Context, cid.Cid) error
- func (_ NoopDAGService) RemoveMany(context.Context, []cid.Cid) error
- type PutOpts
- type ReadSeekCloser
- type VerifBS
Constants ¶
This section is empty.
Variables ¶
var ( // BlockSizeLimit specifies the maximum size an imported block can have. BlockSizeLimit = 1048576 // 1 MB )
var (
ErrDataSourceTypeNotSupported = errors.New("data source type not supported")
)
var (
ErrEmptyData = errors.New("empty data to build DAG")
)
var ( // ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit. ErrSizeLimitExceeded = errors.New("object size limit exceeded") )
Functions ¶
func ExternFetchCid ¶
ExternFetchCid fetches IPFS block data for the given CID from an external source. If the fetch is successful, that means data becomes visible by IPFS peers.
func NewDagNode ¶
func NewDagNode(t pb.Data_DataType, cb cid.Builder, tag any) *dagNode
NewDagNode creates a new empty dagNode.
func NewDataProvider ¶
NewDataProvider creates a default dataProvider that splits data from the provided io.Reader in splitSize.
Types ¶
type Chunk ¶
Chunk defines a chunk returned by dataProvider. The chunk is passed back to blockstore after DAG building. The tag can be any data which is treated by the DAG builder. User can use tag to track chunk data.
type CidOpts ¶
type CidOpts struct { // DataType sets which dag type to generate for the object. DagType DagType // ChunkSize sets the split size for each leave node, 0 for using default size. ChunkSize int64 // Number of linkes per block in DAG. LinksPerBlock int // RawLeaves sets if leaf nodes are generated as RawNode. RawLeaves bool // CidBuilder v0 or v1. Default to v1. CidBuilder cid.Builder }
CidOpts contains configurable parameters for generating CID.
type Config ¶
type Config struct { OfflineMode bool SecretKey crypto.PrivKey ListenAddrs []multiaddr.Multiaddr Bootstrappers []peer.AddrInfo MinConnections int MaxConnections int ConnectionGracePeriod time.Duration Datastore datastore.Batching Blockstore blockstore.Blockstore ReprovideInterval time.Duration CidBuilder cid.Builder ConnectionLogging bool }
type ExtendedNode ¶
ExtendedNode extends ipld.Node interface with extra file size and origin chunk data.
func NewExtendedNode ¶
func (*ExtendedNode) Base ¶
func (n *ExtendedNode) Base() ipld.Node
Base returns the base ipld.Node type.
func (*ExtendedNode) Chunk ¶
func (n *ExtendedNode) Chunk() *Chunk
Chunk returns the original chunk supplied by dataProvider. Nil for non-leaf node.
func (*ExtendedNode) FileSize ¶
func (n *ExtendedNode) FileSize() uint64
FileSize returns the file (or portion of it) size represented by the current node.
func (*ExtendedNode) PutOptsTag ¶
func (n *ExtendedNode) PutOptsTag() any
PutOptsTag returns the passed through tag from PutOpts.
func (*ExtendedNode) Root ¶
func (n *ExtendedNode) Root() bool
Root returns if the node is a DAG root.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a customized IPFS lite-node. The code was originally forked github.com/hsanjuan/ipfs-lite with substantial refactoring with relay support.
func New ¶
New creates a new Node instance. An empty Config which fallbacks to default settings should work.
func (*Node) BlockService ¶
func (n *Node) BlockService() blockservice.BlockService
BlockService returns the underlying blockservice implementation.
func (*Node) BlockStore ¶
func (n *Node) BlockStore() blockstore.Blockstore
BlockStore returns the blockstore.
func (*Node) GetObject ¶
func (n *Node) GetObject(ctx context.Context, c cid.Cid) (ReadSeekCloser, error)
GetObject returns a reader to a data blob as identified by the given root CID. The object must have been added as a UnixFS DAG (default for IPFS).
type NoopDAGService ¶
type NoopDAGService struct { }
func (NoopDAGService) GetMany ¶
func (_ NoopDAGService) GetMany( context.Context, []cid.Cid, ) <-chan *ipld.NodeOption
GetMany implements the DAGService interface.
func (NoopDAGService) Remove ¶
func (_ NoopDAGService) Remove(context.Context, cid.Cid) error
Remove implements the DAGService interface.
func (NoopDAGService) RemoveMany ¶
func (_ NoopDAGService) RemoveMany(context.Context, []cid.Cid) error
RemoveMany implements the DAGService interface.
type PutOpts ¶
type PutOpts struct { // DataType sets which dag type to generate for the object. DagType DagType // ChunkSize sets the split size for generating DAG leave nodes. ChunkSize int64 // Number of linkes per block in DAG. LinksPerBlock int // RawLeaves sets if leaf nodes are generated as RawNode. RawLeaves bool // Tag is custom data to be passed through all the way to blockstore. Tag any }
PutOpts contains configurable parameters for file DAG building.
type ReadSeekCloser ¶
A ReadSeekCloser implements interfaces to read, seek and close.
type VerifBS ¶
type VerifBS struct {
blockstore.Blockstore
}
Copied from github.com/ipfs/kubo/thirdparty/verifbs to avoid dependency on Kubo, which introduces version conflicts for libp2p-core