Documentation
¶
Index ¶
- Constants
- type BadgerStore
- func (s *BadgerStore) AddNodeOperation(tx *common.VersionedTransaction, timestamp, threshold uint64, finalized bool) error
- func (s *BadgerStore) CacheGetTransaction(hash crypto.Hash) (*common.VersionedTransaction, error)
- func (s *BadgerStore) CacheQueueTransaction(tx *common.VersionedTransaction) error
- func (s *BadgerStore) CacheRemoveTransactions(hashes []crypto.Hash) error
- func (s *BadgerStore) CacheRetrieveTransactions(limit int) ([]*common.VersionedTransaction, error)
- func (s *BadgerStore) CacheStoreTransaction(tx *common.VersionedTransaction) error
- func (s *BadgerStore) CheckGenesisLoad(snapshots []*common.SnapshotWithTopologicalOrder) (bool, error)
- func (store *BadgerStore) Close() error
- func (s *BadgerStore) LastSnapshot() (*common.SnapshotWithTopologicalOrder, []*common.VersionedTransaction)
- func (s *BadgerStore) ListAggregatedRoundSpaceCheckpoints(cids []crypto.Hash) (map[crypto.Hash]*common.RoundSpace, error)
- func (s *BadgerStore) ListCustodianUpdates() ([]*common.CustodianUpdateRequest, error)
- func (s *BadgerStore) ListNodeWorks(cids []crypto.Hash, day uint32) (map[crypto.Hash][2]uint64, error)
- func (s *BadgerStore) ListWorkOffsets(cids []crypto.Hash) (map[crypto.Hash]uint64, error)
- func (s *BadgerStore) LoadGenesis(rounds []*common.Round, snapshots []*common.SnapshotWithTopologicalOrder, ...) error
- func (s *BadgerStore) LockAndPersistTransactions(vers []*common.VersionedTransaction, fork bool) error
- func (s *BadgerStore) LockDepositInput(deposit *common.DepositData, tx crypto.Hash, fork bool) error
- func (s *BadgerStore) LockGhostKeys(keys []*crypto.Key, tx crypto.Hash, fork bool) error
- func (s *BadgerStore) LockMintInput(mint *common.MintData, tx crypto.Hash, fork bool) error
- func (s *BadgerStore) LockUTXOs(inputs []*common.Input, tx crypto.Hash, fork bool) error
- func (s *BadgerStore) ReadAllNodes(threshold uint64, withState bool) []*common.Node
- func (s *BadgerStore) ReadAssetWithBalance(id crypto.Hash) (*common.Asset, common.Integer, error)
- func (s *BadgerStore) ReadCustodian(ts uint64) (*common.CustodianUpdateRequest, error)
- func (s *BadgerStore) ReadDepositLock(deposit *common.DepositData) (crypto.Hash, error)
- func (s *BadgerStore) ReadGhostKeyLock(key crypto.Key) (*crypto.Hash, error)
- func (s *BadgerStore) ReadLastConsensusSnapshot() (*common.Snapshot, error)
- func (s *BadgerStore) ReadLastMintDistribution(batch uint64) (*common.MintDistribution, error)
- func (s *BadgerStore) ReadLink(from, to crypto.Hash) (uint64, error)
- func (s *BadgerStore) ReadMintDistributions(offset, count uint64) ([]*common.MintDistribution, []*common.VersionedTransaction, error)
- func (s *BadgerStore) ReadNodeRoundSpacesForBatch(nodeId crypto.Hash, batch uint64) ([]*common.RoundSpace, error)
- func (s *BadgerStore) ReadRound(hash crypto.Hash) (*common.Round, error)
- func (s *BadgerStore) ReadRoundSpaceCheckpoint(nodeId crypto.Hash) (uint64, uint64, error)
- func (s *BadgerStore) ReadSnapshot(hash crypto.Hash) (*common.SnapshotWithTopologicalOrder, error)
- func (s *BadgerStore) ReadSnapshotWithTransactionsSinceTopology(topologyOffset, count uint64) ([]*common.SnapshotWithTopologicalOrder, [][]*common.VersionedTransaction, ...)
- func (s *BadgerStore) ReadSnapshotWorksForNodeRound(nodeId crypto.Hash, round uint64) ([]*common.SnapshotWork, error)
- func (s *BadgerStore) ReadSnapshotsForNodeRound(nodeId crypto.Hash, round uint64) ([]*common.SnapshotWithTopologicalOrder, error)
- func (s *BadgerStore) ReadSnapshotsSinceTopology(topologyOffset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
- func (s *BadgerStore) ReadTransaction(hash crypto.Hash) (*common.VersionedTransaction, string, error)
- func (s *BadgerStore) ReadUTXOKeys(hash crypto.Hash, index uint) (*common.UTXOKeys, error)
- func (s *BadgerStore) ReadUTXOLock(hash crypto.Hash, index uint) (*common.UTXOWithLock, error)
- func (s *BadgerStore) ReadWithdrawalClaim(hash crypto.Hash) (*common.VersionedTransaction, string, error)
- func (s *BadgerStore) ReadWorkOffset(nodeId crypto.Hash) (uint64, error)
- func (s *BadgerStore) RemoveGraphEntries(prefix string) (int, error)
- func (s *BadgerStore) StartNewRound(node crypto.Hash, number uint64, references *common.RoundLink, ...) error
- func (s *BadgerStore) UpdateEmptyHeadRound(node crypto.Hash, number uint64, references *common.RoundLink) error
- func (s *BadgerStore) ValidateGraphEntries(networkId crypto.Hash, depth uint64) (int, int, error)
- func (s *BadgerStore) WriteConsensusSnapshot(snap *common.Snapshot, tx *common.VersionedTransaction, hack *common.Snapshot) error
- func (s *BadgerStore) WriteRoundSpaceAndState(space *common.RoundSpace) error
- func (s *BadgerStore) WriteRoundWork(nodeId crypto.Hash, round uint64, snapshots []*common.SnapshotWork, ...) error
- func (s *BadgerStore) WriteSnapshot(snap *common.SnapshotWithTopologicalOrder, signers []crypto.Hash) error
- func (s *BadgerStore) WriteTransaction(ver *common.VersionedTransaction) error
- type Store
Constants ¶
const DAY_U64 = uint64(time.Hour) * 24
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerStore ¶
type BadgerStore struct {
// contains filtered or unexported fields
}
func NewBadgerStore ¶
func NewBadgerStore(custom *config.Custom, dir string) (*BadgerStore, error)
func (*BadgerStore) AddNodeOperation ¶ added in v0.3.0
func (s *BadgerStore) AddNodeOperation(tx *common.VersionedTransaction, timestamp, threshold uint64, finalized bool) error
func (*BadgerStore) CacheGetTransaction ¶
func (s *BadgerStore) CacheGetTransaction(hash crypto.Hash) (*common.VersionedTransaction, error)
func (*BadgerStore) CacheQueueTransaction ¶ added in v0.19.1
func (s *BadgerStore) CacheQueueTransaction(tx *common.VersionedTransaction) error
func (*BadgerStore) CacheRemoveTransactions ¶ added in v0.12.4
func (s *BadgerStore) CacheRemoveTransactions(hashes []crypto.Hash) error
func (*BadgerStore) CacheRetrieveTransactions ¶ added in v0.14.5
func (s *BadgerStore) CacheRetrieveTransactions(limit int) ([]*common.VersionedTransaction, error)
func (*BadgerStore) CacheStoreTransaction ¶ added in v0.19.1
func (s *BadgerStore) CacheStoreTransaction(tx *common.VersionedTransaction) error
func (*BadgerStore) CheckGenesisLoad ¶
func (s *BadgerStore) CheckGenesisLoad(snapshots []*common.SnapshotWithTopologicalOrder) (bool, error)
func (*BadgerStore) Close ¶
func (store *BadgerStore) Close() error
func (*BadgerStore) LastSnapshot ¶ added in v0.18.21
func (s *BadgerStore) LastSnapshot() (*common.SnapshotWithTopologicalOrder, []*common.VersionedTransaction)
func (*BadgerStore) ListAggregatedRoundSpaceCheckpoints ¶ added in v0.14.0
func (s *BadgerStore) ListAggregatedRoundSpaceCheckpoints(cids []crypto.Hash) (map[crypto.Hash]*common.RoundSpace, error)
func (*BadgerStore) ListCustodianUpdates ¶ added in v0.16.0
func (s *BadgerStore) ListCustodianUpdates() ([]*common.CustodianUpdateRequest, error)
func (*BadgerStore) ListNodeWorks ¶ added in v0.11.0
func (*BadgerStore) ListWorkOffsets ¶ added in v0.11.6
func (*BadgerStore) LoadGenesis ¶
func (s *BadgerStore) LoadGenesis(rounds []*common.Round, snapshots []*common.SnapshotWithTopologicalOrder, transactions []*common.VersionedTransaction) error
func (*BadgerStore) LockAndPersistTransactions ¶ added in v0.19.3
func (s *BadgerStore) LockAndPersistTransactions(vers []*common.VersionedTransaction, fork bool) error
LockAndPersistTransactions locks the inputs and output ghost keys of every transaction and persists their bodies within a single badger transaction. Validating a snapshot batch previously required several fsynced commits per transaction, one for the ghost keys, one for the inputs and one for the body, which dominated the transaction-to-snapshot latency. One commit per batch preserves the same durability with a fraction of the fsyncs, and holding the store mutex for the whole batch keeps the serialization against WriteSnapshot unchanged.
The new path writes every input lock, ghost lock, and transaction body in one Badger transaction. Badger’s default limit is roughly 104,857 entries, but one valid script transaction can contain 256 outputs × 256 keys = 65,536 ghost locks. Two such batchable transactions remain below the 4 MiB per-transaction and transport-size limits, yet require over 131,000 lock writes. This returns badger.ErrTxnTooBig on a verifier without pre-existing locks. Meanwhile, a proposer may succeed because queue validation already stored those locks individually, creating state-dependent snapshot acceptance. Cap expected writes before batching, or keep ghost-lock commits bounded/per-transaction.
func (*BadgerStore) LockDepositInput ¶
func (s *BadgerStore) LockDepositInput(deposit *common.DepositData, tx crypto.Hash, fork bool) error
func (*BadgerStore) LockGhostKeys ¶ added in v0.16.0
func (*BadgerStore) LockMintInput ¶ added in v0.1.1
func (*BadgerStore) ReadAllNodes ¶ added in v0.5.6
func (s *BadgerStore) ReadAllNodes(threshold uint64, withState bool) []*common.Node
func (*BadgerStore) ReadAssetWithBalance ¶ added in v0.17.0
func (*BadgerStore) ReadCustodian ¶ added in v0.16.0
func (s *BadgerStore) ReadCustodian(ts uint64) (*common.CustodianUpdateRequest, error)
func (*BadgerStore) ReadDepositLock ¶ added in v0.17.1
func (s *BadgerStore) ReadDepositLock(deposit *common.DepositData) (crypto.Hash, error)
func (*BadgerStore) ReadGhostKeyLock ¶ added in v0.16.0
func (*BadgerStore) ReadLastConsensusSnapshot ¶ added in v0.18.21
func (s *BadgerStore) ReadLastConsensusSnapshot() (*common.Snapshot, error)
func (*BadgerStore) ReadLastMintDistribution ¶ added in v0.1.1
func (s *BadgerStore) ReadLastMintDistribution(batch uint64) (*common.MintDistribution, error)
func (*BadgerStore) ReadMintDistributions ¶ added in v0.1.2
func (s *BadgerStore) ReadMintDistributions(offset, count uint64) ([]*common.MintDistribution, []*common.VersionedTransaction, error)
func (*BadgerStore) ReadNodeRoundSpacesForBatch ¶ added in v0.14.0
func (s *BadgerStore) ReadNodeRoundSpacesForBatch(nodeId crypto.Hash, batch uint64) ([]*common.RoundSpace, error)
func (*BadgerStore) ReadRoundSpaceCheckpoint ¶ added in v0.14.0
func (*BadgerStore) ReadSnapshot ¶ added in v0.2.14
func (s *BadgerStore) ReadSnapshot(hash crypto.Hash) (*common.SnapshotWithTopologicalOrder, error)
func (*BadgerStore) ReadSnapshotWithTransactionsSinceTopology ¶ added in v0.1.1
func (s *BadgerStore) ReadSnapshotWithTransactionsSinceTopology(topologyOffset, count uint64) ([]*common.SnapshotWithTopologicalOrder, [][]*common.VersionedTransaction, error)
func (*BadgerStore) ReadSnapshotWorksForNodeRound ¶ added in v0.11.7
func (s *BadgerStore) ReadSnapshotWorksForNodeRound(nodeId crypto.Hash, round uint64) ([]*common.SnapshotWork, error)
func (*BadgerStore) ReadSnapshotsForNodeRound ¶
func (s *BadgerStore) ReadSnapshotsForNodeRound(nodeId crypto.Hash, round uint64) ([]*common.SnapshotWithTopologicalOrder, error)
func (*BadgerStore) ReadSnapshotsSinceTopology ¶
func (s *BadgerStore) ReadSnapshotsSinceTopology(topologyOffset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
func (*BadgerStore) ReadTransaction ¶
func (s *BadgerStore) ReadTransaction(hash crypto.Hash) (*common.VersionedTransaction, string, error)
func (*BadgerStore) ReadUTXOKeys ¶ added in v0.12.18
func (*BadgerStore) ReadUTXOLock ¶ added in v0.12.18
func (s *BadgerStore) ReadUTXOLock(hash crypto.Hash, index uint) (*common.UTXOWithLock, error)
func (*BadgerStore) ReadWithdrawalClaim ¶ added in v0.17.7
func (s *BadgerStore) ReadWithdrawalClaim(hash crypto.Hash) (*common.VersionedTransaction, string, error)
func (*BadgerStore) ReadWorkOffset ¶ added in v0.11.0
func (s *BadgerStore) ReadWorkOffset(nodeId crypto.Hash) (uint64, error)
func (*BadgerStore) RemoveGraphEntries ¶ added in v0.1.1
func (s *BadgerStore) RemoveGraphEntries(prefix string) (int, error)
func (*BadgerStore) StartNewRound ¶
func (*BadgerStore) UpdateEmptyHeadRound ¶
func (*BadgerStore) ValidateGraphEntries ¶ added in v0.1.14
func (*BadgerStore) WriteConsensusSnapshot ¶ added in v0.18.21
func (s *BadgerStore) WriteConsensusSnapshot(snap *common.Snapshot, tx *common.VersionedTransaction, hack *common.Snapshot) error
func (*BadgerStore) WriteRoundSpaceAndState ¶ added in v0.14.0
func (s *BadgerStore) WriteRoundSpaceAndState(space *common.RoundSpace) error
func (*BadgerStore) WriteRoundWork ¶ added in v0.11.0
func (s *BadgerStore) WriteRoundWork(nodeId crypto.Hash, round uint64, snapshots []*common.SnapshotWork, credit bool) error
func (*BadgerStore) WriteSnapshot ¶
func (s *BadgerStore) WriteSnapshot(snap *common.SnapshotWithTopologicalOrder, signers []crypto.Hash) error
func (*BadgerStore) WriteTransaction ¶
func (s *BadgerStore) WriteTransaction(ver *common.VersionedTransaction) error
type Store ¶
type Store interface {
Close() error
CheckGenesisLoad(snapshots []*common.SnapshotWithTopologicalOrder) (bool, error)
LoadGenesis(rounds []*common.Round, snapshots []*common.SnapshotWithTopologicalOrder, transactions []*common.VersionedTransaction) error
ReadAssetWithBalance(id crypto.Hash) (*common.Asset, common.Integer, error)
ReadAllNodes(threshold uint64, withState bool) []*common.Node
AddNodeOperation(tx *common.VersionedTransaction, timestamp, threshold uint64, finalized bool) error
ReadTransaction(hash crypto.Hash) (*common.VersionedTransaction, string, error)
WriteTransaction(tx *common.VersionedTransaction) error
LockAndPersistTransactions(txs []*common.VersionedTransaction, fork bool) error
StartNewRound(node crypto.Hash, number uint64, references *common.RoundLink, finalStart uint64) error
UpdateEmptyHeadRound(node crypto.Hash, number uint64, references *common.RoundLink) error
LastSnapshot() (*common.SnapshotWithTopologicalOrder, []*common.VersionedTransaction)
WriteConsensusSnapshot(snap *common.Snapshot, tx *common.VersionedTransaction, hack *common.Snapshot) error
ReadLastConsensusSnapshot() (*common.Snapshot, error)
ReadUTXOKeys(hash crypto.Hash, index uint) (*common.UTXOKeys, error)
ReadUTXOLock(hash crypto.Hash, index uint) (*common.UTXOWithLock, error)
LockUTXOs(inputs []*common.Input, tx crypto.Hash, fork bool) error
ReadDepositLock(deposit *common.DepositData) (crypto.Hash, error)
LockDepositInput(deposit *common.DepositData, tx crypto.Hash, fork bool) error
ReadWithdrawalClaim(hash crypto.Hash) (*common.VersionedTransaction, string, error)
ReadGhostKeyLock(key crypto.Key) (*crypto.Hash, error)
LockGhostKeys(keys []*crypto.Key, tx crypto.Hash, fork bool) error
ReadSnapshot(hash crypto.Hash) (*common.SnapshotWithTopologicalOrder, error)
ReadSnapshotsSinceTopology(offset, count uint64) ([]*common.SnapshotWithTopologicalOrder, error)
ReadSnapshotWithTransactionsSinceTopology(topologyOffset, count uint64) ([]*common.SnapshotWithTopologicalOrder, [][]*common.VersionedTransaction, error)
ReadSnapshotsForNodeRound(nodeIdWithNetwork crypto.Hash, round uint64) ([]*common.SnapshotWithTopologicalOrder, error)
ReadRound(hash crypto.Hash) (*common.Round, error)
ReadLink(from, to crypto.Hash) (uint64, error)
WriteSnapshot(*common.SnapshotWithTopologicalOrder, []crypto.Hash) error
ReadCustodian(ts uint64) (*common.CustodianUpdateRequest, error)
ListCustodianUpdates() ([]*common.CustodianUpdateRequest, error)
CacheStoreTransaction(tx *common.VersionedTransaction) error
CacheQueueTransaction(tx *common.VersionedTransaction) error
CacheGetTransaction(hash crypto.Hash) (*common.VersionedTransaction, error)
CacheRetrieveTransactions(limit int) ([]*common.VersionedTransaction, error)
CacheRemoveTransactions([]crypto.Hash) error
ReadLastMintDistribution(batch uint64) (*common.MintDistribution, error)
LockMintInput(mint *common.MintData, tx crypto.Hash, fork bool) error
ReadMintDistributions(offset, count uint64) ([]*common.MintDistribution, []*common.VersionedTransaction, error)
ReadSnapshotWorksForNodeRound(nodeId crypto.Hash, round uint64) ([]*common.SnapshotWork, error)
ListWorkOffsets(cids []crypto.Hash) (map[crypto.Hash]uint64, error)
ListNodeWorks(cids []crypto.Hash, day uint32) (map[crypto.Hash][2]uint64, error)
ReadWorkOffset(nodeId crypto.Hash) (uint64, error)
WriteRoundWork(nodeId crypto.Hash, round uint64, snapshots []*common.SnapshotWork, credit bool) error
ReadRoundSpaceCheckpoint(nodeId crypto.Hash) (uint64, uint64, error)
WriteRoundSpaceAndState(space *common.RoundSpace) error
ListAggregatedRoundSpaceCheckpoints(cids []crypto.Hash) (map[crypto.Hash]*common.RoundSpace, error)
ReadNodeRoundSpacesForBatch(nodeId crypto.Hash, batch uint64) ([]*common.RoundSpace, error)
RemoveGraphEntries(prefix string) (int, error)
ValidateGraphEntries(networkId crypto.Hash, depth uint64) (int, int, error)
}