Documentation
¶
Index ¶
- Constants
- Variables
- func BlockBlobIndexKey(blockNumber uint64) []byte
- func BlockBlobKey(slot uint64, hash []byte) []byte
- func BlockBlobKeyUint64ToBytes(input uint64) []byte
- func BlockBlobMetadataKey(baseKey []byte) []byte
- func BlockHashIndexKey(hash []byte) []byte
- func BlockTombstone() []byte
- func IsBlockTombstone(data []byte) bool
- func ParseBlockBlobKey(key []byte) (uint64, []byte, error)
- func TxBlobKey(txHash []byte) []byte
- func UtxoBlobKey(txId []byte, outputIdx uint32) []byte
- type BlobItem
- type BlobIterator
- type BlobIteratorOptions
- type BlockMetadata
- type BlockTombstonedError
- type NodeSettings
- type Rat
- type SignedURL
- type Txn
- type Uint64
- type UtxoKey
Constants ¶
const ( BlockBlobKeyPrefix = "bp" BlockBlobIndexKeyPrefix = "bi" BlockBlobMetadataKeySuffix = "_metadata" UtxoBlobKeyPrefix = "u" TxBlobKeyPrefix = "t" )
const ( // StorageModeCore stores only consensus and chain state data. StorageModeCore = "core" // StorageModeAPI stores everything needed for API queries. StorageModeAPI = "api" )
Storage mode constants shared by the metadata plugins.
const BlockBlobKeySize = 2 + 8 + 32
BlockBlobKeySize is the on-disk length of a fully-formed block bp key: prefix (2) + slot (8) + hash (32) = 42 bytes. Plugins use this to decide whether a key is a base bp key (vs a metadata-suffixed one).
const BlockHashIndexKeyPrefix = "bh"
BlockHashIndexKeyPrefix is the key prefix for the hash→block-key index. Key format: "bh" + hash(32 bytes), value: BlockBlobKey (slot+hash).
Variables ¶
var BlockTombstoneMagic = [4]byte{'D', 'B', 'T', '1'}
BlockTombstoneMagic is the four-byte prefix that identifies a tombstone record stored at a block's bp key. The bytes "DBT1" do not appear at the start of any valid Cardano block CBOR (blocks begin with a CBOR array header byte such as 0x82/0x83), so detection is unambiguous.
var ErrBlobKeyNotFound = errors.New("blob key not found")
ErrBlobKeyNotFound is returned by blob operations when a key is missing
ErrBlobStoreUnavailable is returned when blob store cannot be accessed
var ErrBlockTombstoned = errors.New("block tombstoned (archived)")
ErrBlockTombstoned is the sentinel for tombstoned-block errors. Callers can use errors.Is(err, ErrBlockTombstoned) for existence checks. To get the (slot, hash) of the tombstoned block, use errors.As to extract a *BlockTombstonedError. The block was pruned for archival and is expected to be available via an archive proxy; wrappers (notably bark) intercept the typed error and resolve the block from the archive. Unwrapped consumers should treat it as a configuration error (the block is no longer local but no proxy is wired up).
var ErrNilTxn = errors.New("nil transaction")
ErrNilTxn is returned when a nil transaction is provided where a valid transaction is required
var ErrNoEpochData = errors.New(
"no epoch data available for requested slot",
)
ErrNoEpochData is returned when epoch data has not been synced yet for the requested slot. Callers should distinguish this from "no active pools" and handle it appropriately (e.g., retry after sync progresses).
var ErrNoStoreAvailable = errors.New("no store available")
ErrNoStoreAvailable is returned when no blob or metadata store is available
var ErrPartialCommit = errors.New(
"partial commit: blob committed but metadata failed",
)
ErrPartialCommit is returned when blob commits but metadata fails, leaving the database in an inconsistent state that requires recovery.
var ErrTxnWrongType = errors.New("invalid transaction type")
ErrTxnWrongType is returned when a transaction has the wrong type
var ErrUtxoConflict = errors.New("UTxO already spent")
ErrUtxoConflict is returned when a UTxO spend fails because the UTxO was already consumed by another transaction or restored by a rollback. This sentinel error allows callers to distinguish optimistic locking conflicts from other errors and retry or reject accordingly.
var ErrUtxoNotFound = errors.New("utxo not found")
ErrUtxoNotFound is returned when a requested UTxO row does not exist.
Functions ¶
func BlockBlobIndexKey ¶ added in v0.20.0
func BlockBlobKey ¶ added in v0.20.0
func BlockBlobKeyUint64ToBytes ¶ added in v0.20.0
func BlockBlobMetadataKey ¶ added in v0.20.0
func BlockHashIndexKey ¶ added in v0.35.0
BlockHashIndexKey builds the key for a hash→slot lookup index entry.
func BlockTombstone ¶ added in v0.39.1
func BlockTombstone() []byte
BlockTombstone returns a fresh copy of the tombstone marker that replaces a block's CBOR when the block has been pruned for archival. The marker carries no embedded (slot, hash) — the bp key already does, and surfacing the typed BlockTombstonedError is the responsibility of each blob plugin (which knows its own key format).
func IsBlockTombstone ¶ added in v0.39.1
IsBlockTombstone reports whether the given bytes are a tombstone marker. Tested by prefix so any payload starting with the magic is treated as a tombstone — a partial or unexpectedly extended marker must never be misread as block CBOR.
func ParseBlockBlobKey ¶ added in v0.39.1
ParseBlockBlobKey is the inverse of BlockBlobKey: it pulls (slot, hash) back out of a fully-formed bp key. Used by blob plugins that need to attach the (slot, hash) of a tombstoned block to a typed error surfaced from iteration. Returns an error for any key whose shape doesn't match what BlockBlobKey produced.
func TxBlobKey ¶ added in v0.22.0
TxBlobKey creates a key for storing transaction offset data. Key format: 't' + txHash (32 bytes)
func UtxoBlobKey ¶ added in v0.20.0
Types ¶
type BlobIterator ¶ added in v0.19.0
type BlobIterator interface {
Rewind()
Seek(prefix []byte)
Valid() bool
ValidForPrefix(prefix []byte) bool
Next()
Item() BlobItem
Close()
Err() error
}
BlobIterator provides key iteration over the blob store.
Important lifecycle constraint: items returned by `Item()` must only be accessed while the underlying transaction used to create the iterator is still active. Implementations may validate transaction state at access time (for example `ValueCopy` may fail if the transaction has been committed or rolled back). Typical usage iterates and accesses item values within the same transaction scope.
type BlobIteratorOptions ¶ added in v0.19.0
BlobIteratorOptions configures blob iterator creation
type BlockMetadata ¶ added in v0.20.0
BlockMetadata contains metadata for a block stored in blob. IMPORTANT: Field order must remain [ID, Type, Height, PrevHash] because cbor.StructAsArray encodes/decodes by position. Changing the order would break deserialization of existing stored data.
type BlockTombstonedError ¶ added in v0.39.1
BlockTombstonedError is the typed form of ErrBlockTombstoned, returned by blob plugins on every tombstone observation (GetBlock and iterator ValueCopy). It carries the (slot, hash) of the tombstoned block so an archive-proxy wrapper can resolve it without having to parse the blob key — the wrapper extracts it via:
var t *types.BlockTombstonedError
if errors.As(err, &t) { fetchFromArchive(t.Slot, t.Hash) }
func (*BlockTombstonedError) Error ¶ added in v0.39.1
func (e *BlockTombstonedError) Error() string
func (*BlockTombstonedError) Unwrap ¶ added in v0.39.1
func (e *BlockTombstonedError) Unwrap() error
Unwrap returns ErrBlockTombstoned so errors.Is(err, ErrBlockTombstoned) keeps working for callers that only need to detect the condition.
type NodeSettings ¶ added in v0.31.0
NodeSettings holds immutable node configuration that is persisted on first sync and enforced on every subsequent startup.
type SignedURL ¶ added in v0.22.0
SignedURL is a url that has been pre-signed and has an expiration time
type Txn ¶ added in v0.19.0
Txn is a simple transaction handle for commit/rollback only. Database layer (Txn) coordinates metadata and blob operations separately.
type UtxoKey ¶ added in v0.37.0
UtxoKey identifies a UTxO row by its transaction id and output index. Used as a parameter type for batch UTxO operations across the metadata-store interface (e.g. MarkUtxosDeletedAtSlot). The fixed-size UtxoRef in database/cbor_cache.go is for in-memory map keys; this variable-length form matches the byte slices stored on the UTxO row directly.