database

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetadataSolid                = 0
	MetadataValid                = 1
	MetadataConfirmed            = 2
	MetadataIsMilestone          = 3
	MetadataIsValueSpam          = 4
	MetadataValidStrictSemantics = 5
	MetadataConflicting          = 6
	MetadataInvalidPastCone      = 7
)
View Source
const (
	StorePrefixHealth                  byte = 0
	StorePrefixTransactions            byte = 1
	StorePrefixTransactionMetadata     byte = 2
	StorePrefixBundleTransactions      byte = 3
	StorePrefixBundles                 byte = 4
	StorePrefixAddresses               byte = 5
	StorePrefixMilestones              byte = 6
	StorePrefixLedgerState             byte = 7
	StorePrefixLedgerBalance           byte = 8
	StorePrefixLedgerDiff              byte = 9
	StorePrefixApprovers               byte = 10
	StorePrefixTags                    byte = 11
	StorePrefixSnapshot                byte = 12
	StorePrefixSnapshotLedger          byte = 13 // unused
	StorePrefixUnconfirmedTransactions byte = 14 // unused
	StorePrefixSpentAddresses          byte = 15
	StorePrefixAutopeering             byte = 16 // unused
	StorePrefixWhiteFlag               byte = 17 // unused
)
View Source
const (
	TransactionMetadataSolid       = 0
	TransactionMetadataConfirmed   = 1
	TransactionMetadataConflicting = 2
	TransactionMetadataIsHead      = 3
	TransactionMetadataIsTail      = 4
	TransactionMetadataIsValue     = 5
	TransactionMetadataIsMilestone = 6

	// metadata, confirmationIndex, trunkHash, branchHash, bundleHash, milestoneIndex.
	TransactionMetadataSize = 1 + milestone.IndexByteSize + hornet.HashSize + hornet.HashSize + hornet.HashSize + milestone.IndexByteSize
)
View Source
const (
	AddressTxIsValue = 1
)
View Source
const (
	BundleTxIsTail = 1
)
View Source
const (
	DBVersion = 3
)
View Source
const (
	SnapshotMetadataSpentAddressesEnabled = 0
)

Variables

View Source
var (
	// ErrOperationAborted is returned when the operation was aborted e.g. by a shutdown signal.
	ErrOperationAborted = ierrors.New("operation was aborted")
)

Functions

This section is empty.

Types

type Bundle

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

func (*Bundle) Head

func (bundle *Bundle) Head() *Transaction

func (*Bundle) IsMilestone

func (bundle *Bundle) IsMilestone() bool

func (*Bundle) IsValid

func (bundle *Bundle) IsValid() bool

func (*Bundle) IsValueSpam

func (bundle *Bundle) IsValueSpam() bool

func (*Bundle) LedgerChanges

func (bundle *Bundle) LedgerChanges() map[string]int64

func (*Bundle) MilestoneHash

func (bundle *Bundle) MilestoneHash() hornet.Hash

func (*Bundle) MilestoneIndex

func (bundle *Bundle) MilestoneIndex() milestone.Index

func (*Bundle) Tail

func (bundle *Bundle) Tail() *Transaction

func (*Bundle) TailHash

func (bundle *Bundle) TailHash() hornet.Hash

func (*Bundle) Transactions

func (bundle *Bundle) Transactions() []*Transaction

func (*Bundle) Unmarshal

func (bundle *Bundle) Unmarshal(data []byte) error

type Bundles

type Bundles []*Bundle

type Database

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

func New

func New(ctx context.Context, log *logger.Logger, tangleDatabasePath string, snapshotDatabasePath string, spentDatabasePath string, skipHealthCheck bool) (*Database, error)

func (*Database) ApproverHashes

func (db *Database) ApproverHashes(txHash hornet.Hash, maxFind ...int) hornet.Hashes

func (*Database) BalanceForAddress

func (db *Database) BalanceForAddress(address hornet.Hash) (uint64, milestone.Index, error)

func (*Database) BundleOrNil

func (db *Database) BundleOrNil(tailTxHash hornet.Hash) *Bundle

func (*Database) BundleTransactionHashes

func (db *Database) BundleTransactionHashes(bundleHash hornet.Hash, maxFind ...int) hornet.Hashes

func (*Database) CloseDatabases

func (db *Database) CloseDatabases() error

func (*Database) ContainsAddress

func (db *Database) ContainsAddress(address hornet.Hash, txHash hornet.Hash, valueOnly bool) bool

ContainsAddress returns if the given address exists in the cache/persistence layer.

func (*Database) ContainsApprover

func (db *Database) ContainsApprover(txHash hornet.Hash, approverHash hornet.Hash) bool

ContainsApprover returns if the given approver exists in the cache/persistence layer.

func (*Database) ContainsTag

func (db *Database) ContainsTag(txTag hornet.Hash, txHash hornet.Hash) bool

ContainsTag returns if the given tag exists in the cache/persistence layer.

func (*Database) LatestSolidMilestoneBundle

func (db *Database) LatestSolidMilestoneBundle() *Bundle

LatestSolidMilestoneBundle returns the latest solid milestone bundle.

func (*Database) LatestSyncState

func (db *Database) LatestSyncState() *SyncState

func (*Database) LedgerDiffForMilestone

func (db *Database) LedgerDiffForMilestone(ctx context.Context, targetIndex milestone.Index) (map[string]int64, error)

LedgerDiffForMilestone returns the ledger changes of that specific milestone.

func (*Database) LedgerIndex

func (db *Database) LedgerIndex() milestone.Index

func (*Database) LedgerStateForLSMI

func (db *Database) LedgerStateForLSMI(ctx context.Context) (map[string]uint64, milestone.Index, error)

LedgerStateForLSMI returns all balances for the current solid milestone.

func (*Database) LedgerStateForMilestone

func (db *Database) LedgerStateForMilestone(ctx context.Context, targetIndex milestone.Index) (map[string]uint64, milestone.Index, error)

func (*Database) MilestoneBundleOrNil

func (db *Database) MilestoneBundleOrNil(milestoneIndex milestone.Index) *Bundle

MilestoneBundleOrNil returns the Bundle of a milestone index or nil if it doesn't exist.

func (*Database) MilestoneOrNil

func (db *Database) MilestoneOrNil(milestoneIndex milestone.Index) *Milestone

func (*Database) MilestoneTimestamp

func (db *Database) MilestoneTimestamp(milestoneIndex milestone.Index) (uint64, error)

MilestoneTimestamp returns the timestamp of a milestone.

func (*Database) SolidEntryPointsContain

func (db *Database) SolidEntryPointsContain(txHash hornet.Hash) bool

func (*Database) SolidMilestoneIndex

func (db *Database) SolidMilestoneIndex() milestone.Index

SolidMilestoneIndex returns the latest solid milestone index.

func (*Database) TagHashes

func (db *Database) TagHashes(txTag hornet.Hash, maxFind ...int) hornet.Hashes

func (*Database) TransactionHashesForAddress

func (db *Database) TransactionHashesForAddress(address hornet.Hash, valueOnly bool, maxFind ...int) hornet.Hashes

func (*Database) TransactionOrNil

func (db *Database) TransactionOrNil(txHash hornet.Hash) *Transaction

func (*Database) TxMetadataOrNil

func (db *Database) TxMetadataOrNil(txHash hornet.Hash) *TransactionMetadata

func (*Database) WasAddressSpentFrom

func (db *Database) WasAddressSpentFrom(address hornet.Hash) bool

type Milestone

type Milestone struct {
	Index milestone.Index
	Hash  hornet.Hash
}

type SnapshotInfo

type SnapshotInfo struct {
	CoordinatorAddress hornet.Hash
	Hash               hornet.Hash
	SnapshotIndex      milestone.Index
	EntryPointIndex    milestone.Index
	PruningIndex       milestone.Index
	Timestamp          int64
	Metadata           bitmask.BitMask
}

func (*SnapshotInfo) IsSpentAddressesEnabled

func (i *SnapshotInfo) IsSpentAddressesEnabled() bool

type SolidEntryPoints

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

func (*SolidEntryPoints) Add

func (s *SolidEntryPoints) Add(txHash hornet.Hash, milestoneIndex milestone.Index)

type SyncState

type SyncState struct {
	LatestMilestone                    trinary.Hash
	LatestMilestoneIndex               milestone.Index
	LatestSolidSubtangleMilestone      trinary.Hash
	LatestSolidSubtangleMilestoneIndex milestone.Index
	MilestoneStartIndex                milestone.Index
	LastSnapshottedMilestoneIndex      milestone.Index
	CoordinatorAddress                 trinary.Hash
}

type Transaction

type Transaction struct {

	// Decompressed iota.go Transaction containing Hash
	Tx *transaction.Transaction
	// contains filtered or unexported fields
}

func NewTransaction

func NewTransaction(txHash hornet.Hash) *Transaction

func (*Transaction) BranchHash

func (tx *Transaction) BranchHash() hornet.Hash

func (*Transaction) BundleHash

func (tx *Transaction) BundleHash() hornet.Hash

func (*Transaction) IsHead

func (tx *Transaction) IsHead() bool

func (*Transaction) IsTail

func (tx *Transaction) IsTail() bool

func (*Transaction) IsValue

func (tx *Transaction) IsValue() bool

func (*Transaction) TrunkHash

func (tx *Transaction) TrunkHash() hornet.Hash

func (*Transaction) Unmarshal

func (tx *Transaction) Unmarshal(data []byte) error

type TransactionMetadata

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

func NewTransactionMetadata

func NewTransactionMetadata(txHash hornet.Hash) *TransactionMetadata

func (*TransactionMetadata) BranchHash

func (m *TransactionMetadata) BranchHash() hornet.Hash

func (*TransactionMetadata) BundleHash

func (m *TransactionMetadata) BundleHash() hornet.Hash

func (*TransactionMetadata) ConfirmedWithIndex

func (m *TransactionMetadata) ConfirmedWithIndex() (bool, milestone.Index)

func (*TransactionMetadata) IsConfirmed

func (m *TransactionMetadata) IsConfirmed() bool

func (*TransactionMetadata) IsConflicting

func (m *TransactionMetadata) IsConflicting() bool

func (*TransactionMetadata) IsMilestone added in v1.1.0

func (m *TransactionMetadata) IsMilestone() bool

func (*TransactionMetadata) IsSolid

func (m *TransactionMetadata) IsSolid() bool

func (*TransactionMetadata) IsTail

func (m *TransactionMetadata) IsTail() bool

func (*TransactionMetadata) Marshal added in v1.1.0

func (m *TransactionMetadata) Marshal() []byte

func (*TransactionMetadata) MilestoneIndex added in v1.1.0

func (m *TransactionMetadata) MilestoneIndex() milestone.Index

func (*TransactionMetadata) TrunkHash

func (m *TransactionMetadata) TrunkHash() hornet.Hash

func (*TransactionMetadata) TxHash

func (m *TransactionMetadata) TxHash() hornet.Hash

func (*TransactionMetadata) Unmarshal

func (m *TransactionMetadata) Unmarshal(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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