repo

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 1

Documentation

Overview

Package repo implements AT Protocol repository operations.

A repository is a collection of records organized in a Merkle Search Tree, wrapped in signed commits, and stored as CAR files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadBlocksFromCAR

func LoadBlocksFromCAR(r io.Reader) (*mst.MemBlockStore, cbor.CID, error)

LoadBlocksFromCAR reads a CAR file and returns all blocks in a MemBlockStore along with the root CID.

func LoadFromCAR

func LoadFromCAR(r io.Reader) (*Repo, *Commit, error)

LoadFromCAR loads a repository from a CAR v1 stream. Returns the Repo and the decoded Commit.

Types

type Commit

type Commit struct {
	DID     string    // "did"
	Version int64     // "version"
	Prev    *cbor.CID // "prev" — always serialized, even as null
	Data    cbor.CID  // "data" — MST root CID
	Rev     string    // "rev" — TID revision
	Sig     []byte    // "sig" — signature bytes
}

Commit is a signed ATProto repository commit.

func (*Commit) Sign

func (c *Commit) Sign(key crypto.PrivateKey) error

Sign signs the commit with the given private key.

func (*Commit) UnsignedBytes

func (c *Commit) UnsignedBytes() ([]byte, error)

UnsignedBytes returns the DAG-CBOR encoding of the commit without the sig field.

func (*Commit) VerifySignature

func (c *Commit) VerifySignature(key crypto.PublicKey) error

VerifySignature verifies the commit signature against the given public key.

type Repo

type Repo struct {
	DID   atmos.DID
	Clock *atmos.TIDClock
	Store mst.BlockStore
	Tree  *mst.Tree
}

Repo is an in-memory ATProto repository.

func (*Repo) Commit

func (r *Repo) Commit(key crypto.PrivateKey) (*Commit, error)

Commit creates a signed commit for the current state.

func (*Repo) Create

func (r *Repo) Create(collection, rkey string, record any) error

Create creates a new record.

func (*Repo) Delete

func (r *Repo) Delete(collection, rkey string) error

Delete deletes a record.

func (*Repo) ExportCAR

func (r *Repo) ExportCAR(w io.Writer, key crypto.PrivateKey) error

ExportCAR exports the repository as a CAR v1 file. Creates a new signed commit using the given private key.

func (*Repo) Get

func (r *Repo) Get(collection, rkey string) (cbor.CID, []byte, error)

Get retrieves a record by collection and rkey. Returns the record CID, raw CBOR bytes, and any error.

func (*Repo) Update

func (r *Repo) Update(collection, rkey string, record any) error

Update updates an existing record.

Jump to

Keyboard shortcuts

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