storage

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BlockMetadataSolid         = 0
	BlockMetadataReferenced    = 1
	BlockMetadataNoTx          = 2
	BlockMetadataConflictingTx = 3
	BlockMetadataMilestone     = 4
)
View Source
const (
	// ConflictNone the block has no conflict.
	ConflictNone Conflict = iota

	// ConflictInputUTXOAlreadySpent the referenced UTXO was already spent.
	ConflictInputUTXOAlreadySpent = 1

	// ConflictInputUTXOAlreadySpentInThisMilestone the referenced UTXO was already spent while confirming this milestone.
	ConflictInputUTXOAlreadySpentInThisMilestone = 2

	// ConflictInputUTXONotFound the referenced UTXO cannot be found.
	ConflictInputUTXONotFound = 3

	// ConflictInputOutputSumMismatch the sum of the inputs and output values does not match.
	ConflictInputOutputSumMismatch = 4

	// ConflictInvalidSignature the unlock block signature is invalid.
	ConflictInvalidSignature = 5

	// ConflictTimelockNotExpired the configured timelock is not yet expired.
	ConflictTimelockNotExpired = 6

	// ConflictInvalidNativeTokens the given native tokens are invalid.
	ConflictInvalidNativeTokens = 7

	// ConflictReturnAmountNotFulfilled return amount in a transaction is not fulfilled by the output side.
	ConflictReturnAmountNotFulfilled = 8

	// ConflictInvalidInputUnlock input unlock is invalid.
	ConflictInvalidInputUnlock = 9

	// ConflictInvalidInputsCommitment the inputs commitment is invalid.
	ConflictInvalidInputsCommitment = 10

	// ConflictInvalidSender an output contains a Sender with an ident which is not unlocked.
	ConflictInvalidSender = 11

	// ConflictInvalidChainStateTransition the chain state transition is invalid.
	ConflictInvalidChainStateTransition = 12

	// ConflictSemanticValidationFailed the semantic validation failed.
	ConflictSemanticValidationFailed = 255
)
View Source
const (
	DBVersionTangle byte = 2
	DBVersionUTXO   byte = 2
)
View Source
const (
	MaxProtocolParametersActivationRange uint32 = 30
)

Variables

View Source
var (
	ErrSolidEntryPointsAlreadyInitialized = errors.New("solidEntryPoints already initialized")
	ErrSolidEntryPointsNotInitialized     = errors.New("solidEntryPoints not initialized")
)
View Source
var (
	ErrMilestoneNotFound = errors.New("milestone not found")
)
View Source
var (
	ErrProtocolParamsMilestoneOptAlreadyExists = errors.New("protocol parameters milestone option already exists")
)

Functions

func BlockFactory

func BlockFactory(key []byte, data []byte) (objectstorage.StorableObject, error)

func MetadataFactory

func MetadataFactory(key []byte, data []byte) (objectstorage.StorableObject, error)

func ObjectStorageIteratorOptions

func ObjectStorageIteratorOptions(iteratorOptions ...IteratorOption) []objectstorage.IteratorOption

Types

type Block

type Block struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

func BlockFromBytes

func BlockFromBytes(data []byte, deSeriMode serializer.DeSerializationMode, protoParams *iotago.ProtocolParameters) (*Block, error)

func NewBlock

func NewBlock(iotaBlock *iotago.Block, deSeriMode serializer.DeSerializationMode, protoParams *iotago.ProtocolParameters) (*Block, error)

func (*Block) Block

func (blk *Block) Block() *iotago.Block

func (*Block) BlockID

func (blk *Block) BlockID() iotago.BlockID

func (*Block) Data

func (blk *Block) Data() []byte

func (*Block) IsMilestone

func (blk *Block) IsMilestone() bool

func (*Block) IsTransaction

func (blk *Block) IsTransaction() bool

func (*Block) Milestone

func (blk *Block) Milestone() *iotago.Milestone

func (*Block) ObjectStorageKey

func (blk *Block) ObjectStorageKey() []byte

func (*Block) ObjectStorageValue

func (blk *Block) ObjectStorageValue() []byte

func (*Block) Parents

func (blk *Block) Parents() iotago.BlockIDs

func (*Block) ProtocolVersion

func (blk *Block) ProtocolVersion() byte

func (*Block) TaggedData

func (blk *Block) TaggedData() *iotago.TaggedData

func (*Block) Transaction

func (blk *Block) Transaction() *iotago.Transaction

func (*Block) TransactionEssence

func (blk *Block) TransactionEssence() *iotago.TransactionEssence

func (*Block) TransactionEssenceTaggedData

func (blk *Block) TransactionEssenceTaggedData() *iotago.TaggedData

func (*Block) TransactionEssenceUTXOInputs

func (blk *Block) TransactionEssenceUTXOInputs() iotago.OutputIDs

func (*Block) Update

func (blk *Block) Update(_ objectstorage.StorableObject)

type BlockIDConsumer

type BlockIDConsumer func(blockID iotago.BlockID) bool

BlockIDConsumer consumes the given block ID during looping through all blocks. Returning false from this function indicates to abort the iteration.

type BlockMetadata

type BlockMetadata struct {
	objectstorage.StorableObjectFlags
	syncutils.RWMutex
	// contains filtered or unexported fields
}

func NewBlockMetadata

func NewBlockMetadata(blockID iotago.BlockID, parents iotago.BlockIDs) *BlockMetadata

func (*BlockMetadata) BlockID

func (m *BlockMetadata) BlockID() iotago.BlockID

func (*BlockMetadata) ConeRootIndexes

func (m *BlockMetadata) ConeRootIndexes() (ycri iotago.MilestoneIndex, ocri iotago.MilestoneIndex, ci iotago.MilestoneIndex)

func (*BlockMetadata) Conflict

func (m *BlockMetadata) Conflict() Conflict

func (*BlockMetadata) IsConflictingTx

func (m *BlockMetadata) IsConflictingTx() bool

func (*BlockMetadata) IsIncludedTxInLedger

func (m *BlockMetadata) IsIncludedTxInLedger() bool

func (*BlockMetadata) IsMilestone

func (m *BlockMetadata) IsMilestone() bool

func (*BlockMetadata) IsNoTransaction

func (m *BlockMetadata) IsNoTransaction() bool

func (*BlockMetadata) IsReferenced

func (m *BlockMetadata) IsReferenced() bool

func (*BlockMetadata) IsSolid

func (m *BlockMetadata) IsSolid() bool

func (*BlockMetadata) Metadata

func (m *BlockMetadata) Metadata() byte

func (*BlockMetadata) ObjectStorageKey

func (m *BlockMetadata) ObjectStorageKey() []byte

func (*BlockMetadata) ObjectStorageValue

func (m *BlockMetadata) ObjectStorageValue() (data []byte)

func (*BlockMetadata) Parents

func (m *BlockMetadata) Parents() iotago.BlockIDs

func (*BlockMetadata) ReferencedWithIndex

func (m *BlockMetadata) ReferencedWithIndex() (bool, iotago.MilestoneIndex)

func (*BlockMetadata) ReferencedWithIndexAndWhiteFlagIndex

func (m *BlockMetadata) ReferencedWithIndexAndWhiteFlagIndex() (bool, iotago.MilestoneIndex, uint32)

func (*BlockMetadata) SetConeRootIndexes

func (m *BlockMetadata) SetConeRootIndexes(ycri iotago.MilestoneIndex, ocri iotago.MilestoneIndex, ci iotago.MilestoneIndex)

func (*BlockMetadata) SetConflictingTx

func (m *BlockMetadata) SetConflictingTx(conflict Conflict)

func (*BlockMetadata) SetIsNoTransaction

func (m *BlockMetadata) SetIsNoTransaction(noTx bool)

func (*BlockMetadata) SetMilestone

func (m *BlockMetadata) SetMilestone(milestone bool)

func (*BlockMetadata) SetReferenced

func (m *BlockMetadata) SetReferenced(referenced bool, referencedIndex iotago.MilestoneIndex, whiteFlagIndex uint32)

func (*BlockMetadata) SetSolid

func (m *BlockMetadata) SetSolid(solid bool)

func (*BlockMetadata) Update

type BlocksMemcache

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

func NewBlocksMemcache

func NewBlocksMemcache(cachedBlockFunc CachedBlockFunc) *BlocksMemcache

NewBlocksMemcache creates a new BlocksMemcache instance.

func (*BlocksMemcache) CachedBlock

func (c *BlocksMemcache) CachedBlock(blockID iotago.BlockID) (*CachedBlock, error)

CachedBlock returns a cached block object. block +1.

func (*BlocksMemcache) Cleanup

func (c *BlocksMemcache) Cleanup(forceRelease bool)

Cleanup releases all the cached objects that have been used. This MUST be called by the user at the end.

type CachedBlock

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

CachedBlock contains two cached objects, one for block and one for metadata.

func (*CachedBlock) Block

func (c *CachedBlock) Block() *Block

Block retrieves the block, that is cached in this container.

func (*CachedBlock) CachedMetadata

func (c *CachedBlock) CachedMetadata() *CachedMetadata

CachedMetadata returns the underlying cached metadata. meta +1.

func (*CachedBlock) ConsumeBlock

func (c *CachedBlock) ConsumeBlock(consumer func(*Block))

ConsumeBlock consumes the underlying block. block -1. meta -1.

func (*CachedBlock) ConsumeBlockAndMetadata

func (c *CachedBlock) ConsumeBlockAndMetadata(consumer func(*Block, *BlockMetadata))

ConsumeBlockAndMetadata consumes the underlying block and metadata. block -1. meta -1.

func (*CachedBlock) ConsumeMetadata

func (c *CachedBlock) ConsumeMetadata(consumer func(*BlockMetadata))

ConsumeMetadata consumes the underlying metadata. block -1. meta -1.

func (*CachedBlock) Exists

func (c *CachedBlock) Exists() bool

Exists returns true if the block in this container does exist (could be found in the database and was not marked as deleted).

func (*CachedBlock) Metadata

func (c *CachedBlock) Metadata() *BlockMetadata

Metadata retrieves the metadata, that is cached in this container.

func (*CachedBlock) Release

func (c *CachedBlock) Release(force ...bool)

Release releases the cached block and metadata, to be picked up by the persistence layer (as soon as all consumers are done). block -1.

func (*CachedBlock) Retain

func (c *CachedBlock) Retain() *CachedBlock

Retain registers a new consumer for the cached block and metadata. block +1.

type CachedBlockFunc

type CachedBlockFunc func(blockID iotago.BlockID) (*CachedBlock, error)

type CachedBlockMetadataFunc

type CachedBlockMetadataFunc func(blockID iotago.BlockID) (*CachedMetadata, error)

type CachedBlocks

type CachedBlocks []*CachedBlock

func (CachedBlocks) Release

func (cachedBlocks CachedBlocks) Release(force ...bool)

Release releases the cached blocks, to be picked up by the persistence layer (as soon as all consumers are done). block -1.

func (CachedBlocks) Retain

func (cachedBlocks CachedBlocks) Retain() CachedBlocks

Retain registers a new consumer for the cached blocks. block +1.

type CachedChild

type CachedChild struct {
	objectstorage.CachedObject
}

CachedChild represents a cached Child.

func (*CachedChild) Child

func (c *CachedChild) Child() *Child

Child retrieves the child, that is cached in this container.

func (*CachedChild) Retain

func (c *CachedChild) Retain() *CachedChild

Retain registers a new consumer for the cached child. child +1.

type CachedChildren

type CachedChildren []*CachedChild

func (CachedChildren) Release

func (cachedChildren CachedChildren) Release(force ...bool)

Release releases the cached children, to be picked up by the persistence layer (as soon as all consumers are done).

func (CachedChildren) Retain

func (cachedChildren CachedChildren) Retain() CachedChildren

Retain registers a new consumer for the cached children. child +1.

type CachedMetadata

type CachedMetadata struct {
	objectstorage.CachedObject
}

CachedMetadata contains the cached object only for metadata.

func NewCachedMetadata

func NewCachedMetadata(metadata objectstorage.CachedObject) *CachedMetadata

func (*CachedMetadata) ConsumeMetadata

func (c *CachedMetadata) ConsumeMetadata(consumer func(*BlockMetadata))

ConsumeMetadata consumes the metadata. meta -1.

func (*CachedMetadata) Metadata

func (c *CachedMetadata) Metadata() *BlockMetadata

Metadata retrieves the metadata, that is cached in this container.

func (*CachedMetadata) Retain

func (c *CachedMetadata) Retain() *CachedMetadata

Retain registers a new consumer for the cached metadata. meta +1.

type CachedMilestone

type CachedMilestone struct {
	objectstorage.CachedObject
}

CachedMilestone represents a cached milestone.

func (*CachedMilestone) Milestone

func (c *CachedMilestone) Milestone() *Milestone

Milestone retrieves the milestone, that is cached in this container.

func (*CachedMilestone) Retain

func (c *CachedMilestone) Retain() *CachedMilestone

Retain registers a new consumer for the cached milestone. milestone +1.

type CachedMilestones

type CachedMilestones []*CachedMilestone

func (CachedMilestones) Release

func (c CachedMilestones) Release(force ...bool)

Release releases the cached milestones, to be picked up by the persistence layer (as soon as all consumers are done). milestone -1.

func (CachedMilestones) Retain

Retain registers a new consumer for the cached milestones. milestone +1.

type CachedUnreferencedBlock

type CachedUnreferencedBlock struct {
	objectstorage.CachedObject
}

CachedUnreferencedBlock represents a cached unreferenced block.

func (*CachedUnreferencedBlock) UnreferencedBlock

func (c *CachedUnreferencedBlock) UnreferencedBlock() *UnreferencedBlock

UnreferencedBlock retrieves the unreferenced block, that is cached in this container.

type CachedUnreferencedBlocks

type CachedUnreferencedBlocks []*CachedUnreferencedBlock

func (CachedUnreferencedBlocks) Release

func (cachedUnreferencedBlocks CachedUnreferencedBlocks) Release(force ...bool)

Release releases the cached unreferenced blocks, to be picked up by the persistence layer (as soon as all consumers are done).

type Child

type Child struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

func NewChild

func NewChild(parentBlockID iotago.BlockID, childBlockID iotago.BlockID) *Child

func (*Child) ChildBlockID

func (a *Child) ChildBlockID() iotago.BlockID

func (*Child) ObjectStorageKey

func (a *Child) ObjectStorageKey() []byte

func (*Child) ObjectStorageValue

func (a *Child) ObjectStorageValue() []byte

func (*Child) ParentBlockID

func (a *Child) ParentBlockID() iotago.BlockID

func (*Child) Update

func (a *Child) Update(_ objectstorage.StorableObject)

type ChildConsumer

type ChildConsumer func(blockID iotago.BlockID, childBlockID iotago.BlockID) bool

ChildConsumer consumes the given child during looping through all children. Returning false from this function indicates to abort the iteration.

type Conflict

type Conflict uint8

Conflict defines the reason why a block is marked as conflicting.

func ConflictFromSemanticValidationError

func ConflictFromSemanticValidationError(err error) Conflict

type ErrDatabaseError

type ErrDatabaseError struct {
	Inner error
}

func NewDatabaseError

func NewDatabaseError(cause error) *ErrDatabaseError

func (ErrDatabaseError) Cause

func (e ErrDatabaseError) Cause() error

func (ErrDatabaseError) Error

func (e ErrDatabaseError) Error() string

type IteratorOption

type IteratorOption func(opts *IteratorOptions)

IteratorOption is a function setting an iterator option.

func WithIteratorMaxIterations

func WithIteratorMaxIterations(maxIterations int) IteratorOption

WithIteratorMaxIterations is used to stop the iteration after a certain amount of iterations. 0 disables the limit.

func WithIteratorPrefix

func WithIteratorPrefix(prefix []byte) IteratorOption

WithIteratorPrefix is used to iterate a subset of elements with a defined prefix.

type IteratorOptions

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

IteratorOptions define options for iterations in the object storage.

type LexicalOrderedSolidEntryPoints

type LexicalOrderedSolidEntryPoints []*SolidEntryPoint

LexicalOrderedSolidEntryPoints are solid entry points ordered in lexical order by their BlockID.

func (LexicalOrderedSolidEntryPoints) Len

func (LexicalOrderedSolidEntryPoints) Less

func (LexicalOrderedSolidEntryPoints) Swap

func (l LexicalOrderedSolidEntryPoints) Swap(i, j int)

type MetadataMemcache

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

func NewMetadataMemcache

func NewMetadataMemcache(cachedBlockMetadataFunc CachedBlockMetadataFunc) *MetadataMemcache

NewMetadataMemcache creates a new NewMetadataMemcache instance.

func (*MetadataMemcache) CachedBlockMetadata

func (c *MetadataMemcache) CachedBlockMetadata(blockID iotago.BlockID) (*CachedMetadata, error)

CachedBlockMetadata returns a cached metadata object. meta +1.

func (*MetadataMemcache) Cleanup

func (c *MetadataMemcache) Cleanup(forceRelease bool)

Cleanup releases all the cached objects that have been used. This MUST be called by the user at the end.

type Milestone

type Milestone struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

func NewMilestone

func NewMilestone(milestonePayload *iotago.Milestone, deSeriMode serializer.DeSerializationMode, milestoneID ...iotago.MilestoneID) (*Milestone, error)

func (*Milestone) Data

func (ms *Milestone) Data() []byte

func (*Milestone) Index

func (ms *Milestone) Index() iotago.MilestoneIndex

func (*Milestone) Milestone

func (ms *Milestone) Milestone() *iotago.Milestone

func (*Milestone) MilestoneID

func (ms *Milestone) MilestoneID() iotago.MilestoneID

func (*Milestone) MilestoneIDHex

func (ms *Milestone) MilestoneIDHex() string

func (*Milestone) ObjectStorageKey

func (ms *Milestone) ObjectStorageKey() []byte

func (*Milestone) ObjectStorageValue

func (ms *Milestone) ObjectStorageValue() []byte

func (*Milestone) Parents

func (ms *Milestone) Parents() iotago.BlockIDs

func (*Milestone) Timestamp

func (ms *Milestone) Timestamp() time.Time

func (*Milestone) TimestampUnix

func (ms *Milestone) TimestampUnix() uint32

func (*Milestone) Update

func (ms *Milestone) Update(_ objectstorage.StorableObject)

type MilestoneIndex

type MilestoneIndex struct {
	objectstorage.StorableObjectFlags

	Index iotago.MilestoneIndex
	// contains filtered or unexported fields
}

func NewMilestoneIndex

func NewMilestoneIndex(milestonePayload *iotago.Milestone, milestoneID ...iotago.MilestoneID) (*MilestoneIndex, error)

func (*MilestoneIndex) MilestoneID

func (ms *MilestoneIndex) MilestoneID() iotago.MilestoneID

func (*MilestoneIndex) ObjectStorageKey

func (ms *MilestoneIndex) ObjectStorageKey() []byte

func (*MilestoneIndex) ObjectStorageValue

func (ms *MilestoneIndex) ObjectStorageValue() (data []byte)

func (*MilestoneIndex) Update

type MilestoneIndexConsumer

type MilestoneIndexConsumer func(index iotago.MilestoneIndex) bool

MilestoneIndexConsumer consumes the given index during looping through all milestones. Returning false from this function indicates to abort the iteration.

type NonCachedStorage

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

NonCachedStorage is a Storage without a cache.

func (*NonCachedStorage) ForEachBlockID

func (ns *NonCachedStorage) ForEachBlockID(consumer BlockIDConsumer, iteratorOptions ...IteratorOption)

ForEachBlockID loops over all block IDs.

func (*NonCachedStorage) ForEachBlockMetadataBlockID

func (ns *NonCachedStorage) ForEachBlockMetadataBlockID(consumer BlockIDConsumer, iteratorOptions ...IteratorOption)

ForEachBlockMetadataBlockID loops over all block metadata block IDs.

func (*NonCachedStorage) ForEachChild

func (ns *NonCachedStorage) ForEachChild(consumer ChildConsumer, iteratorOptions ...IteratorOption)

ForEachChild loops over all children.

func (*NonCachedStorage) ForEachMilestoneIndex

func (ns *NonCachedStorage) ForEachMilestoneIndex(consumer MilestoneIndexConsumer, iteratorOptions ...IteratorOption)

ForEachMilestoneIndex loops through all milestones.

func (*NonCachedStorage) ForEachUnreferencedBlock

func (ns *NonCachedStorage) ForEachUnreferencedBlock(consumer UnreferencedBlockConsumer, iteratorOptions ...IteratorOption)

ForEachUnreferencedBlock loops over all unreferenced blocks.

type ProtocolParamsMilestoneOptConsumer

type ProtocolParamsMilestoneOptConsumer func(*iotago.ProtocolParamsMilestoneOpt) bool

ProtocolParamsMilestoneOptConsumer consumes the given ProtocolParamsMilestoneOpt. Returning false from this function indicates to abort the iteration.

type ProtocolStorage

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

func NewProtocolStorage

func NewProtocolStorage(protocolStore kvstore.KVStore) *ProtocolStorage

func (*ProtocolStorage) ActiveProtocolParameterMilestoneOptionsHash

func (s *ProtocolStorage) ActiveProtocolParameterMilestoneOptionsHash(msIndex iotago.MilestoneIndex) ([]byte, error)

func (*ProtocolStorage) ForEachActiveProtocolParameterMilestoneOption

func (s *ProtocolStorage) ForEachActiveProtocolParameterMilestoneOption(msIndex iotago.MilestoneIndex, consumer ProtocolParamsMilestoneOptConsumer) error

func (*ProtocolStorage) ForEachProtocolParameterMilestoneOption

func (s *ProtocolStorage) ForEachProtocolParameterMilestoneOption(consumer ProtocolParamsMilestoneOptConsumer) error

func (*ProtocolStorage) ProtocolParameters

func (s *ProtocolStorage) ProtocolParameters(msIndex iotago.MilestoneIndex) (*iotago.ProtocolParameters, error)

func (*ProtocolStorage) ProtocolParametersMilestoneOption

func (s *ProtocolStorage) ProtocolParametersMilestoneOption(msIndex iotago.MilestoneIndex) (*iotago.ProtocolParamsMilestoneOpt, error)

func (*ProtocolStorage) PruneProtocolParameterMilestoneOptions

func (s *ProtocolStorage) PruneProtocolParameterMilestoneOptions(pruningIndex iotago.MilestoneIndex) error

func (*ProtocolStorage) StoreProtocolParametersMilestoneOption

func (s *ProtocolStorage) StoreProtocolParametersMilestoneOption(protoParamsMsOption *iotago.ProtocolParamsMilestoneOpt) error

type ReadOption

type ReadOption = objectstorage.ReadOption

type SnapshotInfo

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

func (*SnapshotInfo) Deserialize

func (i *SnapshotInfo) Deserialize(data []byte, _ serializer.DeSerializationMode, _ interface{}) (int, error)

func (*SnapshotInfo) EntryPointIndex

func (i *SnapshotInfo) EntryPointIndex() iotago.MilestoneIndex

EntryPointIndex returns the index of the milestone of which the SEPs within the database are from.

func (*SnapshotInfo) GenesisMilestoneIndex

func (i *SnapshotInfo) GenesisMilestoneIndex() iotago.MilestoneIndex

GenesisMilestoneIndex returns the index of the genesis milestone of the network.

func (*SnapshotInfo) PruningIndex

func (i *SnapshotInfo) PruningIndex() iotago.MilestoneIndex

PruningIndex returns the index of the milestone before which the tangle history is pruned. This is not the same as EntryPointIndex, so we can cleanly prune again even if the pruning was aborted last time.

func (*SnapshotInfo) Serialize

func (i *SnapshotInfo) Serialize(_ serializer.DeSerializationMode, _ interface{}) ([]byte, error)

func (*SnapshotInfo) SnapshotIndex

func (i *SnapshotInfo) SnapshotIndex() iotago.MilestoneIndex

SnapshotIndex returns the index of the snapshot file.

func (*SnapshotInfo) SnapshotTimestamp

func (i *SnapshotInfo) SnapshotTimestamp() time.Time

SnapshotTimestamp returns the timestamp of the target milestone of the snapshot.

type SolidEntryPoint

type SolidEntryPoint struct {
	BlockID iotago.BlockID
	Index   iotago.MilestoneIndex
}

type SolidEntryPointConsumer

type SolidEntryPointConsumer func(solidEntryPoint *SolidEntryPoint) bool

SolidEntryPointConsumer consumes the solid entry point during looping through all solid entry points. Returning false from this function indicates to abort the iteration.

type SolidEntryPoints

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

func NewSolidEntryPoints

func NewSolidEntryPoints() *SolidEntryPoints

func SolidEntryPointsFromBytes

func SolidEntryPointsFromBytes(solidEntryPointsBytes []byte) (*SolidEntryPoints, error)

func (*SolidEntryPoints) Add

func (s *SolidEntryPoints) Add(blockID iotago.BlockID, milestoneIndex iotago.MilestoneIndex)

func (*SolidEntryPoints) Bytes

func (s *SolidEntryPoints) Bytes() []byte

func (*SolidEntryPoints) Clear

func (s *SolidEntryPoints) Clear()

func (*SolidEntryPoints) Contains

func (s *SolidEntryPoints) Contains(blockID iotago.BlockID) bool

func (*SolidEntryPoints) Index

func (*SolidEntryPoints) IsModified

func (s *SolidEntryPoints) IsModified() bool

func (*SolidEntryPoints) SHA256Sum

func (s *SolidEntryPoints) SHA256Sum() ([]byte, error)

func (*SolidEntryPoints) SetModified

func (s *SolidEntryPoints) SetModified(modified bool)

func (*SolidEntryPoints) Sorted

func (s *SolidEntryPoints) Sorted() []*SolidEntryPoint

Sorted sorts the solid entry points lexicographically by their BlockID.

type Storage

type Storage struct {
	*ProtocolStorage

	// events
	Events *packageEvents
	// contains filtered or unexported fields
}

Storage is the access layer to the node databases (partially cached).

func New

func New(tangleStore kvstore.KVStore, utxoStore kvstore.KVStore, cachesProfile ...*profile.Caches) (*Storage, error)

func (*Storage) AreStoresCorrupted

func (s *Storage) AreStoresCorrupted() (bool, error)

func (*Storage) AreStoresTainted

func (s *Storage) AreStoresTainted() (bool, error)

func (*Storage) Block

func (s *Storage) Block(blockID iotago.BlockID) (*iotago.Block, error)

Block returns an iotago block object.

func (*Storage) BlockExistsInStore

func (s *Storage) BlockExistsInStore(blockID iotago.BlockID) bool

BlockExistsInStore returns if the given block exists in the persistence layer.

func (*Storage) BlockMetadataExistsInStore

func (s *Storage) BlockMetadataExistsInStore(blockID iotago.BlockID) bool

BlockMetadataExistsInStore returns if the given block metadata exists in the persistence layer.

func (*Storage) BlockMetadataStorageSize

func (s *Storage) BlockMetadataStorageSize() int

func (*Storage) BlockStorageSize

func (s *Storage) BlockStorageSize() int

func (*Storage) CachedBlock

func (s *Storage) CachedBlock(blockID iotago.BlockID) (*CachedBlock, error)

CachedBlock returns a cached block object. block +1.

func (*Storage) CachedBlockMetadata

func (s *Storage) CachedBlockMetadata(blockID iotago.BlockID) (*CachedMetadata, error)

CachedBlockMetadata returns a cached metadata object. meta +1.

func (*Storage) CachedBlockMetadataOrNil

func (s *Storage) CachedBlockMetadataOrNil(blockID iotago.BlockID) *CachedMetadata

CachedBlockMetadataOrNil returns a cached metadata object. meta +1.

func (*Storage) CachedBlockOrNil

func (s *Storage) CachedBlockOrNil(blockID iotago.BlockID) *CachedBlock

CachedBlockOrNil returns a cached block object. block +1.

func (*Storage) CachedChildrenOfBlockID

func (s *Storage) CachedChildrenOfBlockID(blockID iotago.BlockID, iteratorOptions ...IteratorOption) CachedChildren

CachedChildrenOfBlockID returns the cached children of a block. children +1.

func (*Storage) CachedMilestoneByIndexOrNil

func (s *Storage) CachedMilestoneByIndexOrNil(milestoneIndex iotago.MilestoneIndex) *CachedMilestone

CachedMilestoneByIndexOrNil returns a cached milestone object. milestone +1.

func (*Storage) CachedMilestoneOrNil

func (s *Storage) CachedMilestoneOrNil(milestoneID iotago.MilestoneID) *CachedMilestone

CachedMilestoneOrNil returns a cached milestone object. milestone +1.

func (*Storage) CheckCorrectStoresVersion

func (s *Storage) CheckCorrectStoresVersion() (bool, error)

func (*Storage) CheckLedgerState

func (s *Storage) CheckLedgerState() error

CheckLedgerState checks if the total balance of the ledger fits the token supply in the protocol parameters.

func (*Storage) ChildrenBlockIDs

func (s *Storage) ChildrenBlockIDs(blockID iotago.BlockID, iteratorOptions ...IteratorOption) (iotago.BlockIDs, error)

ChildrenBlockIDs returns the block IDs of the children of the given block. children +-0.

func (*Storage) ChildrenStorageSize

func (s *Storage) ChildrenStorageSize() int

func (*Storage) ContainsBlock

func (s *Storage) ContainsBlock(blockID iotago.BlockID, readOptions ...ReadOption) bool

ContainsBlock returns if the given block exists in the cache/persistence layer.

func (*Storage) ContainsChild

func (s *Storage) ContainsChild(blockID iotago.BlockID, childBlockID iotago.BlockID, readOptions ...ReadOption) bool

ContainsChild returns if the given child exists in the cache/persistence layer.

func (*Storage) ContainsMilestoneIndex

func (s *Storage) ContainsMilestoneIndex(milestoneIndex iotago.MilestoneIndex, readOptions ...ReadOption) bool

ContainsMilestoneIndex returns if the given milestone exists in the cache/persistence layer.

func (*Storage) CurrentProtocolParameters

func (s *Storage) CurrentProtocolParameters() (*iotago.ProtocolParameters, error)

func (*Storage) DeleteBlock

func (s *Storage) DeleteBlock(blockID iotago.BlockID)

DeleteBlock deletes the block and metadata in the cache/persistence layer.

func (*Storage) DeleteBlockMetadata

func (s *Storage) DeleteBlockMetadata(blockID iotago.BlockID)

DeleteBlockMetadata deletes the metadata in the cache/persistence layer.

func (*Storage) DeleteChild

func (s *Storage) DeleteChild(blockID iotago.BlockID, childBlockID iotago.BlockID)

DeleteChild deletes the child in the cache/persistence layer. child +-0.

func (*Storage) DeleteChildren

func (s *Storage) DeleteChildren(blockID iotago.BlockID, iteratorOptions ...IteratorOption)

DeleteChildren deletes the children of the given block in the cache/persistence layer. child +-0.

func (*Storage) DeleteMilestone

func (s *Storage) DeleteMilestone(milestoneIndex iotago.MilestoneIndex)

DeleteMilestone deletes the milestone in the cache/persistence layer.

func (*Storage) DeleteUnreferencedBlocks

func (s *Storage) DeleteUnreferencedBlocks(msIndex iotago.MilestoneIndex, iteratorOptions ...IteratorOption) int

DeleteUnreferencedBlocks deletes unreferenced block entries in the cache/persistence layer.

func (*Storage) FlushAndCloseStores

func (s *Storage) FlushAndCloseStores() error

func (*Storage) FlushBlocksStorage

func (s *Storage) FlushBlocksStorage()

FlushBlocksStorage flushes the blocks storage.

func (*Storage) FlushChildrenStorage

func (s *Storage) FlushChildrenStorage()

FlushChildrenStorage flushes the children storage.

func (*Storage) FlushMilestoneStorage

func (s *Storage) FlushMilestoneStorage()

FlushMilestoneStorage flushes the milestones storage.

func (*Storage) FlushStorages

func (s *Storage) FlushStorages()

FlushStorages flushes all storages.

func (*Storage) FlushUnreferencedBlocksStorage

func (s *Storage) FlushUnreferencedBlocksStorage()

FlushUnreferencedBlocksStorage flushes the unreferenced blocks storage.

func (*Storage) ForEachBlockID

func (s *Storage) ForEachBlockID(consumer BlockIDConsumer, iteratorOptions ...IteratorOption)

ForEachBlockID loops over all block IDs.

func (*Storage) ForEachBlockMetadataBlockID

func (s *Storage) ForEachBlockMetadataBlockID(consumer BlockIDConsumer, iteratorOptions ...IteratorOption)

ForEachBlockMetadataBlockID loops over all block metadata block IDs.

func (*Storage) ForEachChild

func (s *Storage) ForEachChild(consumer ChildConsumer, iteratorOptions ...IteratorOption)

ForEachChild loops over all children.

func (*Storage) ForEachMilestoneIndex

func (s *Storage) ForEachMilestoneIndex(consumer MilestoneIndexConsumer, iteratorOptions ...IteratorOption)

ForEachMilestoneIndex loops through all milestones.

func (*Storage) ForEachSolidEntryPointWithoutLocking

func (s *Storage) ForEachSolidEntryPointWithoutLocking(consumer SolidEntryPointConsumer)

ForEachSolidEntryPointWithoutLocking loops over all solid entry points in the persistence layer. WriteLockSolidEntryPoints must be held while entering this function.

func (*Storage) ForEachUnreferencedBlock

func (s *Storage) ForEachUnreferencedBlock(consumer UnreferencedBlockConsumer, iteratorOptions ...IteratorOption)

ForEachUnreferencedBlock loops over all unreferenced blocks.

func (*Storage) MarkStoresCorrupted

func (s *Storage) MarkStoresCorrupted() error

func (*Storage) MarkStoresHealthy

func (s *Storage) MarkStoresHealthy() error

func (*Storage) MarkStoresTainted

func (s *Storage) MarkStoresTainted() error

func (*Storage) MilestoneParentsByIndex

func (s *Storage) MilestoneParentsByIndex(milestoneIndex iotago.MilestoneIndex) (iotago.BlockIDs, error)

MilestoneParentsByIndex returns the parents of a milestone.

func (*Storage) MilestoneStorageSize

func (s *Storage) MilestoneStorageSize() int

MilestoneStorageSize returns the size of the milestone storage.

func (*Storage) MilestoneTimestampByIndex

func (s *Storage) MilestoneTimestampByIndex(milestoneIndex iotago.MilestoneIndex) (time.Time, error)

MilestoneTimestampByIndex returns the timestamp of a milestone.

func (*Storage) MilestoneTimestampUnixByIndex

func (s *Storage) MilestoneTimestampUnixByIndex(milestoneIndex iotago.MilestoneIndex) (uint32, error)

MilestoneTimestampUnixByIndex returns the unix timestamp of a milestone.

func (*Storage) NonCachedStorage

func (s *Storage) NonCachedStorage() *NonCachedStorage

func (*Storage) PrintSnapshotInfo

func (s *Storage) PrintSnapshotInfo()

func (*Storage) ReadLockSolidEntryPoints

func (s *Storage) ReadLockSolidEntryPoints()

func (*Storage) ReadUnlockSolidEntryPoints

func (s *Storage) ReadUnlockSolidEntryPoints()

func (*Storage) ResetSolidEntryPointsWithoutLocking

func (s *Storage) ResetSolidEntryPointsWithoutLocking()

ResetSolidEntryPointsWithoutLocking resets the solid entry points. WriteLockSolidEntryPoints must be held while entering this function.

func (*Storage) SearchLatestMilestoneIndexInStore

func (s *Storage) SearchLatestMilestoneIndexInStore() iotago.MilestoneIndex

SearchLatestMilestoneIndexInStore searches the latest milestone without accessing the cache layer.

func (*Storage) SetEntryPointIndex

func (s *Storage) SetEntryPointIndex(entryPointIndex iotago.MilestoneIndex) error

func (*Storage) SetInitialSnapshotInfo

func (s *Storage) SetInitialSnapshotInfo(genesisMilestoneIndex iotago.MilestoneIndex, snapshotIndex iotago.MilestoneIndex, entryPointIndex iotago.MilestoneIndex, pruningIndex iotago.MilestoneIndex, snapshotTimestamp time.Time) error

func (*Storage) SetPruningIndex

func (s *Storage) SetPruningIndex(pruningIndex iotago.MilestoneIndex) error

func (*Storage) SetSnapshotIndex

func (s *Storage) SetSnapshotIndex(snapshotIndex iotago.MilestoneIndex, snapshotTimestamp time.Time) error

func (*Storage) Shutdown

func (s *Storage) Shutdown() error

Shutdown flushes and closes all object storages, and then flushes and closes all stores.

func (*Storage) ShutdownBlocksStorage

func (s *Storage) ShutdownBlocksStorage()

ShutdownBlocksStorage shuts down the blocks storage.

func (*Storage) ShutdownChildrenStorage

func (s *Storage) ShutdownChildrenStorage()

ShutdownChildrenStorage shuts down the children storage.

func (*Storage) ShutdownMilestoneStorage

func (s *Storage) ShutdownMilestoneStorage()

ShutdownMilestoneStorage shuts down milestones storage.

func (*Storage) ShutdownStorages

func (s *Storage) ShutdownStorages()

ShutdownStorages shuts down all storages.

func (*Storage) ShutdownUnreferencedBlocksStorage

func (s *Storage) ShutdownUnreferencedBlocksStorage()

ShutdownUnreferencedBlocksStorage shuts down the unreferenced blocks storage.

func (*Storage) SnapshotInfo

func (s *Storage) SnapshotInfo() *SnapshotInfo

func (*Storage) SolidEntryPoints

func (s *Storage) SolidEntryPoints() *SolidEntryPoints

func (*Storage) SolidEntryPointsAddWithoutLocking

func (s *Storage) SolidEntryPointsAddWithoutLocking(blockID iotago.BlockID, milestoneIndex iotago.MilestoneIndex)

SolidEntryPointsAddWithoutLocking adds a block to the solid entry points. WriteLockSolidEntryPoints must be held while entering this function.

func (*Storage) SolidEntryPointsContain

func (s *Storage) SolidEntryPointsContain(blockID iotago.BlockID) (bool, error)

func (*Storage) SolidEntryPointsIndex

func (s *Storage) SolidEntryPointsIndex(blockID iotago.BlockID) (iotago.MilestoneIndex, bool, error)

SolidEntryPointsIndex returns the index of a solid entry point and whether the block is a solid entry point or not.

func (*Storage) StoreBlockIfAbsent

func (s *Storage) StoreBlockIfAbsent(block *Block) (cachedBlock *CachedBlock, newlyAdded bool)

StoreBlockIfAbsent returns a cached object and stores the block in the persistence layer if it was absent. block +1.

func (*Storage) StoreChild

func (s *Storage) StoreChild(parentBlockID iotago.BlockID, childBlockID iotago.BlockID) *CachedChild

StoreChild stores the child in the persistence layer and returns a cached object. child +1.

func (*Storage) StoreMilestoneIfAbsent

func (s *Storage) StoreMilestoneIfAbsent(milestonePayload *iotago.Milestone) (cachedMilestone *CachedMilestone, newlyAdded bool)

StoreMilestoneIfAbsent stores a milestone if it is not known yet. milestone +1.

func (*Storage) StoreSolidEntryPointsWithoutLocking

func (s *Storage) StoreSolidEntryPointsWithoutLocking() error

StoreSolidEntryPointsWithoutLocking stores the solid entry points in the persistence layer. WriteLockSolidEntryPoints must be held while entering this function.

func (*Storage) StoreUnreferencedBlock

func (s *Storage) StoreUnreferencedBlock(msIndex iotago.MilestoneIndex, blockID iotago.BlockID) *CachedUnreferencedBlock

StoreUnreferencedBlock stores the unreferenced block in the persistence layer and returns a cached object. unreferencedBlock +1.

func (*Storage) StoredMetadataOrNil

func (s *Storage) StoredMetadataOrNil(blockID iotago.BlockID) *BlockMetadata

StoredMetadataOrNil returns a metadata object without accessing the cache layer.

func (*Storage) TangleStore

func (s *Storage) TangleStore() kvstore.KVStore

func (*Storage) UTXOManager

func (s *Storage) UTXOManager() *utxo.Manager

func (*Storage) UTXOStore

func (s *Storage) UTXOStore() kvstore.KVStore

func (*Storage) UnreferencedBlockIDs

func (s *Storage) UnreferencedBlockIDs(msIndex iotago.MilestoneIndex, iteratorOptions ...IteratorOption) iotago.BlockIDs

UnreferencedBlockIDs returns all block IDs of unreferenced blocks for that milestone.

func (*Storage) UnreferencedBlocksStorageSize

func (s *Storage) UnreferencedBlocksStorageSize() int

func (*Storage) UpdateSnapshotInfo

func (s *Storage) UpdateSnapshotInfo(snapshotIndex iotago.MilestoneIndex, entryPointIndex iotago.MilestoneIndex, pruningIndex iotago.MilestoneIndex, snapshotTimestamp time.Time) error

func (*Storage) UpdateStoresVersion

func (s *Storage) UpdateStoresVersion() (bool, error)

UpdateStoresVersion tries to migrate the existing data to the new store version.

func (*Storage) WriteLockSolidEntryPoints

func (s *Storage) WriteLockSolidEntryPoints()

func (*Storage) WriteUnlockSolidEntryPoints

func (s *Storage) WriteUnlockSolidEntryPoints()

type UnreferencedBlock

type UnreferencedBlock struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

func NewUnreferencedBlock

func NewUnreferencedBlock(msIndex iotago.MilestoneIndex, blockID iotago.BlockID) *UnreferencedBlock

func (*UnreferencedBlock) BlockID

func (t *UnreferencedBlock) BlockID() iotago.BlockID

func (*UnreferencedBlock) LatestMilestoneIndex

func (t *UnreferencedBlock) LatestMilestoneIndex() iotago.MilestoneIndex

func (*UnreferencedBlock) ObjectStorageKey

func (t *UnreferencedBlock) ObjectStorageKey() []byte

func (*UnreferencedBlock) ObjectStorageValue

func (t *UnreferencedBlock) ObjectStorageValue() []byte

func (*UnreferencedBlock) Update

type UnreferencedBlockConsumer

type UnreferencedBlockConsumer func(msIndex iotago.MilestoneIndex, blockID iotago.BlockID) bool

UnreferencedBlockConsumer consumes the given unreferenced block during looping through all unreferenced blocks. Returning false from this function indicates to abort the iteration.

Jump to

Keyboard shortcuts

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