repo

package
v0.0.0-...-efe2ce5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0, MIT Imports: 20 Imported by: 24

Documentation

Index

Constants

View Source
const ATP_REPO_VERSION int64 = 3

current version of repo currently implemented

View Source
const ATP_REPO_VERSION_2 int64 = 2

Variables

View Source
var ErrDoneIterating = fmt.Errorf("done iterating")

Functions

func IngestRepo

func IngestRepo(ctx context.Context, bs blockstore.Blockstore, r io.Reader) (cid.Cid, error)

func NextTID

func NextTID() string

Types

type CborMarshaler

type CborMarshaler interface {
	MarshalCBOR(w io.Writer) error
}

type Repo

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

func NewRepo

func NewRepo(ctx context.Context, did string, bs blockstore.Blockstore) *Repo

func OpenRepo

func OpenRepo(ctx context.Context, bs blockstore.Blockstore, root cid.Cid) (*Repo, error)

func ReadRepoFromCar

func ReadRepoFromCar(ctx context.Context, r io.Reader) (*Repo, error)

func (*Repo) Blockstore

func (r *Repo) Blockstore() blockstore.Blockstore

func (*Repo) Commit

func (r *Repo) Commit(ctx context.Context, signer func(context.Context, string, []byte) ([]byte, error)) (cid.Cid, string, error)

creates and writes a new SignedCommit for this repo, with `prev` pointing to old value

func (*Repo) CopyDataTo

func (r *Repo) CopyDataTo(ctx context.Context, bs blockstore.Blockstore) error

func (*Repo) CreateRecord

func (r *Repo) CreateRecord(ctx context.Context, nsid string, rec CborMarshaler) (cid.Cid, string, error)

func (*Repo) DataCid

func (r *Repo) DataCid() cid.Cid

func (*Repo) DeleteRecord

func (r *Repo) DeleteRecord(ctx context.Context, rpath string) error

func (*Repo) DiffSince

func (r *Repo) DiffSince(ctx context.Context, oldrepo cid.Cid) ([]*mst.DiffOp, error)

func (*Repo) ForEach

func (r *Repo) ForEach(ctx context.Context, prefix string, cb func(k string, v cid.Cid) error) error

func (*Repo) GetRecord

func (r *Repo) GetRecord(ctx context.Context, rpath string) (cid.Cid, cbg.CBORMarshaler, error)

func (*Repo) GetRecordBytes

func (r *Repo) GetRecordBytes(ctx context.Context, rpath string) (cid.Cid, *[]byte, error)

func (*Repo) PrevCommit

func (r *Repo) PrevCommit(ctx context.Context) (*cid.Cid, error)

TODO(bnewbold): this could return just *cid.Cid

func (*Repo) PutRecord

func (r *Repo) PutRecord(ctx context.Context, rpath string, rec CborMarshaler) (cid.Cid, error)

func (*Repo) RepoDid

func (r *Repo) RepoDid() string

func (*Repo) SignedCommit

func (r *Repo) SignedCommit() SignedCommit

func (*Repo) Truncate

func (r *Repo) Truncate()

truncates history while retaining the same data root

func (*Repo) UpdateRecord

func (r *Repo) UpdateRecord(ctx context.Context, rpath string, rec CborMarshaler) (cid.Cid, error)

type SignedCommit

type SignedCommit struct {
	Did     string   `json:"did" cborgen:"did"`
	Version int64    `json:"version" cborgen:"version"`
	Prev    *cid.Cid `json:"prev" cborgen:"prev"`
	Data    cid.Cid  `json:"data" cborgen:"data"`
	Sig     []byte   `json:"sig" cborgen:"sig"`
	Rev     string   `json:"rev" cborgen:"rev,omitempty"`
}

func (*SignedCommit) MarshalCBOR

func (t *SignedCommit) MarshalCBOR(w io.Writer) error

func (*SignedCommit) UnmarshalCBOR

func (t *SignedCommit) UnmarshalCBOR(r io.Reader) (err error)

func (*SignedCommit) Unsigned

func (sc *SignedCommit) Unsigned() *UnsignedCommit

Returns a copy of commit without the Sig field. Helpful when verifying signature.

type UnsignedCommit

type UnsignedCommit struct {
	Did     string   `cborgen:"did"`
	Version int64    `cborgen:"version"`
	Prev    *cid.Cid `cborgen:"prev"`
	Data    cid.Cid  `cborgen:"data"`
	Rev     string   `cborgen:"rev,omitempty"`
}

func (*UnsignedCommit) BytesForSigning

func (uc *UnsignedCommit) BytesForSigning() ([]byte, error)

returns bytes of the DAG-CBOR representation of object. This is what gets signed; the `go-did` library will take the SHA-256 of the bytes and sign that.

func (*UnsignedCommit) MarshalCBOR

func (t *UnsignedCommit) MarshalCBOR(w io.Writer) error

func (*UnsignedCommit) UnmarshalCBOR

func (t *UnsignedCommit) UnmarshalCBOR(r io.Reader) (err error)

Jump to

Keyboard shortcuts

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