ahtree

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCompressionFormat = appendable.DefaultCompressionFormat
View Source
const DefaultCompressionLevel = appendable.DefaultCompressionLevel
View Source
const DefaultDataCacheSlots = 1_000
View Source
const DefaultDigestsCacheSlots = 100_000
View Source
const DefaultFileMode = os.FileMode(0755)
View Source
const DefaultFileSize = multiapp.DefaultFileSize
View Source
const DefaultSyncThld = 100_000
View Source
const DefaultWriteBufferSize = 1 << 24 //16Mb
View Source
const LeafPrefix = byte(0)
View Source
const (
	MetaVersion = "VERSION"
)
View Source
const NodePrefix = byte(1)
View Source
const Version = 1

Variables

View Source
var ErrAlreadyClosed = errors.New("ahtree: already closed")
View Source
var ErrCannotResetToLargerSize = errors.New("ahtree: can not reset the tree to a larger size")
View Source
var ErrEmptyTree = errors.New("ahtree: empty tree")
View Source
var ErrIllegalArguments = errors.New("ahtree: illegal arguments")
View Source
var ErrInvalidOptions = fmt.Errorf("%w: invalid options", ErrIllegalArguments)
View Source
var ErrReadOnly = errors.New("ahtree: read-only mode")
View Source
var ErrUnexistentData = errors.New("ahtree: attempt to read unexistent data")
View Source
var ErrorCorruptedData = errors.New("ahtree: data log is corrupted")
View Source
var ErrorCorruptedDigests = errors.New("ahtree: hash log is corrupted")
View Source
var ErrorPathIsNotADirectory = errors.New("ahtree: path is not a directory")

Functions

func EvalConsistency

func EvalConsistency(cproof [][sha256.Size]byte, i, j uint64) ([sha256.Size]byte, [sha256.Size]byte)

func EvalInclusion

func EvalInclusion(iproof [][sha256.Size]byte, i, j uint64, iLeaf [sha256.Size]byte) [sha256.Size]byte

func EvalLastInclusion

func EvalLastInclusion(iproof [][sha256.Size]byte, i uint64, leaf [sha256.Size]byte) [sha256.Size]byte

func VerifyConsistency

func VerifyConsistency(cproof [][sha256.Size]byte, i, j uint64, iRoot, jRoot [sha256.Size]byte) bool

func VerifyInclusion

func VerifyInclusion(iproof [][sha256.Size]byte, i, j uint64, iLeaf, jRoot [sha256.Size]byte) bool

func VerifyLastInclusion

func VerifyLastInclusion(iproof [][sha256.Size]byte, i uint64, leaf, root [sha256.Size]byte) bool

Types

type AHtree

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

AHtree stands for Appendable Hash Tree

func Open

func Open(path string, opts *Options) (*AHtree, error)

func OpenWith

func OpenWith(pLog, dLog, cLog appendable.Appendable, opts *Options) (*AHtree, error)

func (*AHtree) Append

func (t *AHtree) Append(d []byte) (n uint64, h [sha256.Size]byte, err error)

func (*AHtree) Close

func (t *AHtree) Close() error

func (*AHtree) ConsistencyProof

func (t *AHtree) ConsistencyProof(i, j uint64) (p [][sha256.Size]byte, err error)

func (*AHtree) DataAt

func (t *AHtree) DataAt(n uint64) ([]byte, error)

func (*AHtree) InclusionProof

func (t *AHtree) InclusionProof(i, j uint64) (p [][sha256.Size]byte, err error)

func (*AHtree) ResetSize added in v1.0.5

func (t *AHtree) ResetSize(newSize uint64) error

func (*AHtree) Root

func (t *AHtree) Root() (n uint64, r [sha256.Size]byte, err error)

func (*AHtree) RootAt

func (t *AHtree) RootAt(n uint64) (r [sha256.Size]byte, err error)

func (*AHtree) Size

func (t *AHtree) Size() uint64

func (*AHtree) Sync

func (t *AHtree) Sync() error

type AppFactoryFunc added in v1.0.5

type AppFactoryFunc func(
	rootPath string,
	subPath string,
	opts *multiapp.Options,
) (appendable.Appendable, error)

type Options

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

func DefaultOptions

func DefaultOptions() *Options

func (*Options) Validate added in v1.3.2

func (opts *Options) Validate() error

func (*Options) WithAppFactory added in v1.0.5

func (opts *Options) WithAppFactory(appFactory AppFactoryFunc) *Options

func (*Options) WithAutoSync added in v1.3.2

func (opts *Options) WithAutoSync(autoSync bool) *Options

func (*Options) WithCompresionLevel

func (opts *Options) WithCompresionLevel(compressionLevel int) *Options

func (*Options) WithCompressionFormat

func (opts *Options) WithCompressionFormat(compressionFormat int) *Options

func (*Options) WithDataCacheSlots

func (opts *Options) WithDataCacheSlots(cacheSlots int) *Options

func (*Options) WithDigestsCacheSlots

func (opts *Options) WithDigestsCacheSlots(cacheSlots int) *Options

func (*Options) WithFileMode

func (opts *Options) WithFileMode(fileMode os.FileMode) *Options

func (*Options) WithFileSize

func (opts *Options) WithFileSize(fileSize int) *Options

func (*Options) WithReadBufferSize added in v1.3.2

func (opts *Options) WithReadBufferSize(size int) *Options

func (*Options) WithReadOnly

func (opts *Options) WithReadOnly(readOnly bool) *Options

func (*Options) WithRetryableSync added in v1.3.2

func (opts *Options) WithRetryableSync(retryableSync bool) *Options

func (*Options) WithSyncThld added in v1.3.2

func (opts *Options) WithSyncThld(syncThld int) *Options

func (*Options) WithWriteBufferSize added in v1.3.2

func (opts *Options) WithWriteBufferSize(size int) *Options

Jump to

Keyboard shortcuts

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