Documentation
¶
Index ¶
- Constants
- Variables
- func BlockBeforeSlot(db *Database, slotNumber uint64) (models.Block, error)
- func BlockBeforeSlotTxn(txn *Txn, slotNumber uint64) (models.Block, error)
- func BlockBlobIndexKey(blockNumber uint64) []byte
- func BlockBlobKey(slot uint64, hash []byte) []byte
- func BlockBlobKeyHashHex(slot uint64, hashHex string) ([]byte, error)
- func BlockBlobMetadataKey(baseKey []byte) []byte
- func BlockByPoint(db *Database, point ocommon.Point) (models.Block, error)
- func BlockByPointTxn(txn *Txn, point ocommon.Point) (models.Block, error)
- func BlockDeleteTxn(txn *Txn, block models.Block) error
- func BlocksAfterSlotTxn(txn *Txn, slotNumber uint64) ([]models.Block, error)
- func BlocksRecent(db *Database, count int) ([]models.Block, error)
- func BlocksRecentTxn(txn *Txn, count int) ([]models.Block, error)
- func UtxoBlobKey(txId []byte, outputIdx uint32) []byte
- type BlockBlobMetadata
- type CommitTimestampError
- type Config
- type Database
- func (d *Database) AddUtxos(utxos []models.UtxoSlot, txn *Txn) error
- func (d *Database) ApplyPParamUpdates(slot, epoch uint64, era uint, currentPParams *lcommon.ProtocolParameters, ...) error
- func (d *Database) Blob() blob.BlobStore
- func (d *Database) BlobTxn(readWrite bool) *Txn
- func (d *Database) BlockByIndex(blockIndex uint64, txn *Txn) (models.Block, error)
- func (d *Database) BlockCreate(block models.Block, txn *Txn) error
- func (d *Database) Close() error
- func (d *Database) Config() *Config
- func (d *Database) DataDir() string
- func (d *Database) DeleteBlockNoncesBeforeSlot(slotNumber uint64, txn *Txn) error
- func (d *Database) DeleteBlockNoncesBeforeSlotWithoutCheckpoints(slotNumber uint64, txn *Txn) error
- func (d *Database) GetAccount(stakeKey []byte, includeInactive bool, txn *Txn) (*models.Account, error)
- func (d *Database) GetBlockNonce(point ocommon.Point, txn *Txn) ([]byte, error)
- func (d *Database) GetDatum(hash []byte, txn *Txn) (*models.Datum, error)
- func (d *Database) GetDrep(cred []byte, includeInactive bool, txn *Txn) (*models.Drep, error)
- func (d *Database) GetEpochs(txn *Txn) ([]models.Epoch, error)
- func (d *Database) GetEpochsByEra(eraId uint, txn *Txn) ([]models.Epoch, error)
- func (d *Database) GetPParams(epoch uint64, decodeFunc func([]byte) (lcommon.ProtocolParameters, error), ...) (lcommon.ProtocolParameters, error)
- func (d *Database) GetPool(pkh lcommon.PoolKeyHash, includeInactive bool, txn *Txn) (*models.Pool, error)
- func (d *Database) GetPoolRegistrations(poolKeyHash lcommon.PoolKeyHash, txn *Txn) ([]lcommon.PoolRegistrationCertificate, error)
- func (d *Database) GetStakeRegistrations(stakingKey []byte, txn *Txn) ([]lcommon.StakeRegistrationCertificate, error)
- func (d *Database) GetTip(txn *Txn) (ochainsync.Tip, error)
- func (d *Database) Logger() *slog.Logger
- func (d *Database) Metadata() metadata.MetadataStore
- func (d *Database) MetadataTxn(readWrite bool) *Txn
- func (d *Database) SetBlockNonce(blockHash []byte, slotNumber uint64, nonce []byte, isCheckpoint bool, txn *Txn) error
- func (d *Database) SetDatum(rawDatum []byte, addedSlot uint64, txn *Txn) error
- func (d *Database) SetEpoch(slot, epoch uint64, nonce []byte, era, slotLength, lengthInSlots uint, ...) error
- func (d *Database) SetPParamUpdate(genesis, params []byte, slot, epoch uint64, txn *Txn) error
- func (d *Database) SetPParams(params []byte, slot, epoch uint64, era uint, txn *Txn) error
- func (d *Database) SetTip(tip ochainsync.Tip, txn *Txn) error
- func (d *Database) SetTransaction(tx lcommon.Transaction, point ocommon.Point, idx uint32, updateEpoch uint64, ...) error
- func (d *Database) Transaction(readWrite bool) *Txn
- func (d *Database) UtxoByRef(txId []byte, outputIdx uint32, txn *Txn) (*models.Utxo, error)
- func (d *Database) UtxosByAddress(addr ledger.Address, txn *Txn) ([]models.Utxo, error)
- func (d *Database) UtxosDeleteConsumed(slot uint64, limit int, txn *Txn) (int, error)
- func (d *Database) UtxosDeleteRolledback(slot uint64, txn *Txn) error
- func (d *Database) UtxosUnspend(slot uint64, txn *Txn) error
- type Txn
Constants ¶
const (
BlockInitialIndex uint64 = 1
)
Variables ¶
var DefaultConfig = &Config{
BlobPlugin: "badger",
DataDir: ".dingo",
MetadataPlugin: "sqlite",
}
var ErrDatumNotFound = errors.New("datum not found")
var ErrUtxoNotFound = errors.New("utxo not found")
Functions ¶
func BlockBeforeSlot ¶ added in v0.4.2
func BlockBeforeSlotTxn ¶ added in v0.4.2
func BlockBlobIndexKey ¶ added in v0.4.5
func BlockBlobKey ¶ added in v0.4.2
func BlockBlobKeyHashHex ¶ added in v0.4.2
func BlockBlobMetadataKey ¶ added in v0.4.2
func BlockByPoint ¶ added in v0.4.2
func BlockByPointTxn ¶ added in v0.4.2
func BlocksAfterSlotTxn ¶ added in v0.4.2
func BlocksRecent ¶ added in v0.4.2
func BlocksRecentTxn ¶ added in v0.4.2
func UtxoBlobKey ¶ added in v0.4.2
Types ¶
type BlockBlobMetadata ¶ added in v0.4.2
type CommitTimestampError ¶
CommitTimestampError contains the timestamps of the metadata and blob stores
func (CommitTimestampError) Error ¶
func (e CommitTimestampError) Error() string
Error returns the stringified error
type Config ¶ added in v0.12.1
type Config struct {
PromRegistry prometheus.Registerer
Logger *slog.Logger
BlobPlugin string
DataDir string
MetadataPlugin string
}
Config represents the configuration for a database instance
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents our data storage services
func New ¶ added in v0.4.3
New creates a new database instance with optional persistence using the provided data directory. When config is nil, DefaultConfig is used (DataDir = ".dingo" for persistence). When config is provided but DataDir is empty, storage is in-memory only. When config.DataDir is non-empty, it specifies the persistent storage directory.
func (*Database) ApplyPParamUpdates ¶ added in v0.4.4
func (*Database) BlobTxn ¶ added in v0.4.3
BlobTxn starts a new blob-only database transaction and returns a handle to it
func (*Database) BlockByIndex ¶ added in v0.4.5
func (*Database) BlockCreate ¶ added in v0.4.5
func (*Database) Config ¶ added in v0.12.1
Config returns the config object used for the database instance
func (*Database) DataDir ¶ added in v0.4.3
DataDir returns the path to the data directory used for storage
func (*Database) DeleteBlockNoncesBeforeSlot ¶ added in v0.11.0
DeleteBlockNoncesBeforeSlot removes all block_nonces older than the given slot number
func (*Database) DeleteBlockNoncesBeforeSlotWithoutCheckpoints ¶ added in v0.11.0
func (d *Database) DeleteBlockNoncesBeforeSlotWithoutCheckpoints( slotNumber uint64, txn *Txn, ) error
DeleteBlockNoncesBeforeSlotWithoutCheckpoints removes non-checkpoint block_nonces older than the given slot number
func (*Database) GetAccount ¶ added in v0.6.0
func (d *Database) GetAccount( stakeKey []byte, includeInactive bool, txn *Txn, ) (*models.Account, error)
GetAccount returns an account by staking key
func (*Database) GetBlockNonce ¶ added in v0.11.0
GetBlockNonce fetches the block nonce for a given chain point
func (*Database) GetEpochsByEra ¶ added in v0.4.3
func (*Database) GetPParams ¶ added in v0.4.4
func (d *Database) GetPParams( epoch uint64, decodeFunc func([]byte) (lcommon.ProtocolParameters, error), txn *Txn, ) (lcommon.ProtocolParameters, error)
func (*Database) GetPool ¶ added in v0.17.0
func (d *Database) GetPool( pkh lcommon.PoolKeyHash, includeInactive bool, txn *Txn, ) (*models.Pool, error)
GetPool returns a pool by its key hash
func (*Database) GetPoolRegistrations ¶ added in v0.4.3
func (d *Database) GetPoolRegistrations( poolKeyHash lcommon.PoolKeyHash, txn *Txn, ) ([]lcommon.PoolRegistrationCertificate, error)
GetPoolRegistrations returns a list of pool registration certificates
func (*Database) GetStakeRegistrations ¶ added in v0.4.3
func (d *Database) GetStakeRegistrations( stakingKey []byte, txn *Txn, ) ([]lcommon.StakeRegistrationCertificate, error)
GetStakeRegistrations returns a list of stake registration certificates
func (*Database) GetTip ¶ added in v0.4.3
func (d *Database) GetTip(txn *Txn) (ochainsync.Tip, error)
GetTip returns the current tip as represented by the protocol
func (*Database) Metadata ¶
func (d *Database) Metadata() metadata.MetadataStore
Metadata returns the underlying metadata store instance
func (*Database) MetadataTxn ¶ added in v0.4.3
MetadataTxn starts a new metadata-only database transaction and returns a handle to it
func (*Database) SetBlockNonce ¶ added in v0.11.0
func (*Database) SetDatum ¶ added in v0.9.0
SetDatum saves the raw datum into the database by computing the hash before inserting.
func (*Database) SetPParamUpdate ¶ added in v0.4.4
func (*Database) SetPParams ¶ added in v0.4.4
func (*Database) SetTip ¶ added in v0.4.3
func (d *Database) SetTip(tip ochainsync.Tip, txn *Txn) error
SetTip saves the current tip
func (*Database) SetTransaction ¶ added in v0.18.0
func (d *Database) SetTransaction( tx lcommon.Transaction, point ocommon.Point, idx uint32, updateEpoch uint64, pparamUpdates map[lcommon.Blake2b224]lcommon.ProtocolParameterUpdate, certDeposits map[int]uint64, txn *Txn, ) error
func (*Database) Transaction ¶
Transaction starts a new database transaction and returns a handle to it
func (*Database) UtxosByAddress ¶ added in v0.4.3
func (*Database) UtxosDeleteConsumed ¶ added in v0.4.4
func (*Database) UtxosDeleteRolledback ¶ added in v0.4.3
type Txn ¶
type Txn struct {
// contains filtered or unexported fields
}
Txn is a wrapper around the transaction objects for the underlying DB engines