localfs

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package localfs provides block data from local filesystem.

Index

Constants

This section is empty.

Variables

View Source
var (
	LocalFSBlockdataType = hint.Type("localfs-blockdata")
	LocalFSBlockdataHint = hint.NewHint(LocalFSBlockdataType, "v0.0.1")
)
View Source
var (
	BlockDirectoryHeightFormat     = "%021s"
	BlockDirectoryRemovedTouchFile = ".removed"
	BlockFileFormats               = "%d-%s-%s.jsonld.gz" // <height>-<data>-<checksum>.jsonld.gz
	BlockFileGlobFormats           = "*-%s-*.jsonld.gz"   // -<data>-*.jsonld.gz
)
View Source
var (
	DefaultFilePermission      os.FileMode = 0o644
	DefaultDirectoryPermission os.FileMode = 0o755
)

Functions

func HeightDirectory

func HeightDirectory(height base.Height) string

func LoadBlock

func LoadBlock(st *Blockdata, height base.Height) (block.BaseBlockdataMap, block.Block, error)

func LoadBlockByPath

func LoadBlockByPath(st *Blockdata, prepath string) (block.BaseBlockdataMap, block.Block, error)

func LoadData

func LoadData(prepath, dataType string) (block.BaseBlockdataMapItem, io.ReadCloser, error)

func NewBaseBlockdataMapItem

func NewBaseBlockdataMapItem(f string) (block.BaseBlockdataMapItem, error)

func OpenFile

func OpenFile(prepath, dataType string) (string, io.ReadCloser, error)

func ParseDataFileName

func ParseDataFileName(s string) (base.Height, string, string, error)

Types

type Blockdata

type Blockdata struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewBlockdata

func NewBlockdata(root string, encoder *jsonenc.Encoder) *Blockdata

func (*Blockdata) Clean

func (st *Blockdata) Clean(remove bool) error

func (*Blockdata) Exists

func (st *Blockdata) Exists(height base.Height) (bool, error)

func (*Blockdata) ExistsReal

func (st *Blockdata) ExistsReal(height base.Height) (exists bool, removed bool, err error)

func (*Blockdata) FS

func (st *Blockdata) FS() fs.FS

func (*Blockdata) Hint

func (*Blockdata) Hint() hint.Hint

func (*Blockdata) Initialize

func (st *Blockdata) Initialize() error

func (*Blockdata) IsLocal

func (*Blockdata) IsLocal() bool

func (*Blockdata) NewSession

func (st *Blockdata) NewSession(height base.Height) (blockdata.Session, error)

func (*Blockdata) Remove

func (st *Blockdata) Remove(height base.Height) error

Remove removes block directory by height. Remove does not remove the directory and inside files, it just creates .removd file with time. .removed file helps CleanByHeight to clean directories.

func (*Blockdata) RemoveAll

func (st *Blockdata) RemoveAll(height base.Height) error

RemoveAll removes directory and it's inside files.

func (*Blockdata) Root

func (st *Blockdata) Root() string

func (*Blockdata) SaveSession

func (st *Blockdata) SaveSession(session blockdata.Session) (block.BlockdataMap, error)

func (*Blockdata) Writer

func (st *Blockdata) Writer() blockdata.Writer

type FS

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

func NewFS

func NewFS(root string) FS

func (FS) Open

func (f FS) Open(p string) (fs.File, error)

type Session

type Session struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSession

func NewSession(root string, writer blockdata.Writer, height base.Height) (*Session, error)

func (*Session) AddOperations

func (ss *Session) AddOperations(ops ...operation.Operation) error

func (*Session) AddStates

func (ss *Session) AddStates(sts ...state.State) error

func (*Session) Cancel

func (ss *Session) Cancel() error

func (*Session) CloseOperations

func (ss *Session) CloseOperations() error

func (*Session) CloseStates

func (ss *Session) CloseStates() error

func (*Session) Height

func (ss *Session) Height() base.Height

func (*Session) Import

func (ss *Session) Import(dataType string, r io.Reader) (string, error)

func (*Session) SetACCEPTVoteproof

func (ss *Session) SetACCEPTVoteproof(voteproof base.Voteproof) error

func (*Session) SetBlock

func (ss *Session) SetBlock(blk block.Block) error

func (*Session) SetINITVoteproof

func (ss *Session) SetINITVoteproof(voteproof base.Voteproof) error

func (*Session) SetManifest

func (ss *Session) SetManifest(manifest block.Manifest) error

func (*Session) SetOperationsTree

func (ss *Session) SetOperationsTree(ft tree.FixedTree) error

func (*Session) SetProposal

func (ss *Session) SetProposal(sfs base.SignedBallotFact) error

func (*Session) SetStatesTree

func (ss *Session) SetStatesTree(ft tree.FixedTree) error

func (*Session) SetSuffrageInfo

func (ss *Session) SetSuffrageInfo(suffrageInfo block.SuffrageInfo) error

Jump to

Keyboard shortcuts

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