isaacblock

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: GPL-3.0 Imports: 26 Imported by: 28

Documentation

Overview

Package isaacblock handles data of block.

Index

Constants

This section is empty.

Variables

View Source
var BlockDirectoryHeightFormat = "%021s"
View Source
var BlockMapHint = hint.MustNewHint("blockmap-v0.0.1")
View Source
var (
	BlockTempDirectoryPrefix = "temp"
)
View Source
var (
	LocalBlockMapScheme = "file+block"
)
View Source
var LocalFSWriterHint = hint.MustNewHint("local-block-fs-writer-v0.0.1")
View Source
var SuffrageProofHint = hint.MustNewHint("suffrage-proof-v0.0.1")

Functions

func BlockFileName

func BlockFileName(t base.BlockMapItemType, hinttype string) (string, error)

func CleanBlockTempDirectory

func CleanBlockTempDirectory(root string) error

func FindHighestDirectory

func FindHighestDirectory(root string) (highest string, found bool, _ error)

func HeightDirectory

func HeightDirectory(height base.Height) string

func HeightFromDirectory

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

func LoadBlockReader

func LoadBlockReader(
	readers *BlockReaders,
	encs *encoder.Encoders,
	writerhint, enchint hint.Hint,
	height base.Height,
) (isaac.BlockReader, error)

func LoadRawItems

func LoadRawItems(
	f io.Reader,
	decode func([]byte) (interface{}, error),
	callback func(uint64, interface{}) error,
) error

func LoadRawItemsWithWorker

func LoadRawItemsWithWorker(
	f io.Reader,
	num uint64,
	decode func([]byte) (interface{}, error),
	callback func(uint64, interface{}) error,
) error

func LoadTree

func LoadTree(
	enc encoder.Encoder,
	item base.BlockMapItem,
	f io.Reader,
	callback func(interface{}) (fixedtree.Node, error),
) (tr fixedtree.Tree, err error)

func LoadTreeHint

func LoadTreeHint(br *bufio.Reader) (ht hint.Hint, _ error)

func LoadVoteproofsFromReader

func LoadVoteproofsFromReader(
	r io.Reader,
	num uint64,
	decode func([]byte) (interface{}, error),
) ([]base.Voteproof, error)

func RemoveBlocksFromLocalFS

func RemoveBlocksFromLocalFS(root string, height base.Height) (bool, error)

Types

type BlockImporter

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

func NewBlockImporter

func NewBlockImporter(
	root string,
	encs *encoder.Encoders,
	m base.BlockMap,
	bwdb isaac.BlockWriteDatabase,
	mergeBlockWriteDatabasef func(context.Context) error,
	networkID base.NetworkID,
) (*BlockImporter, error)

func (*BlockImporter) CancelImport

func (im *BlockImporter) CancelImport(context.Context) error

func (*BlockImporter) Reader

func (im *BlockImporter) Reader() (isaac.BlockReader, error)

func (*BlockImporter) Save

func (im *BlockImporter) Save(context.Context) (func(context.Context) error, error)

func (*BlockImporter) WriteItem

func (im *BlockImporter) WriteItem(t base.BlockMapItemType, r io.Reader) error

func (*BlockImporter) WriteMap

func (im *BlockImporter) WriteMap(m base.BlockMap) error

type BlockMap

type BlockMap struct {
	base.BaseNodeSign
	hint.BaseHinter
	// contains filtered or unexported fields
}

func NewBlockMap

func NewBlockMap(writer, encoder hint.Hint) BlockMap

func (BlockMap) Bytes

func (BlockMap) Bytes() []byte

func (*BlockMap) DecodeJSON

func (m *BlockMap) DecodeJSON(b []byte, enc *jsonenc.Encoder) error

func (BlockMap) Encoder

func (m BlockMap) Encoder() hint.Hint

func (BlockMap) IsValid

func (m BlockMap) IsValid(b []byte) error

func (BlockMap) Item

func (BlockMap) Items

func (m BlockMap) Items(f func(base.BlockMapItem) bool)

func (BlockMap) Manifest

func (m BlockMap) Manifest() base.Manifest

func (BlockMap) MarshalJSON

func (m BlockMap) MarshalJSON() ([]byte, error)

func (*BlockMap) SetItem

func (m *BlockMap) SetItem(item base.BlockMapItem) error

func (*BlockMap) SetManifest

func (m *BlockMap) SetManifest(manifest base.Manifest)

func (*BlockMap) Sign

func (m *BlockMap) Sign(node base.Address, priv base.Privatekey, networkID base.NetworkID) error

func (BlockMap) Writer

func (m BlockMap) Writer() hint.Hint

type BlockMapItem

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

func NewBlockMapItem

func NewBlockMapItem(t base.BlockMapItemType, u url.URL, checksum string, num uint64) BlockMapItem

func NewLocalBlockMapItem

func NewLocalBlockMapItem(t base.BlockMapItemType, checksum string, num uint64) BlockMapItem

func (BlockMapItem) Checksum

func (item BlockMapItem) Checksum() string

func (BlockMapItem) IsValid

func (item BlockMapItem) IsValid([]byte) error

func (BlockMapItem) MarshalJSON

func (item BlockMapItem) MarshalJSON() ([]byte, error)

func (BlockMapItem) Num

func (item BlockMapItem) Num() uint64

func (BlockMapItem) Type

func (item BlockMapItem) Type() base.BlockMapItemType

func (BlockMapItem) URL

func (item BlockMapItem) URL() *url.URL

func (*BlockMapItem) UnmarshalJSON

func (item *BlockMapItem) UnmarshalJSON(b []byte) error

type BlockReaders

type BlockReaders struct {
	*hint.CompatibleSet // NOTE handles NewBlockReaderFunc
}

func NewBlockReaders

func NewBlockReaders() *BlockReaders

func (*BlockReaders) Add

func (rs *BlockReaders) Add(ht hint.Hint, v interface{}) error

func (*BlockReaders) Find

func (rs *BlockReaders) Find(writerhint hint.Hint) NewBlockReaderFunc

type FSWriter

type FSWriter interface {
	SetProposal(context.Context, base.ProposalSignFact) error
	SetOperation(context.Context, uint64, base.Operation) error
	SetOperationsTree(context.Context, *fixedtree.Writer) error
	SetState(context.Context, uint64, base.State) error
	SetStatesTree(context.Context, *fixedtree.Writer) (fixedtree.Tree, error)
	SetManifest(context.Context, base.Manifest) error
	SetINITVoteproof(context.Context, base.INITVoteproof) error
	SetACCEPTVoteproof(context.Context, base.ACCEPTVoteproof) error
	Save(context.Context) (base.BlockMap, error)
	Cancel() error
}

type LocalFSImporter

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

func NewLocalFSImporter

func NewLocalFSImporter(root string, enc encoder.Encoder, m base.BlockMap) (*LocalFSImporter, error)

func (*LocalFSImporter) Cancel

func (l *LocalFSImporter) Cancel() error

func (*LocalFSImporter) Save

func (l *LocalFSImporter) Save() error

func (*LocalFSImporter) WriteItem

func (*LocalFSImporter) WriteMap

func (l *LocalFSImporter) WriteMap(m base.BlockMap) error

WriteMap writes BlockMap; BlockMap should be already sign.

type LocalFSReader

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

func NewLocalFSReader

func NewLocalFSReader(root string, enc encoder.Encoder) (*LocalFSReader, error)

func NewLocalFSReaderFromHeight

func NewLocalFSReaderFromHeight(baseroot string, height base.Height, enc encoder.Encoder) (*LocalFSReader, error)

func (*LocalFSReader) BlockMap

func (r *LocalFSReader) BlockMap() (base.BlockMap, bool, error)

func (*LocalFSReader) ChecksumReader

func (r *LocalFSReader) ChecksumReader(t base.BlockMapItemType) (util.ChecksumReader, bool, error)

func (*LocalFSReader) Close

func (r *LocalFSReader) Close() error

func (*LocalFSReader) Item

func (r *LocalFSReader) Item(t base.BlockMapItemType) (item interface{}, found bool, _ error)

func (*LocalFSReader) Items

func (r *LocalFSReader) Items(f func(base.BlockMapItem, interface{}, bool, error) bool) error

func (*LocalFSReader) Reader

func (*LocalFSReader) UncompressedReader

func (r *LocalFSReader) UncompressedReader(t base.BlockMapItemType) (io.ReadCloser, bool, error)

type LocalFSWriter

type LocalFSWriter struct {
	hint.BaseHinter

	sync.Mutex
	// contains filtered or unexported fields
}

func NewLocalFSWriter

func NewLocalFSWriter(
	root string,
	height base.Height,
	enc encoder.Encoder,
	local base.LocalNode,
	networkID base.NetworkID,
) (*LocalFSWriter, error)

func (*LocalFSWriter) Cancel

func (w *LocalFSWriter) Cancel() error

func (*LocalFSWriter) Save

func (w *LocalFSWriter) Save(ctx context.Context) (base.BlockMap, error)

func (*LocalFSWriter) SetACCEPTVoteproof

func (w *LocalFSWriter) SetACCEPTVoteproof(_ context.Context, vp base.ACCEPTVoteproof) error

func (*LocalFSWriter) SetINITVoteproof

func (w *LocalFSWriter) SetINITVoteproof(_ context.Context, vp base.INITVoteproof) error

func (*LocalFSWriter) SetManifest

func (w *LocalFSWriter) SetManifest(_ context.Context, m base.Manifest) error

func (*LocalFSWriter) SetOperation

func (w *LocalFSWriter) SetOperation(_ context.Context, _ uint64, op base.Operation) error

func (*LocalFSWriter) SetOperationsTree

func (w *LocalFSWriter) SetOperationsTree(ctx context.Context, tw *fixedtree.Writer) error

func (*LocalFSWriter) SetProposal

func (w *LocalFSWriter) SetProposal(_ context.Context, pr base.ProposalSignFact) error

func (*LocalFSWriter) SetState

func (w *LocalFSWriter) SetState(_ context.Context, _ uint64, st base.State) error

func (*LocalFSWriter) SetStatesTree

func (w *LocalFSWriter) SetStatesTree(ctx context.Context, tw *fixedtree.Writer) (tr fixedtree.Tree, err error)

type NewBlockReaderFunc

type NewBlockReaderFunc func(base.Height, encoder.Encoder) (isaac.BlockReader, error)

type SuffrageProof

type SuffrageProof struct {
	hint.BaseHinter
	// contains filtered or unexported fields
}

func NewSuffrageProof

func NewSuffrageProof(
	m base.BlockMap,
	st base.State,
	proof fixedtree.Proof,
	voteproof base.ACCEPTVoteproof,
) SuffrageProof

func (SuffrageProof) ACCEPTVoteproof

func (s SuffrageProof) ACCEPTVoteproof() base.ACCEPTVoteproof

func (*SuffrageProof) DecodeJSON

func (s *SuffrageProof) DecodeJSON(b []byte, enc *jsonenc.Encoder) error

func (SuffrageProof) IsValid

func (s SuffrageProof) IsValid(b []byte) error

func (SuffrageProof) Map

func (s SuffrageProof) Map() base.BlockMap

func (SuffrageProof) MarshalJSON

func (s SuffrageProof) MarshalJSON() ([]byte, error)

func (SuffrageProof) Proof

func (s SuffrageProof) Proof() fixedtree.Proof

func (SuffrageProof) Prove

func (s SuffrageProof) Prove(previousState base.State) error

Prove should be called after IsValid().

func (SuffrageProof) State

func (s SuffrageProof) State() base.State

func (SuffrageProof) Suffrage

func (s SuffrageProof) Suffrage() (base.Suffrage, error)

func (SuffrageProof) SuffrageHeight

func (s SuffrageProof) SuffrageHeight() base.Height

type SuffrageProofJSONMarshaler

type SuffrageProofJSONMarshaler struct {
	Map       base.BlockMap        `json:"map"`
	State     base.State           `json:"state"`
	Voteproof base.ACCEPTVoteproof `json:"voteproof"`
	Proof     fixedtree.Proof      `json:"proof"`
	hint.BaseHinter
}

type SuffrageProofJSONUnmarshaler

type SuffrageProofJSONUnmarshaler struct {
	Map       json.RawMessage `json:"map"`
	State     json.RawMessage `json:"state"`
	Proof     fixedtree.Proof `json:"proof"`
	Voteproof json.RawMessage `json:"voteproof"`
}

type Writer

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

func NewWriter

func NewWriter(
	proposal base.ProposalSignFact,
	getStateFunc base.GetStateFunc,
	db isaac.BlockWriteDatabase,
	mergeDatabase func(isaac.BlockWriteDatabase) error,
	fswriter FSWriter,
) *Writer

func (*Writer) Cancel

func (w *Writer) Cancel() error

func (*Writer) Manifest

func (w *Writer) Manifest(ctx context.Context, previous base.Manifest) (base.Manifest, error)

func (*Writer) Save

func (w *Writer) Save(ctx context.Context) (base.BlockMap, error)

func (*Writer) SetACCEPTVoteproof

func (w *Writer) SetACCEPTVoteproof(ctx context.Context, vp base.ACCEPTVoteproof) error

func (*Writer) SetINITVoteproof

func (w *Writer) SetINITVoteproof(ctx context.Context, vp base.INITVoteproof) error

func (*Writer) SetOperationsSize

func (w *Writer) SetOperationsSize(n uint64)

func (*Writer) SetProcessResult

func (w *Writer) SetProcessResult(
	_ context.Context,
	index uint64,
	op, facthash util.Hash,
	instate bool,
	errorreason base.OperationProcessReasonError,
) error

func (*Writer) SetState

func (w *Writer) SetState(_ context.Context, stv base.StateMergeValue, operation base.Operation) error

func (*Writer) SetStates

func (w *Writer) SetStates(
	ctx context.Context, index uint64, states []base.StateMergeValue, operation base.Operation,
) error

Jump to

Keyboard shortcuts

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