private

package
v0.0.0-...-01c881c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2021 License: GPL-3.0 Imports: 41 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyKey = Key([32]byte{})

Functions

func CopyBlocks

func CopyBlocks(ctx context.Context, id cid.Cid, src, dst Store) (err error)

Copy blocks from src to dst

func LoadNode

func LoadNode(ctx context.Context, store Store, name string, id cid.Cid, key Key) (privateNode, error)

func Merge

func Merge(ctx context.Context, aNode, bNode base.Node) (result base.MergeResult, err error)

func MergeHAMTBlocks

func MergeHAMTBlocks(ctx context.Context, src, dst Store) error

Types

type BareNamefilter

type BareNamefilter string

a name filter with just inumbers in it

func AddToBare

func AddToBare(bareFilter BareNamefilter, toAdd []byte) (BareNamefilter, error)

add some string to a name filter

func CreateBare

func CreateBare(key Key) (BareNamefilter, error)

create bare name filter with a single key

func IdentityBareNamefilter

func IdentityBareNamefilter() BareNamefilter

root key should be the identity bare name filter

func NewBareNamefilter

func NewBareNamefilter(parent BareNamefilter, in INumber) (bnf BareNamefilter, err error)

parent is the "super" constructor arg

type CborByteArray

type CborByteArray []byte

A CBOR-marshalable byte array.

func (*CborByteArray) MarshalCBOR

func (c *CborByteArray) MarshalCBOR(w io.Writer) error

func (*CborByteArray) UnmarshalCBOR

func (c *CborByteArray) UnmarshalCBOR(r io.Reader) error

type DecryptionStore

type DecryptionStore interface {
	DecryptionFields(id cid.Cid) (sname Name, key Key, err error)
}

type File

type File struct {
	// contains filtered or unexported fields
}

func LoadFile

func LoadFile(ctx context.Context, store Store, name string, key Key, id cid.Cid) (*File, error)

func NewFile

func NewFile(store Store, parent BareNamefilter, content fs.File) (*File, error)

func NewFileMetadata

func NewFileMetadata(store Store, parent BareNamefilter, f fs.File, meta interface{}) (*File, error)

func (*File) AsHistoryEntry

func (pf *File) AsHistoryEntry() base.HistoryEntry

func (*File) BareNamefilter

func (pf *File) BareNamefilter() BareNamefilter

func (*File) Cid

func (pf *File) Cid() cid.Cid

func (*File) Close

func (pf *File) Close() error

func (*File) Content

func (pf *File) Content() cid.Cid

func (*File) History

func (pf *File) History(ctx context.Context, maxRevs int) ([]base.HistoryEntry, error)

func (*File) INumber

func (pf *File) INumber() INumber

func (*File) IsDir

func (pf *File) IsDir() bool

func (*File) Key

func (pf *File) Key() Key

func (*File) Metadata

func (pf *File) Metadata() (f base.LDFile, err error)

func (*File) ModTime

func (pf *File) ModTime() time.Time

func (*File) Mode

func (pf *File) Mode() fs.FileMode

func (*File) Name

func (pf *File) Name() string

func (*File) PrivateFS

func (pf *File) PrivateFS() Store

func (*File) PrivateName

func (pf *File) PrivateName() (Name, error)

func (*File) Put

func (pf *File) Put() (PutResult, error)

func (*File) Ratchet

func (pf *File) Ratchet() *ratchet.Spiral

func (*File) Read

func (pf *File) Read(p []byte) (n int, err error)

func (*File) SetContents

func (pf *File) SetContents(f fs.File)

func (*File) SetMetadata

func (pf *File) SetMetadata(md interface{}) (err error)

func (*File) Size

func (pf *File) Size() int64

func (*File) Stat

func (pf *File) Stat() (fs.FileInfo, error)

func (*File) Sys

func (pf *File) Sys() interface{}

func (*File) Type

func (pf *File) Type() base.NodeType

func (*File) Update

func (pf *File) Update(change fs.File) (result PutResult, err error)

type HAMT

type HAMT struct {
	// contains filtered or unexported fields
}

func LoadHAMT

func LoadHAMT(ctx context.Context, bstore blockstore.Blockstore, id cid.Cid) (*HAMT, error)

func NewEmptyHamt

func NewEmptyHamt(bstore blockstore.Blockstore) (*HAMT, error)

func (*HAMT) CID

func (h *HAMT) CID() cid.Cid

func (*HAMT) Diagnostic

func (h *HAMT) Diagnostic(ctx context.Context) map[string]string

func (*HAMT) Merge

func (h *HAMT) Merge(ctx context.Context, b *hamt.Node) error

func (*HAMT) Root

func (h *HAMT) Root() *hamt.Node

func (*HAMT) Write

func (h *HAMT) Write(ctx context.Context) error
type Header struct {
	Info      HeaderInfo
	Metadata  cid.Cid
	ContentID cid.Cid
	Value     interface{} // only present on LDFile nodes
}

type HeaderInfo

type HeaderInfo struct {
	WNFS  base.SemVer
	Type  base.NodeType
	Mode  uint32
	Ctime int64
	Mtime int64
	Size  int64

	INumber        INumber
	BareNamefilter BareNamefilter
	Ratchet        string
}

func HeaderInfoFromCBOR

func HeaderInfoFromCBOR(d []byte) (HeaderInfo, error)

func NewHeaderInfo

func NewHeaderInfo(nt base.NodeType, in INumber, bnf BareNamefilter) HeaderInfo

func (HeaderInfo) CBOR

func (hi HeaderInfo) CBOR() (*bytes.Buffer, error)

func (HeaderInfo) Copy

func (hi HeaderInfo) Copy() HeaderInfo

type INumber

type INumber [32]byte

func NewINumber

func NewINumber() INumber

func (INumber) Encode

func (n INumber) Encode() string

type Info

type Info interface {
	base.FileInfo
	Ratchet() *ratchet.Spiral
	PrivateName() (Name, error)
}

func Stat

func Stat(f fs.File) (Info, error)

type Key

type Key [32]byte

func NewKey

func NewKey() Key

func (*Key) Decode

func (k *Key) Decode(s string) error

func (Key) Encode

func (k Key) Encode() string

func (Key) IsEmpty

func (k Key) IsEmpty() bool

func (Key) MarshalJSON

func (k Key) MarshalJSON() ([]byte, error)

func (*Key) UnmarshalJSON

func (k *Key) UnmarshalJSON(d []byte) error

type KeyedNameFilter

type KeyedNameFilter string

a name filter with inumbers and a key, which serves as the revision identifier

func AddKey

func AddKey(bareFilter BareNamefilter, key Key) (knf KeyedNameFilter, err error)

add the revision number to the name filter, salted with the AES key for the node

type LDFile

type LDFile struct {
	// contains filtered or unexported fields
}

func LoadLDFile

func LoadLDFile(ctx context.Context, fs Store, name string, id cid.Cid, key Key) (*LDFile, error)

func NewLDFile

func NewLDFile(store Store, name string, content interface{}, parent BareNamefilter) (*LDFile, error)

func (*LDFile) AsHistoryEntry

func (df *LDFile) AsHistoryEntry() base.HistoryEntry

func (*LDFile) BareNamefilter

func (df *LDFile) BareNamefilter() BareNamefilter

func (*LDFile) Cid

func (df *LDFile) Cid() cid.Cid

func (*LDFile) Close

func (df *LDFile) Close() error

func (*LDFile) Data

func (df *LDFile) Data() (interface{}, error)

func (*LDFile) History

func (df *LDFile) History(ctx context.Context, maxRevs int) ([]base.HistoryEntry, error)

func (*LDFile) INumber

func (df *LDFile) INumber() INumber

func (*LDFile) IsBare

func (df *LDFile) IsBare() bool

func (*LDFile) IsDir

func (df *LDFile) IsDir() bool
func (df *LDFile) Links() base.Links

func (*LDFile) Metadata

func (df *LDFile) Metadata() (base.LDFile, error)

func (*LDFile) ModTime

func (df *LDFile) ModTime() time.Time

func (*LDFile) Mode

func (df *LDFile) Mode() fs.FileMode

func (*LDFile) Name

func (df *LDFile) Name() string

func (*LDFile) PrivateName

func (df *LDFile) PrivateName() (Name, error)

func (*LDFile) Put

func (df *LDFile) Put() (result PutResult, err error)

func (*LDFile) Ratchet

func (df *LDFile) Ratchet() *ratchet.Spiral

func (*LDFile) Read

func (df *LDFile) Read(p []byte) (n int, err error)

func (*LDFile) ReadDir

func (df *LDFile) ReadDir(n int) ([]fs.DirEntry, error)

func (*LDFile) SetContents

func (df *LDFile) SetContents(data interface{})

func (*LDFile) Size

func (df *LDFile) Size() int64

func (*LDFile) Stat

func (df *LDFile) Stat() (fs.FileInfo, error)

func (*LDFile) Sys

func (df *LDFile) Sys() interface{}

func (*LDFile) Type

func (df *LDFile) Type() base.NodeType

func (*LDFile) Update

func (df *LDFile) Update(change fs.File) (result PutResult, err error)

type Name

type Name string

a hashed name filter exported as "private.Name", private.Name is in fact a private value, and needs to be kept secret

func ToName

func ToName(knf KeyedNameFilter) (Name, error)

saturate the filter to 320 bits and hash it with sha256 to give the private name that a node will be stored in the MMPT with

type PrivateLink struct {
	base.Link
	Key     Key
	Pointer Name
}
type PrivateLinks map[string]PrivateLink

func (PrivateLinks) Add

func (pls PrivateLinks) Add(link PrivateLink)

func (PrivateLinks) Get

func (pls PrivateLinks) Get(name string) *PrivateLink

func (PrivateLinks) Remove

func (pls PrivateLinks) Remove(name string) bool

func (PrivateLinks) SizeSum

func (pls PrivateLinks) SizeSum() (total int64)

func (PrivateLinks) SortedSlice

func (pls PrivateLinks) SortedSlice() []PrivateLink

type PutResult

type PutResult struct {
	public.PutResult
	Key     Key
	Pointer Name
}
func (r PutResult) ToPrivateLink(name string) PrivateLink

type Root

type Root struct {
	*Tree
	// contains filtered or unexported fields
}

func LoadRoot

func LoadRoot(ctx context.Context, store Store, name string, rootKey Key, rootName Name) (*Root, error)

func NewEmptyRoot

func NewEmptyRoot(ctx context.Context, store Store, name string, rootKey Key) (*Root, error)

func (*Root) Add

func (r *Root) Add(path base.Path, f fs.File) (res base.PutResult, err error)

func (*Root) Cid

func (r *Root) Cid() cid.Cid

func (*Root) Context

func (r *Root) Context() context.Context

func (*Root) Copy

func (r *Root) Copy(path base.Path, srcPathStr string, srcFS fs.FS) (res base.PutResult, err error)

func (*Root) HAMTCid

func (r *Root) HAMTCid() *cid.Cid

func (*Root) Mkdir

func (r *Root) Mkdir(path base.Path) (res base.PutResult, err error)

func (*Root) Open

func (r *Root) Open(pathStr string) (fs.File, error)

func (*Root) Put

func (r *Root) Put() (base.PutResult, error)

func (*Root) Rm

func (r *Root) Rm(path base.Path) (base.PutResult, error)

type Store

type Store interface {
	Context() context.Context
	PutEncryptedFile(f fs.File, key []byte) (PutResult, error)
	GetEncryptedFile(root cid.Cid, key []byte) (io.ReadCloser, error)

	HAMT() *HAMT
	DAGService() ipld.DAGService
	Blockservice() blockservice.BlockService
	RatchetStore() ratchet.Store
}

func LoadStore

func LoadStore(ctx context.Context, bserv blockservice.BlockService, rs ratchet.Store, hamtCid cid.Cid) (s Store, err error)

func NewStore

func NewStore(ctx context.Context, bserv blockservice.BlockService, rs ratchet.Store) (Store, error)

func NodeStore

func NodeStore(n base.Node) (Store, error)

NodeStore extracts a private store from a wnfs.Node

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func LoadTree

func LoadTree(store Store, name string, key Key, id cid.Cid) (*Tree, error)

func LoadTreeFromName

func LoadTreeFromName(ctx context.Context, fs Store, key Key, name string, pn Name) (*Tree, error)

func NewEmptyTree

func NewEmptyTree(store Store, parent BareNamefilter, name string) (*Tree, error)

func (*Tree) Add

func (pt *Tree) Add(path base.Path, f fs.File) (res base.PutResult, err error)

func (*Tree) AsHistoryEntry

func (pt *Tree) AsHistoryEntry() base.HistoryEntry

func (*Tree) BareNamefilter

func (pt *Tree) BareNamefilter() BareNamefilter

func (*Tree) Cid

func (pt *Tree) Cid() cid.Cid

func (*Tree) Close

func (pt *Tree) Close() error

func (*Tree) Copy

func (pt *Tree) Copy(path base.Path, srcPathStr string, srcFS fs.FS) (res base.PutResult, err error)

func (*Tree) Get

func (pt *Tree) Get(path base.Path) (fs.File, error)

func (*Tree) History

func (pt *Tree) History(ctx context.Context, maxRevs int) ([]base.HistoryEntry, error)

func (*Tree) INumber

func (pt *Tree) INumber() INumber

func (*Tree) IsDir

func (pt *Tree) IsDir() bool

func (*Tree) Key

func (pt *Tree) Key() Key

func (*Tree) Metadata

func (pt *Tree) Metadata() (f base.LDFile, err error)

func (*Tree) Mkdir

func (pt *Tree) Mkdir(path base.Path) (res base.PutResult, err error)

func (*Tree) ModTime

func (pt *Tree) ModTime() time.Time

func (*Tree) Mode

func (pt *Tree) Mode() fs.FileMode

func (*Tree) Name

func (pt *Tree) Name() string

func (*Tree) PrivateFS

func (pt *Tree) PrivateFS() Store

func (*Tree) PrivateName

func (pt *Tree) PrivateName() (Name, error)

func (*Tree) Put

func (pt *Tree) Put() (base.PutResult, error)

func (*Tree) Ratchet

func (pt *Tree) Ratchet() *ratchet.Spiral

func (*Tree) Read

func (pt *Tree) Read(p []byte) (n int, err error)

func (*Tree) ReadDir

func (pt *Tree) ReadDir(n int) ([]fs.DirEntry, error)

func (*Tree) Rm

func (pt *Tree) Rm(path base.Path) (base.PutResult, error)

func (*Tree) SetMetadata

func (pt *Tree) SetMetadata(md interface{}) (err error)

func (*Tree) Size

func (pt *Tree) Size() int64

func (*Tree) Stat

func (pt *Tree) Stat() (fs.FileInfo, error)

func (*Tree) Sys

func (pt *Tree) Sys() interface{}

func (*Tree) Type

func (pt *Tree) Type() base.NodeType

func (*Tree) Update

func (pt *Tree) Update(file fs.File) (PutResult, error)

type WritableDecryptionStore

type WritableDecryptionStore interface {
	DecryptionStore
	PutDecryptionFields(id cid.Cid, sname Name, key Key) error
}

func NewDecryptionStore

func NewDecryptionStore(filepath string) (WritableDecryptionStore, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL