Categorygithub.com/ipfs/go-dagwriter
modulepackage
1.0.0
Repository: https://github.com/ipfs/go-dagwriter.git
Documentation: pkg.go.dev

# README

go-dagwriter

DagWriter is the glue for mutating (adding, removing) ipld nodes in a block service.

Usage

import (
    "context"

    "github.com/ipfs/go-dagwriter"
    "github.com/ipld/go-ipld-prime"
    cidlink "github.com/ipld/go-ipld-prime/linking/cid"
    "github.com/ipfs/go-cid"
)

...
linkPrototype := cidlink.LinkPrototype{cid.Prefix{
    Version: 1, Codec: 0x71, MhType: 0x17, MhLength: 20,
}}

writer := dagwriter.NewDagWriter(blockService)

// Store ipldNode in the block service
link, err := writer.Store(ipld.LinkContext{}, linkPrototype, ipldNode)
if err != nil {
    panic(err)
}
...

// Remove the node from the block service.
if err := writer.Delete(context.Background(), link); err != nil {
    panic(err)
}

Contribute

PRs are welcome!

License

The go-dagwriter project is dual-licensed under Apache 2.0 and MIT terms:

# Packages

No description provided by the author

# Interfaces

DagBatchWriter is a DagWriter that allows queing up several write and delete commands to an underlying store, then executing them in a single commit.
DagWriter provides access for writing and deleting ipld.Nodes in an underlying store Note: on its own, the dag writer provides no methods for loading/reading nodes.
DagWritingService provides both methods for writing and deleting ipld.Nodes atomically, and for instantiating batch operations.