blocks

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockWithRoot

type BlockWithRoot struct {
	// Root of the Block.Message
	Root beacon.Root
	// Block, with signature
	Block *beacon.SignedBeaconBlock
}

func WithRoot

func WithRoot(spec *beacon.Spec, block *beacon.SignedBeaconBlock) *BlockWithRoot

type DB

type DB interface {
	// Store, only for trusted blocks, to persist a block in the DB.
	// The block is stored in serialized form, so the original instance may be mutated after storing it.
	// This is an efficient convenience method for using Import.
	// Returns exists=true if the block exists (previously), false otherwise. If error, it may not be accurate.
	// Returns slashable=true if exists=true, but the signatures are different. The existing block is kept.
	Store(ctx context.Context, block *BlockWithRoot) (exists bool, err error)
	// Import inserts a SignedBeaconBlock, read directly from the reader stream.
	// Returns exists=true if the block exists (previously), false otherwise. If error, it may not be accurate.
	// Returns slashable=true if exists=true, but the signatures are different. The existing block is kept.
	Import(r io.Reader) (exists bool, err error)
	// Get, an efficient convenience method for getting a block through Export. The block is safe to modify.
	// The data at the pointer is mutated to the new block.
	// Returns exists=true if the block exists, false otherwise. If error, it may not be accurate.
	Get(root beacon.Root, dest *beacon.SignedBeaconBlock) (exists bool, err error)
	// Size quickly checks the size of a block, without dealing with the full block.
	// Returns exists=true if the block exists, false otherwise. If error, it may not be accurate.
	Size(root beacon.Root) (size uint64, exists bool)
	// Export outputs the requested SignedBeaconBlock to the writer in SSZ.
	// Returns exists=true if the block exists, false otherwise. If error, it may not be accurate.
	Export(root beacon.Root, w io.Writer) (exists bool, err error)
	// Stream is used to stream the contents by getting a reader and total size to read
	Stream(root beacon.Root) (r io.ReadCloser, size uint64, exists bool, err error)
	// Remove removes a block from the DB. Removing a block that does not exist is safe.
	// Returns exists=true if the block exists (previously), false otherwise. If error, it may not be accurate.
	Remove(root beacon.Root) (exists bool, err error)
	// Stats shows some database statistics such as latest write key and entry count.
	Stats() DBStats
	// List all known block roots
	List() []beacon.Root
	// Get Path
	Path() string
	// Spec of states
	Spec() *beacon.Spec
}

type DBID added in v0.2.1

type DBID string

type DBMap added in v0.2.1

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

func (*DBMap) Create added in v0.2.1

func (dbm *DBMap) Create(id DBID, path string, spec *beacon.Spec) (db DB, err error)

func (*DBMap) Find added in v0.2.1

func (dbm *DBMap) Find(id DBID) (db DB, ok bool)

func (*DBMap) List added in v0.2.1

func (dbm *DBMap) List() (out []DBID)

func (*DBMap) Remove added in v0.2.1

func (dbm *DBMap) Remove(id DBID) (existed bool)

type DBStats

type DBStats struct {
	Count     int64
	LastWrite beacon.Root
}

type DBs added in v0.2.1

type DBs interface {
	Find(id DBID) (db DB, ok bool)
	// Create a new database. An empty path creates a memory DB.
	Create(id DBID, path string, spec *beacon.Spec) (db DB, err error)
	Remove(id DBID) (existed bool)
	List() []DBID
}

type FileDB added in v0.2.1

type FileDB struct {
	BasePath string
	// contains filtered or unexported fields
}

func (*FileDB) Export added in v0.2.1

func (db *FileDB) Export(root beacon.Root, w io.Writer) (exists bool, err error)

func (*FileDB) Get added in v0.2.1

func (db *FileDB) Get(root beacon.Root, dest *beacon.SignedBeaconBlock) (exists bool, err error)

func (*FileDB) Import added in v0.2.1

func (db *FileDB) Import(r io.Reader) (exists bool, err error)

func (*FileDB) List added in v0.2.1

func (db *FileDB) List() (out []beacon.Root)

func (*FileDB) Path added in v0.2.1

func (db *FileDB) Path() string

func (*FileDB) Remove added in v0.2.1

func (db *FileDB) Remove(root beacon.Root) (exists bool, err error)

func (*FileDB) Size added in v0.2.1

func (db *FileDB) Size(root beacon.Root) (size uint64, exists bool)

func (*FileDB) Spec added in v0.3.0

func (db *FileDB) Spec() *beacon.Spec

func (*FileDB) Stats added in v0.2.1

func (db *FileDB) Stats() DBStats

func (*FileDB) Store added in v0.2.1

func (db *FileDB) Store(ctx context.Context, block *BlockWithRoot) (exists bool, err error)

func (*FileDB) Stream added in v0.2.1

func (db *FileDB) Stream(root beacon.Root) (r io.ReadCloser, size uint64, exists bool, err error)

type MemDB

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

func (*MemDB) Export

func (db *MemDB) Export(root beacon.Root, w io.Writer) (exists bool, err error)

func (*MemDB) Get

func (db *MemDB) Get(root beacon.Root, dest *beacon.SignedBeaconBlock) (exists bool, err error)

func (*MemDB) Import

func (db *MemDB) Import(r io.Reader) (exists bool, err error)

func (*MemDB) List

func (db *MemDB) List() (out []beacon.Root)

func (*MemDB) Path added in v0.2.1

func (db *MemDB) Path() string

func (*MemDB) Remove

func (db *MemDB) Remove(root beacon.Root) (exists bool, err error)

func (*MemDB) Size

func (db *MemDB) Size(root beacon.Root) (size uint64, exists bool)

func (*MemDB) Spec added in v0.3.0

func (db *MemDB) Spec() *beacon.Spec

func (*MemDB) Stats

func (db *MemDB) Stats() DBStats

func (*MemDB) Store

func (db *MemDB) Store(ctx context.Context, block *BlockWithRoot) (exists bool, err error)

func (*MemDB) Stream

func (db *MemDB) Stream(root beacon.Root) (r io.ReadCloser, size uint64, exists bool, err error)

Jump to

Keyboard shortcuts

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