store

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 22 Imported by: 6

Documentation

Overview

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const DefaultCompressionFormat = appendable.DefaultCompressionFormat
View Source
const DefaultCompressionLevel = appendable.DefaultCompressionLevel
View Source
const DefaultFileMode = os.FileMode(0755)
View Source
const DefaultFileSize = multiapp.DefaultFileSize
View Source
const DefaultMaxConcurrency = 30
View Source
const DefaultMaxIOConcurrency = 1
View Source
const DefaultMaxKeyLen = 1024
View Source
const DefaultMaxLinearProofLen = 1 << 10
View Source
const DefaultMaxTxEntries = 1 << 10 // 1024
View Source
const DefaultMaxValueLen = 4096 // 4Kb
View Source
const DefaultMaxWaitees = 1000
View Source
const DefaultTxLogCacheSize = 1000
View Source
const MaxFileSize = (1 << 31) - 1 // 2Gb
View Source
const MaxKeyLen = 1024 // assumed to be not lower than hash size
View Source
const MaxParallelIO = 127
View Source
const NotificationWindow = 60 * time.Second
View Source
const TxHeaderVersion = 1
View Source
const Version = 1

Variables

View Source
var ErrAlreadyClosed = errors.New("store already closed")
View Source
var ErrCompactionUnsupported = errors.New("compaction is unsupported when remote storage is used")
View Source
var ErrCorruptedAHtree = errors.New("appendable hash tree is corrupted")
View Source
var ErrCorruptedCLog = errors.New("commit log is corrupted")
View Source
var ErrCorruptedData = errors.New("data is corrupted")
View Source
var ErrCorruptedIndex = errors.New("corrupted index")
View Source
var ErrDuplicatedKey = errors.New("duplicated key")
View Source
var ErrExpiredEntry = fmt.Errorf("%w: expired entry", ErrKeyNotFound)
View Source
var ErrIllegalArguments = errors.New("illegal arguments")
View Source
var ErrIllegalState = tbtree.ErrIllegalState
View Source
var ErrKeyAlreadyExists = errors.New("key already exists")
View Source
var ErrKeyNotFound = tbtree.ErrKeyNotFound
View Source
var ErrLinearProofMaxLenExceeded = errors.New("max linear proof length limit exceeded")
View Source
var ErrMaxConcurrencyLimitExceeded = errors.New("max concurrency limit exceeded")
View Source
var ErrNewerVersionOrCorruptedData = errors.New("tx created with a newer version or data is corrupted")
View Source
var ErrNoMoreEntries = tbtree.ErrNoMoreEntries
View Source
var ErrNonExpirable = errors.New("non expirable")
View Source
var ErrNullKey = errors.New("null key")
View Source
var ErrOffsetOutOfRange = tbtree.ErrOffsetOutOfRange
View Source
var ErrSourceTxNewerThanTargetTx = errors.New("source tx is newer than target tx")
View Source
var ErrTxNotFound = errors.New("tx not found")
View Source
var ErrTxReadConflict = errors.New("tx read conflict")
View Source
var ErrTxSizeGreaterThanMaxTxSize = errors.New("tx size greater than max tx size")
View Source
var ErrUnexpectedError = errors.New("unexpected error")
View Source
var ErrUnexpectedLinkingError = errors.New("internal inconsistency between linear and binary linking")
View Source
var ErrUnsupportedTxVersion = errors.New("unsupported tx version")
View Source
var ErrWriteOnlyTx = errors.New("write-only transaction")
View Source
var ErrorCorruptedTxData = errors.New("tx data is corrupted")
View Source
var ErrorMaxKeyLenExceeded = errors.New("max key length exceeded")
View Source
var ErrorMaxTxEntriesLimitExceeded = errors.New("max number of entries per tx exceeded")
View Source
var ErrorMaxValueLenExceeded = errors.New("max value length exceeded")
View Source
var ErrorNoEntriesProvided = errors.New("no entries provided")
View Source
var ErrorPathIsNotADirectory = errors.New("path is not a directory")

Functions

func EntrySpecDigest_v0 added in v1.2.0

func EntrySpecDigest_v0(kv *EntrySpec) [sha256.Size]byte

func EntrySpecDigest_v1 added in v1.2.0

func EntrySpecDigest_v1(kv *EntrySpec) [sha256.Size]byte

func TxEntryDigest_v1_1 added in v1.2.0

func TxEntryDigest_v1_1(e *TxEntry) [sha256.Size]byte

func TxEntryDigest_v1_2 added in v1.2.0

func TxEntryDigest_v1_2(e *TxEntry) [sha256.Size]byte

func VerifyDualProof

func VerifyDualProof(proof *DualProof, sourceTxID, targetTxID uint64, sourceAlh, targetAlh [sha256.Size]byte) bool

func VerifyInclusion added in v0.9.0

func VerifyInclusion(proof *htree.InclusionProof, entryDigest, root [sha256.Size]byte) bool

func VerifyLinearProof

func VerifyLinearProof(proof *LinearProof, sourceTxID, targetTxID uint64, sourceAlh, targetAlh [sha256.Size]byte) bool

Types

type AppFactoryFunc added in v1.0.5

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

type DualProof

type DualProof struct {
	SourceTxHeader     *TxHeader
	TargetTxHeader     *TxHeader
	InclusionProof     [][sha256.Size]byte
	ConsistencyProof   [][sha256.Size]byte
	TargetBlTxAlh      [sha256.Size]byte
	LastInclusionProof [][sha256.Size]byte
	LinearProof        *LinearProof
}

type EntrySpec added in v1.2.0

type EntrySpec struct {
	Key      []byte
	Metadata *KVMetadata
	Value    []byte
}

type EntrySpecDigest added in v1.2.0

type EntrySpecDigest func(kv *EntrySpec) [sha256.Size]byte

func EntrySpecDigestFor added in v1.2.0

func EntrySpecDigestFor(version int) (EntrySpecDigest, error)

type FilterFn added in v1.2.0

type FilterFn func(valRef ValueRef, t time.Time) bool

filter out entries when filter evaluates to true

var (
	IgnoreDeleted FilterFn = func(valRef ValueRef, t time.Time) bool {
		md := valRef.KVMetadata()
		return md != nil && md.Deleted()
	}

	IgnoreExpired FilterFn = func(valRef ValueRef, t time.Time) bool {
		md := valRef.KVMetadata()
		return md != nil && md.ExpiredAt(t)
	}
)

type ImmuStore

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

func Open

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

func OpenWith

func OpenWith(path string, vLogs []appendable.Appendable, txLog, cLog appendable.Appendable, opts *Options) (*ImmuStore, error)

func (*ImmuStore) Alh

func (s *ImmuStore) Alh() (uint64, [sha256.Size]byte)

func (*ImmuStore) BlInfo

func (s *ImmuStore) BlInfo() (uint64, error)

func (*ImmuStore) Close

func (s *ImmuStore) Close() error

func (*ImmuStore) CommitWith added in v0.9.1

func (s *ImmuStore) CommitWith(callback func(txID uint64, index KeyIndex) ([]*EntrySpec, error), waitForIndexing bool) (*TxHeader, error)

func (*ImmuStore) CompactIndex added in v0.9.2

func (s *ImmuStore) CompactIndex() error

func (*ImmuStore) DualProof

func (s *ImmuStore) DualProof(sourceTx, targetTx *Tx) (proof *DualProof, err error)

DualProof combines linear cryptographic linking i.e. transactions include the linear accumulative hash up to the previous one, with binary cryptographic linking generated by appending the linear accumulative hash values into an incremental hash tree, whose root is also included as part of each transaction and thus considered when calculating the linear accumulative hash. The objective of this proof is the same as the linear proof, that is, generate data for the calculation of the accumulative hash value of the target transaction from the linear accumulative hash value up to source transaction.

func (*ImmuStore) ExistKeyWith added in v1.0.0

func (s *ImmuStore) ExistKeyWith(prefix []byte, neq []byte) (bool, error)

func (*ImmuStore) ExportTx added in v1.0.5

func (s *ImmuStore) ExportTx(txID uint64, tx *Tx) ([]byte, error)

func (*ImmuStore) Get added in v0.9.0

func (s *ImmuStore) Get(key []byte) (valRef ValueRef, err error)

func (*ImmuStore) GetWith added in v1.2.0

func (s *ImmuStore) GetWith(key []byte, filters ...FilterFn) (valRef ValueRef, err error)

func (*ImmuStore) History added in v0.9.1

func (s *ImmuStore) History(key []byte, offset uint64, descOrder bool, limit int) (txs []uint64, err error)

func (*ImmuStore) IndexInfo

func (s *ImmuStore) IndexInfo() uint64

func (*ImmuStore) LinearProof

func (s *ImmuStore) LinearProof(sourceTxID, targetTxID uint64) (*LinearProof, error)

LinearProof returns a list of hashes to calculate Alh@targetTxID from Alh@sourceTxID

func (*ImmuStore) MaxConcurrency

func (s *ImmuStore) MaxConcurrency() int

func (*ImmuStore) MaxIOConcurrency

func (s *ImmuStore) MaxIOConcurrency() int

func (*ImmuStore) MaxKeyLen

func (s *ImmuStore) MaxKeyLen() int

func (*ImmuStore) MaxLinearProofLen

func (s *ImmuStore) MaxLinearProofLen() int

func (*ImmuStore) MaxTxEntries

func (s *ImmuStore) MaxTxEntries() int

func (*ImmuStore) MaxValueLen

func (s *ImmuStore) MaxValueLen() int

func (*ImmuStore) NewTx

func (s *ImmuStore) NewTx() (*OngoingTx, error)

func (*ImmuStore) NewTxHolder added in v1.2.0

func (s *ImmuStore) NewTxHolder() *Tx

func (*ImmuStore) NewTxReader

func (s *ImmuStore) NewTxReader(initialTxID uint64, desc bool, tx *Tx) (*TxReader, error)

func (*ImmuStore) NewWriteOnlyTx added in v1.2.0

func (s *ImmuStore) NewWriteOnlyTx() (*OngoingTx, error)

func (*ImmuStore) ReadOnly

func (s *ImmuStore) ReadOnly() bool

func (*ImmuStore) ReadTx

func (s *ImmuStore) ReadTx(txID uint64, tx *Tx) error

func (*ImmuStore) ReadValue

func (s *ImmuStore) ReadValue(txID uint64, txHolder *Tx, key []byte) ([]byte, error)

ReadValue returns the actual associated value to a key at a specific transaction ErrExpiredEntry is be returned if the specified time has already elapsed Note; the tx is read to be safe in cases provided tx was manipulated at runtime

func (*ImmuStore) ReplicateTx added in v1.0.5

func (s *ImmuStore) ReplicateTx(exportedTx []byte, waitForIndexing bool) (*TxHeader, error)

func (*ImmuStore) SetBlErr

func (s *ImmuStore) SetBlErr(err error)

func (*ImmuStore) Snapshot

func (s *ImmuStore) Snapshot() (*Snapshot, error)

func (*ImmuStore) SnapshotSince added in v0.9.0

func (s *ImmuStore) SnapshotSince(tx uint64) (*Snapshot, error)

func (*ImmuStore) Sync

func (s *ImmuStore) Sync() error

func (*ImmuStore) Synced

func (s *ImmuStore) Synced() bool

func (*ImmuStore) TxCount

func (s *ImmuStore) TxCount() uint64

func (*ImmuStore) UseTimeFunc added in v1.1.0

func (s *ImmuStore) UseTimeFunc(timeFunc TimeFunc) error

func (*ImmuStore) WaitForIndexingUpto added in v0.9.2

func (s *ImmuStore) WaitForIndexingUpto(txID uint64, cancellation <-chan struct{}) error

func (*ImmuStore) WaitForTx added in v1.0.5

func (s *ImmuStore) WaitForTx(txID uint64, cancellation <-chan struct{}) error

type IndexOptions

type IndexOptions struct {
	CacheSize             int
	FlushThld             int
	MaxActiveSnapshots    int
	MaxNodeSize           int
	RenewSnapRootAfter    time.Duration
	CompactionThld        int
	DelayDuringCompaction time.Duration
}

func DefaultIndexOptions

func DefaultIndexOptions() *IndexOptions

func (*IndexOptions) WithCacheSize

func (opts *IndexOptions) WithCacheSize(cacheSize int) *IndexOptions

func (*IndexOptions) WithCompactionThld added in v0.9.2

func (opts *IndexOptions) WithCompactionThld(compactionThld int) *IndexOptions

func (*IndexOptions) WithDelayDuringCompaction added in v0.9.2

func (opts *IndexOptions) WithDelayDuringCompaction(delayDuringCompaction time.Duration) *IndexOptions

func (*IndexOptions) WithFlushThld

func (opts *IndexOptions) WithFlushThld(flushThld int) *IndexOptions

func (*IndexOptions) WithMaxActiveSnapshots

func (opts *IndexOptions) WithMaxActiveSnapshots(maxActiveSnapshots int) *IndexOptions

func (*IndexOptions) WithMaxNodeSize

func (opts *IndexOptions) WithMaxNodeSize(maxNodeSize int) *IndexOptions

func (*IndexOptions) WithRenewSnapRootAfter

func (opts *IndexOptions) WithRenewSnapRootAfter(renewSnapRootAfter time.Duration) *IndexOptions

type KVMetadata added in v1.2.0

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

func NewKVMetadata added in v1.2.0

func NewKVMetadata() *KVMetadata

func (*KVMetadata) AsDeleted added in v1.2.0

func (md *KVMetadata) AsDeleted(deleted bool) *KVMetadata

func (*KVMetadata) Bytes added in v1.2.0

func (md *KVMetadata) Bytes() []byte

func (*KVMetadata) Deleted added in v1.2.0

func (md *KVMetadata) Deleted() bool

func (*KVMetadata) ExpirationTime added in v1.2.0

func (md *KVMetadata) ExpirationTime() (time.Time, error)

func (*KVMetadata) ExpiredAt added in v1.2.0

func (md *KVMetadata) ExpiredAt(mtime time.Time) bool

func (*KVMetadata) ExpiresAt added in v1.2.0

func (md *KVMetadata) ExpiresAt(expiresAt time.Time) *KVMetadata

func (*KVMetadata) IsExpirable added in v1.2.0

func (md *KVMetadata) IsExpirable() bool

func (*KVMetadata) NonExpirable added in v1.2.0

func (md *KVMetadata) NonExpirable() *KVMetadata

func (*KVMetadata) ReadFrom added in v1.2.0

func (md *KVMetadata) ReadFrom(b []byte) error

type KeyIndex added in v1.0.0

type KeyIndex interface {
	Get(key []byte) (valRef ValueRef, err error)
	GetWith(key []byte, filters ...FilterFn) (valRef ValueRef, err error)
}

type KeyReader added in v0.9.1

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

func (*KeyReader) Close added in v0.9.1

func (r *KeyReader) Close() error

func (*KeyReader) Read added in v0.9.1

func (r *KeyReader) Read() (key []byte, val ValueRef, err error)

func (*KeyReader) ReadAsBefore added in v1.0.0

func (r *KeyReader) ReadAsBefore(txID uint64) (key []byte, val ValueRef, tx uint64, err error)

func (*KeyReader) Reset added in v1.0.0

func (r *KeyReader) Reset() error

type KeyReaderSpec added in v1.0.0

type KeyReaderSpec struct {
	SeekKey       []byte
	EndKey        []byte
	Prefix        []byte
	InclusiveSeek bool
	InclusiveEnd  bool
	DescOrder     bool
	Filter        FilterFn
}

type LinearProof

type LinearProof struct {
	SourceTxID uint64
	TargetTxID uint64
	Terms      [][sha256.Size]byte
}

type NotificationType added in v0.9.2

type NotificationType = int
const (
	Info NotificationType = iota
	Warn
	Error
)

type OngoingTx added in v1.2.0

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

OngoingTx (no-thread safe) represents an interactive or incremental transaction with support of RYOW. The snapshot may be locally modified but isolated from other transactions

func (*OngoingTx) AsyncCommit added in v1.2.0

func (tx *OngoingTx) AsyncCommit() (*TxHeader, error)

func (*OngoingTx) Cancel added in v1.2.0

func (tx *OngoingTx) Cancel() error

func (*OngoingTx) Commit added in v1.2.0

func (tx *OngoingTx) Commit() (*TxHeader, error)

func (*OngoingTx) Delete added in v1.2.0

func (tx *OngoingTx) Delete(key []byte) error

func (*OngoingTx) ExistKeyWith added in v1.2.0

func (tx *OngoingTx) ExistKeyWith(prefix, neq []byte) (bool, error)

func (*OngoingTx) Get added in v1.2.0

func (tx *OngoingTx) Get(key []byte) (ValueRef, error)

func (*OngoingTx) GetWith added in v1.2.0

func (tx *OngoingTx) GetWith(key []byte, filters ...FilterFn) (ValueRef, error)

func (*OngoingTx) IsWriteOnly added in v1.2.0

func (tx *OngoingTx) IsWriteOnly() bool

func (*OngoingTx) Metadata added in v1.2.0

func (tx *OngoingTx) Metadata() *TxMetadata

func (*OngoingTx) NewKeyReader added in v1.2.0

func (tx *OngoingTx) NewKeyReader(spec *KeyReaderSpec) (*KeyReader, error)

func (*OngoingTx) Set added in v1.2.0

func (tx *OngoingTx) Set(key []byte, md *KVMetadata, value []byte) error

func (*OngoingTx) WithMetadata added in v1.2.0

func (tx *OngoingTx) WithMetadata(md *TxMetadata) *OngoingTx

type Options

type Options struct {
	ReadOnly bool
	Synced   bool
	FileMode os.FileMode

	CompactionDisabled bool

	MaxConcurrency    int
	MaxIOConcurrency  int
	MaxLinearProofLen int

	TxLogCacheSize int

	VLogMaxOpenedFiles      int
	TxLogMaxOpenedFiles     int
	CommitLogMaxOpenedFiles int

	MaxWaitees int

	TimeFunc TimeFunc

	// options below are only set during initialization and stored as metadata
	MaxTxEntries      int
	MaxKeyLen         int
	MaxValueLen       int
	FileSize          int
	CompressionFormat int
	CompressionLevel  int

	// options below affect indexing
	IndexOpts *IndexOptions
	// contains filtered or unexported fields
}

func DefaultOptions

func DefaultOptions() *Options

func (*Options) WithAppFactory added in v1.0.5

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

func (*Options) WithCommitLogMaxOpenedFiles

func (opts *Options) WithCommitLogMaxOpenedFiles(commitLogMaxOpenedFiles int) *Options

func (*Options) WithCompactionDisabled added in v1.0.5

func (opts *Options) WithCompactionDisabled(disabled bool) *Options

func (*Options) WithCompresionLevel

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

func (*Options) WithCompressionFormat

func (opts *Options) WithCompressionFormat(compressionFormat 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) WithIndexOptions

func (opts *Options) WithIndexOptions(indexOptions *IndexOptions) *Options

func (*Options) WithLog added in v0.9.2

func (opts *Options) WithLog(log logger.Logger) *Options

func (*Options) WithMaxConcurrency

func (opts *Options) WithMaxConcurrency(maxConcurrency int) *Options

func (*Options) WithMaxIOConcurrency

func (opts *Options) WithMaxIOConcurrency(maxIOConcurrency int) *Options

func (*Options) WithMaxKeyLen

func (opts *Options) WithMaxKeyLen(maxKeyLen int) *Options

func (*Options) WithMaxLinearProofLen

func (opts *Options) WithMaxLinearProofLen(maxLinearProofLen int) *Options

func (*Options) WithMaxTxEntries

func (opts *Options) WithMaxTxEntries(maxTxEntries int) *Options

func (*Options) WithMaxValueLen

func (opts *Options) WithMaxValueLen(maxValueLen int) *Options

func (*Options) WithMaxWaitees added in v0.9.2

func (opts *Options) WithMaxWaitees(maxWaitees int) *Options

func (*Options) WithReadOnly

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

func (*Options) WithSynced

func (opts *Options) WithSynced(synced bool) *Options

func (*Options) WithTimeFunc added in v1.1.0

func (opts *Options) WithTimeFunc(timeFunc TimeFunc) *Options

func (*Options) WithTxLogCacheSize added in v0.9.2

func (opts *Options) WithTxLogCacheSize(txLogCacheSize int) *Options

func (*Options) WithTxLogMaxOpenedFiles

func (opts *Options) WithTxLogMaxOpenedFiles(txLogMaxOpenedFiles int) *Options

func (*Options) WithVLogMaxOpenedFiles

func (opts *Options) WithVLogMaxOpenedFiles(vLogMaxOpenedFiles int) *Options

type Snapshot added in v1.0.0

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

func (*Snapshot) Close added in v1.0.0

func (s *Snapshot) Close() error

func (*Snapshot) ExistKeyWith added in v1.2.0

func (s *Snapshot) ExistKeyWith(prefix []byte, neq []byte) (bool, error)

func (*Snapshot) Get added in v1.0.0

func (s *Snapshot) Get(key []byte) (valRef ValueRef, err error)

func (*Snapshot) GetWith added in v1.2.0

func (s *Snapshot) GetWith(key []byte, filters ...FilterFn) (valRef ValueRef, err error)

func (*Snapshot) History added in v1.0.0

func (s *Snapshot) History(key []byte, offset uint64, descOrder bool, limit int) (tss []uint64, err error)

func (*Snapshot) NewKeyReader added in v1.0.0

func (s *Snapshot) NewKeyReader(spec *KeyReaderSpec) (*KeyReader, error)

func (*Snapshot) Ts added in v1.0.0

func (s *Snapshot) Ts() uint64

type TimeFunc added in v1.1.0

type TimeFunc func() time.Time

type Tx

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

func NewTxWithEntries added in v0.9.0

func NewTxWithEntries(entries []*TxEntry) *Tx

func (*Tx) BuildHashTree added in v0.9.0

func (tx *Tx) BuildHashTree() error

func (*Tx) Entries

func (tx *Tx) Entries() []*TxEntry

func (*Tx) EntryOf added in v1.2.0

func (tx *Tx) EntryOf(key []byte) (*TxEntry, error)

func (*Tx) Header added in v1.2.0

func (tx *Tx) Header() *TxHeader

func (*Tx) IndexOf

func (tx *Tx) IndexOf(key []byte) (int, error)

func (*Tx) Proof

func (tx *Tx) Proof(key []byte) (*htree.InclusionProof, error)

func (*Tx) TxEntryDigest added in v1.2.0

func (tx *Tx) TxEntryDigest() (TxEntryDigest, error)

type TxEntry added in v0.9.1

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

func NewTxEntry added in v0.9.1

func NewTxEntry(key []byte, md *KVMetadata, vLen int, hVal [sha256.Size]byte, vOff int64) *TxEntry

func (*TxEntry) HVal added in v0.9.1

func (e *TxEntry) HVal() [sha256.Size]byte

func (*TxEntry) Key added in v0.9.1

func (e *TxEntry) Key() []byte

func (*TxEntry) Metadata added in v1.2.0

func (e *TxEntry) Metadata() *KVMetadata

func (*TxEntry) VLen added in v0.9.1

func (e *TxEntry) VLen() int

func (*TxEntry) VOff added in v0.9.1

func (e *TxEntry) VOff() int64

type TxEntryDigest added in v1.2.0

type TxEntryDigest func(e *TxEntry) [sha256.Size]byte

type TxHeader added in v1.2.0

type TxHeader struct {
	ID      uint64
	Ts      int64
	BlTxID  uint64
	BlRoot  [sha256.Size]byte
	PrevAlh [sha256.Size]byte

	Version int

	Metadata *TxMetadata

	NEntries int
	Eh       [sha256.Size]byte
}

func (*TxHeader) Alh added in v1.2.0

func (hdr *TxHeader) Alh() [sha256.Size]byte

Alh calculates the Accumulative Linear Hash up to this transaction Alh is calculated as hash(txID + prevAlh + hash(ts + nentries + eH + blTxID + blRoot)) Inner hash is calculated so to reduce the length of linear proofs

func (*TxHeader) Bytes added in v1.2.0

func (hdr *TxHeader) Bytes() []byte

func (*TxHeader) ReadFrom added in v1.2.0

func (hdr *TxHeader) ReadFrom(b []byte) error

type TxMetadata

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

func NewTxMetadata added in v1.2.0

func NewTxMetadata() *TxMetadata

func (*TxMetadata) Bytes added in v1.2.0

func (md *TxMetadata) Bytes() []byte

func (*TxMetadata) Equal added in v1.2.0

func (md *TxMetadata) Equal(amd *TxMetadata) bool

func (*TxMetadata) ReadFrom added in v1.2.0

func (md *TxMetadata) ReadFrom(b []byte) error

func (*TxMetadata) Summary added in v1.2.0

func (md *TxMetadata) Summary() []byte

func (*TxMetadata) WithSummary added in v1.2.0

func (md *TxMetadata) WithSummary(summary []byte) *TxMetadata

type TxReader

type TxReader struct {
	InitialTxID uint64
	Desc        bool

	CurrTxID uint64
	CurrAlh  [sha256.Size]byte
	// contains filtered or unexported fields
}

func (*TxReader) Read

func (txr *TxReader) Read() (*Tx, error)

type ValueRef added in v0.9.1

type ValueRef interface {
	Resolve() (val []byte, err error)
	Tx() uint64
	HC() uint64
	TxMetadata() *TxMetadata
	KVMetadata() *KVMetadata
	HVal() [sha256.Size]byte
	Len() uint32
}

Jump to

Keyboard shortcuts

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