archive

package
v2.1.63+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultArchiveAge is the default distance from head at which data is archived.
	DefaultArchiveAge uint64 = 100000
	// DefaultArchivePeriod is how often the archive process runs.
	DefaultArchivePeriod = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

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

Archive manages an archive of data in an S3 compatible bucket.

func NewArchive

func NewArchive(config Config) (*Archive, error)

NewArchive returns a new Archive backed by an S3 compatible bucket. The bucket must already exist.

func (*Archive) Delete

func (a *Archive) Delete(key string) error

func (*Archive) Get

func (a *Archive) Get(key string) ([]byte, error)

func (*Archive) Has

func (a *Archive) Has(key string) (bool, error)

func (*Archive) Meter

func (a *Archive) Meter(prefix string)

func (*Archive) Put

func (a *Archive) Put(key string, value []byte) (int64, error)

type Config

type Config struct {
	Endpoint   string        `toml:",omitempty"` // S3 compatible endpoint.
	Bucket     string        `toml:",omitempty"` // Bucket name. Must already exist.
	ID, Secret string        `toml:",omitempty"` // Credentials.
	Age        uint64        `toml:",omitempty"` // Optional. Distance from head before archiving.
	Period     time.Duration `toml:",omitempty"` // Optional. How often to run the archive process.
}

type DB

type DB struct {
	*ethdb.LDBDatabase
	// contains filtered or unexported fields
}

DB extends an LDBDatabase with support for archiving entries to a Archive.

func NewDB

func NewDB(db *ethdb.LDBDatabase, archive *Archive) *DB

NewDB returns a new DB, backed by a Archive. Start() must be called to begin the background archival process.

func (*DB) Close

func (db *DB) Close()

func (*DB) Delete

func (db *DB) Delete(key []byte) error

func (*DB) Get

func (db *DB) Get(key []byte) ([]byte, error)

func (*DB) Has

func (db *DB) Has(key []byte) (bool, error)

func (*DB) Start

func (db *DB) Start(limitFn func(byte) uint64)

Start launches the background goroutine to periodically sweeps for data to archive. It must only be called once.

Jump to

Keyboard shortcuts

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