kubo/merkledag/readonly.go
Jeromy a703e2d1f2 comments
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2018-02-03 14:45:11 -08:00

21 lines
557 B
Go

package merkledag
import (
"fmt"
ipld "gx/ipfs/Qme5bWv7wtjUNGsK2BNGVUFPKiuxWrsqrtvYwCLRw8YFES/go-ipld-format"
)
// ErrReadOnly is used when a read-only datastructure is written to.
var ErrReadOnly = fmt.Errorf("cannot write to readonly DAGService")
// NewReadOnlyDagService takes a NodeGetter, and returns a full DAGService
// implementation that returns ErrReadOnly when its 'write' methods are
// invoked.
func NewReadOnlyDagService(ng ipld.NodeGetter) ipld.DAGService {
return &ComboService{
Read: ng,
Write: &ErrorService{ErrReadOnly},
}
}