Documentation
¶
Overview ¶
Package replica owns the backup-side wiring: open a ZapDB read-only, take a snapshot, stream the badger Backup bytes through hanzoai/vfs (4 KiB content-addressed age-encrypted blocks), and publish a manifest naming the produced block list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChunkReader ¶
type ChunkReader struct {
// contains filtered or unexported fields
}
ChunkReader reads back a stream the ChunkWriter produced. It fetches each BlockID via vfs.GetBlock in order. Plaintext blocks are returned padded to vfs.BlockSize; the reader truncates the final block to (plainSize - (n-1)*BlockSize) when plainSize is not a multiple of BlockSize.
func NewChunkReader ¶
func NewChunkReader(ctx context.Context, v *vfs.VFS, blocks []vfs.BlockID, plainSize int64) *ChunkReader
NewChunkReader builds a reader. plainSize MUST match the manifest.
type ChunkWriter ¶
type ChunkWriter struct {
// contains filtered or unexported fields
}
ChunkWriter buffers an io.Writer stream into vfs.BlockSize pages and pushes each full page through vfs.PutBlock. The last page (Close) flushes whatever bytes remain — vfs.Pad zero-pads short tails to BlockSize before encryption.
Concurrency: not safe for concurrent use. Caller serialises Write/Close.
func NewChunkWriter ¶
func NewChunkWriter(ctx context.Context, v *vfs.VFS) *ChunkWriter
NewChunkWriter constructs a ChunkWriter against the given VFS. The caller is responsible for Close() — it flushes any partial tail block.
func (*ChunkWriter) Blocks ¶
func (c *ChunkWriter) Blocks() []vfs.BlockID
Blocks returns the ordered BlockIDs produced by this writer. Only valid after Close.
func (*ChunkWriter) Close ¶
func (c *ChunkWriter) Close() error
Close flushes any partial tail block. Safe to call multiple times. After Close, Blocks and PlainSize are stable.
func (*ChunkWriter) PlainSize ¶
func (c *ChunkWriter) PlainSize() int64
PlainSize returns the number of plaintext bytes the writer consumed. Used by the manifest so Restore can truncate the final block.
type Config ¶
type Config struct {
DBPath string
Network string // e.g. "mainnet"
VFS *vfs.VFS // backend + crypto
Backend backend.Backend
StatePath string // override state file path; empty -> derived
Interval time.Duration // between cycles, default 60s
FullSnapshotEvery time.Duration // re-snapshot full at this cadence
AgeSchemeLabel string // recorded in manifests for audit
}
Config wires a single replica.
type Replica ¶
type Replica struct {
// contains filtered or unexported fields
}
Replica is a single (database, backend) pair that the daemon ticks against. Each tick: snapshot ZapDB, stream through vfs, publish a manifest, advance HEAD, persist watermark.