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.
Index ¶
- Constants
- Variables
- func VerifyDualProof(proof *DualProof, sourceTxID, targetTxID uint64, ...) bool
- func VerifyInclusion(proof *htree.InclusionProof, kv *KV, root [sha256.Size]byte) bool
- func VerifyLinearProof(proof *LinearProof, sourceTxID, targetTxID uint64, ...) bool
- type DualProof
- type ImmuStore
- func (s *ImmuStore) Alh() (uint64, [sha256.Size]byte)
- func (s *ImmuStore) BlInfo() (uint64, error)
- func (s *ImmuStore) Close() error
- func (s *ImmuStore) Commit(entries []*KV, waitForIndexing bool) (*TxMetadata, error)
- func (s *ImmuStore) CommitWith(callback func(txID uint64, index *tbtree.TBtree) ([]*KV, error), ...) (*TxMetadata, error)
- func (s *ImmuStore) CompactIndex() error
- func (s *ImmuStore) DualProof(sourceTx, targetTx *Tx) (proof *DualProof, err error)
- func (s *ImmuStore) Get(key []byte) (value []byte, tx uint64, hc uint64, err error)
- func (s *ImmuStore) History(key []byte, offset uint64, descOrder bool, limit int) (txs []uint64, err error)
- func (s *ImmuStore) IndexInfo() (uint64, error)
- func (s *ImmuStore) LinearProof(sourceTxID, targetTxID uint64) (*LinearProof, error)
- func (s *ImmuStore) MaxConcurrency() int
- func (s *ImmuStore) MaxIOConcurrency() int
- func (s *ImmuStore) MaxKeyLen() int
- func (s *ImmuStore) MaxLinearProofLen() int
- func (s *ImmuStore) MaxTxEntries() int
- func (s *ImmuStore) MaxValueLen() int
- func (st *ImmuStore) NewKeyReader(snap *tbtree.Snapshot, spec *tbtree.ReaderSpec) (*KeyReader, error)
- func (s *ImmuStore) NewTx() *Tx
- func (s *ImmuStore) NewTxReader(initialTxID uint64, desc bool, tx *Tx) (*TxReader, error)
- func (s *ImmuStore) ReadOnly() bool
- func (s *ImmuStore) ReadTx(txID uint64, tx *Tx) error
- func (s *ImmuStore) ReadValue(tx *Tx, key []byte) ([]byte, error)
- func (s *ImmuStore) ReadValueAt(b []byte, off int64, hvalue [sha256.Size]byte) (int, error)
- func (s *ImmuStore) SetBlErr(err error)
- func (s *ImmuStore) Snapshot() (*tbtree.Snapshot, error)
- func (s *ImmuStore) SnapshotSince(tx uint64) (*tbtree.Snapshot, error)
- func (s *ImmuStore) Sync() error
- func (s *ImmuStore) Synced() bool
- func (s *ImmuStore) TxCount() uint64
- func (s *ImmuStore) WaitForIndexingUpto(txID uint64) error
- type IndexOptions
- func (opts *IndexOptions) WithCacheSize(cacheSize int) *IndexOptions
- func (opts *IndexOptions) WithCompactionThld(compactionThld int) *IndexOptions
- func (opts *IndexOptions) WithDelayDuringCompaction(delayDuringCompaction time.Duration) *IndexOptions
- func (opts *IndexOptions) WithFlushThld(flushThld int) *IndexOptions
- func (opts *IndexOptions) WithMaxActiveSnapshots(maxActiveSnapshots int) *IndexOptions
- func (opts *IndexOptions) WithMaxNodeSize(maxNodeSize int) *IndexOptions
- func (opts *IndexOptions) WithRenewSnapRootAfter(renewSnapRootAfter time.Duration) *IndexOptions
- type KV
- type KeyReader
- type LinearProof
- type NotificationType
- type Options
- func (opts *Options) WithCommitLogMaxOpenedFiles(commitLogMaxOpenedFiles int) *Options
- func (opts *Options) WithCompresionLevel(compressionLevel int) *Options
- func (opts *Options) WithCompressionFormat(compressionFormat int) *Options
- func (opts *Options) WithFileMode(fileMode os.FileMode) *Options
- func (opts *Options) WithFileSize(fileSize int) *Options
- func (opts *Options) WithIndexOptions(indexOptions *IndexOptions) *Options
- func (opts *Options) WithLog(log logger.Logger) *Options
- func (opts *Options) WithMaxConcurrency(maxConcurrency int) *Options
- func (opts *Options) WithMaxIOConcurrency(maxIOConcurrency int) *Options
- func (opts *Options) WithMaxKeyLen(maxKeyLen int) *Options
- func (opts *Options) WithMaxLinearProofLen(maxLinearProofLen int) *Options
- func (opts *Options) WithMaxTxEntries(maxTxEntries int) *Options
- func (opts *Options) WithMaxValueLen(maxValueLen int) *Options
- func (opts *Options) WithMaxWaitees(maxWaitees int) *Options
- func (opts *Options) WithReadOnly(readOnly bool) *Options
- func (opts *Options) WithSynced(synced bool) *Options
- func (opts *Options) WithTxLogCacheSize(txLogCacheSize int) *Options
- func (opts *Options) WithTxLogMaxOpenedFiles(txLogMaxOpenedFiles int) *Options
- func (opts *Options) WithVLogMaxOpenedFiles(vLogMaxOpenedFiles int) *Options
- type Tx
- type TxEntry
- type TxMetadata
- type TxReader
- type ValueRef
Constants ¶
const DefaultCompressionFormat = appendable.DefaultCompressionFormat
const DefaultCompressionLevel = appendable.DefaultCompressionLevel
const DefaultFileMode = os.FileMode(0755)
const DefaultFileSize = multiapp.DefaultFileSize
const DefaultMaxConcurrency = 30
const DefaultMaxIOConcurrency = 1
const DefaultMaxKeyLen = 1024
const DefaultMaxLinearProofLen = 1 << 10
const DefaultMaxTxEntries = 1 << 10 // 1024
const DefaultMaxValueLen = 4096 // 4Kb
const DefaultMaxWaitees = 1000
const DefaultTxLogCacheSize = 1000
const MaxFileSize = (1 << 31) - 1 // 2Gb
const MaxKeyLen = 1024 // assumed to be not lower than hash size
const MaxParallelIO = 127
const NotificationWindow = 60 * time.Second
const Version = 1
Variables ¶
var ErrAlreadyClosed = errors.New("store already closed")
var ErrCorruptedAHtree = errors.New("appendable hash tree is corrupted")
var ErrCorruptedCLog = errors.New("commit log is corrupted")
var ErrCorruptedData = errors.New("data is corrupted")
var ErrDuplicatedKey = errors.New("duplicated key")
var ErrIllegalArguments = errors.New("illegal arguments")
var ErrIllegalState = tbtree.ErrIllegalState
var ErrKeyNotFound = tbtree.ErrKeyNotFound
var ErrLinearProofMaxLenExceeded = errors.New("max linear proof length limit exceeded")
var ErrMaxConcurrencyLimitExceeded = errors.New("max concurrency limit exceeded")
var ErrNoMoreEntries = tbtree.ErrNoMoreEntries
var ErrNullKey = errors.New("null key")
var ErrSourceTxNewerThanTargetTx = errors.New("source tx is newer than target tx")
var ErrTxNotFound = errors.New("tx not found")
var ErrTxSizeGreaterThanMaxTxSize = errors.New("tx size greater than max tx size")
var ErrUnexpectedLinkingError = errors.New("Internal inconsistency between linear and binary linking")
var ErrorCorruptedTxData = errors.New("tx data is corrupted")
var ErrorMaxKeyLenExceeded = errors.New("max key length exceeded")
var ErrorMaxTxEntriesLimitExceeded = errors.New("max number of entries per tx exceeded")
var ErrorMaxValueLenExceeded = errors.New("max value length exceeded")
var ErrorNoEntriesProvided = errors.New("no entries provided")
var ErrorPathIsNotADirectory = errors.New("path is not a directory")
Functions ¶
func VerifyDualProof ¶
func VerifyInclusion ¶ added in v0.9.0
func VerifyLinearProof ¶
Types ¶
type DualProof ¶
type DualProof struct { SourceTxMetadata *TxMetadata TargetTxMetadata *TxMetadata InclusionProof [][sha256.Size]byte ConsistencyProof [][sha256.Size]byte TargetBlTxAlh [sha256.Size]byte LastInclusionProof [][sha256.Size]byte LinearProof *LinearProof }
type ImmuStore ¶
type ImmuStore struct {
// contains filtered or unexported fields
}
func OpenWith ¶
func OpenWith(path string, vLogs []appendable.Appendable, txLog, cLog appendable.Appendable, opts *Options) (*ImmuStore, error)
func (*ImmuStore) Commit ¶
func (s *ImmuStore) Commit(entries []*KV, waitForIndexing bool) (*TxMetadata, error)
func (*ImmuStore) CommitWith ¶ added in v0.9.1
func (*ImmuStore) CompactIndex ¶ added in v0.9.2
func (*ImmuStore) DualProof ¶
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) 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 (*ImmuStore) MaxIOConcurrency ¶
func (*ImmuStore) MaxLinearProofLen ¶
func (*ImmuStore) MaxTxEntries ¶
func (*ImmuStore) MaxValueLen ¶
func (*ImmuStore) NewKeyReader ¶ added in v0.9.1
func (st *ImmuStore) NewKeyReader(snap *tbtree.Snapshot, spec *tbtree.ReaderSpec) (*KeyReader, error)
NewReader ...
func (*ImmuStore) NewTxReader ¶
func (*ImmuStore) ReadValueAt ¶
func (*ImmuStore) SnapshotSince ¶ added in v0.9.0
func (*ImmuStore) WaitForIndexingUpto ¶ added in v0.9.2
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 KeyReader ¶ added in v0.9.1
type KeyReader struct {
// contains filtered or unexported fields
}
type LinearProof ¶
type NotificationType ¶ added in v0.9.2
type NotificationType = int
const ( Info NotificationType = iota Warn Error )
type Options ¶
type Options struct { ReadOnly bool Synced bool FileMode os.FileMode MaxConcurrency int MaxIOConcurrency int MaxLinearProofLen int TxLogCacheSize int VLogMaxOpenedFiles int TxLogMaxOpenedFiles int CommitLogMaxOpenedFiles int MaxWaitees int // 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) WithCommitLogMaxOpenedFiles ¶
func (*Options) WithCompresionLevel ¶
func (*Options) WithCompressionFormat ¶
func (*Options) WithFileSize ¶
func (*Options) WithIndexOptions ¶
func (opts *Options) WithIndexOptions(indexOptions *IndexOptions) *Options
func (*Options) WithMaxConcurrency ¶
func (*Options) WithMaxIOConcurrency ¶
func (*Options) WithMaxKeyLen ¶
func (*Options) WithMaxLinearProofLen ¶
func (*Options) WithMaxTxEntries ¶
func (*Options) WithMaxValueLen ¶
func (*Options) WithMaxWaitees ¶ added in v0.9.2
func (*Options) WithReadOnly ¶
func (*Options) WithSynced ¶
func (*Options) WithTxLogCacheSize ¶ added in v0.9.2
func (*Options) WithTxLogMaxOpenedFiles ¶
func (*Options) WithVLogMaxOpenedFiles ¶
type Tx ¶
type Tx struct { ID uint64 Ts int64 BlTxID uint64 BlRoot [sha256.Size]byte PrevAlh [sha256.Size]byte Alh [sha256.Size]byte InnerHash [sha256.Size]byte // contains filtered or unexported fields }
func NewTxWithEntries ¶ added in v0.9.0
func (*Tx) BuildHashTree ¶ added in v0.9.0
func (*Tx) CalcAlh ¶ added in v0.9.0
func (tx *Tx) CalcAlh()
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 (*Tx) Metadata ¶ added in v0.9.0
func (tx *Tx) Metadata() *TxMetadata
type TxEntry ¶ added in v0.9.1
type TxEntry struct {
// contains filtered or unexported fields
}