Documentation
¶
Overview ¶
Package storage provides abstractions and implementations for storing and retrieving transaction outputs in overlay services.
The package includes implementations for:
- Redis: High-performance in-memory storage with persistence
- MongoDB: Document-based storage with flexible querying
- SQLite: Embedded database with full SQL support and WAL mode
Key Features:
- Transaction output storage and retrieval
- Topic-based output organization
- Interaction tracking between hosts and topics
- Integration with BEEF storage and event publishing
- Database-agnostic queue management operations
EventDataStorage Interface:
All storage backends implement the EventDataStorage interface which extends engine.Storage with event-based querying and data management.
Storage implementations handle:
- Output insertion and updates
- Spent/unspent status tracking
- Block height updates
- Topic membership management
- Applied transaction tracking
- Event management and querying
Example Usage:
// Create Redis storage with EventDataStorage interface storage, err := storage.NewRedisEventDataStorage( "redis://localhost:6379", beefStore, publisher ) // Insert an output err = storage.InsertOutput(ctx, output) // Find outputs for a topic outputs, err := storage.FindUTXOsForTopic(ctx, "my-topic", 0, 100) // Save events for an output err = storage.SaveEvents(ctx, outpoint, []string{"event1", "event2"}, 850000, 123, eventData) // Create SQLite storage with EventDataStorage interface sqliteStorage, err := storage.NewSQLiteEventDataStorage( "/path/to/database.db", beefStore, publisher )
Index ¶
- Constants
- func OutMembershipKey(topic string) string
- func OutputTopicKey(outpoint *transaction.Outpoint, topic string) string
- func TxMembershipKey(topic string) string
- type BSONBeef
- type BSONOutput
- type BaseEventDataStorage
- type EventDataStorage
- type EventQuestion
- type JoinType
- type MongoEventDataStorage
- func (s *MongoEventDataStorage) DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
- func (s *MongoEventDataStorage) DoesAppliedTransactionExist(ctx context.Context, tx *overlay.AppliedTransaction) (bool, error)
- func (s *MongoEventDataStorage) FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error)
- func (s *MongoEventDataStorage) FindOutput(ctx context.Context, outpoint *transaction.Outpoint, topic *string, ...) (o *engine.Output, err error)
- func (s *MongoEventDataStorage) FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error)
- func (s *MongoEventDataStorage) FindOutputs(ctx context.Context, outpoints []*transaction.Outpoint, topic string, ...) ([]*engine.Output, error)
- func (s *MongoEventDataStorage) FindOutputsForTransaction(ctx context.Context, txid *chainhash.Hash, includeBEEF bool) ([]*engine.Output, error)
- func (s *MongoEventDataStorage) FindUTXOsForTopic(ctx context.Context, topic string, since float64, limit uint32, ...) ([]*engine.Output, error)
- func (s *MongoEventDataStorage) GetLastInteraction(ctx context.Context, host string, topic string) (float64, error)
- func (s *MongoEventDataStorage) GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error)
- func (s *MongoEventDataStorage) GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error)
- func (s *MongoEventDataStorage) HDel(ctx context.Context, key string, fields ...string) error
- func (s *MongoEventDataStorage) HGet(ctx context.Context, key, field string) (string, error)
- func (s *MongoEventDataStorage) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (s *MongoEventDataStorage) HSet(ctx context.Context, key, field, value string) error
- func (s *MongoEventDataStorage) InsertAppliedTransaction(ctx context.Context, tx *overlay.AppliedTransaction) error
- func (s *MongoEventDataStorage) InsertOutput(ctx context.Context, utxo *engine.Output) (err error)
- func (s *MongoEventDataStorage) LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error)
- func (s *MongoEventDataStorage) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error)
- func (s *MongoEventDataStorage) LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error)
- func (s *MongoEventDataStorage) MarkUTXOAsSpent(ctx context.Context, outpoint *transaction.Outpoint, topic string, beef []byte) error
- func (s *MongoEventDataStorage) MarkUTXOsAsSpent(ctx context.Context, outpoints []*transaction.Outpoint, topic string, ...) error
- func (s *MongoEventDataStorage) SAdd(ctx context.Context, key string, members ...string) error
- func (s *MongoEventDataStorage) SIsMember(ctx context.Context, key, member string) (bool, error)
- func (s *MongoEventDataStorage) SMembers(ctx context.Context, key string) ([]string, error)
- func (s *MongoEventDataStorage) SRem(ctx context.Context, key string, members ...string) error
- func (s *MongoEventDataStorage) SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, ...) error
- func (s *MongoEventDataStorage) UpdateConsumedBy(ctx context.Context, outpoint *transaction.Outpoint, topic string, ...) error
- func (s *MongoEventDataStorage) UpdateLastInteraction(ctx context.Context, host string, topic string, since float64) error
- func (s *MongoEventDataStorage) UpdateOutputBlockHeight(ctx context.Context, outpoint *transaction.Outpoint, topic string, ...) error
- func (s *MongoEventDataStorage) UpdateTransactionBEEF(ctx context.Context, txid *chainhash.Hash, beef []byte) error
- func (s *MongoEventDataStorage) ZAdd(ctx context.Context, key string, members ...ScoredMember) error
- func (s *MongoEventDataStorage) ZCard(ctx context.Context, key string) (int64, error)
- func (s *MongoEventDataStorage) ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error)
- func (s *MongoEventDataStorage) ZRem(ctx context.Context, key string, members ...string) error
- func (s *MongoEventDataStorage) ZScore(ctx context.Context, key, member string) (float64, error)
- type OutpointResult
- type OutputData
- type RedisEventDataStorage
- func (s *RedisEventDataStorage) Close() error
- func (s *RedisEventDataStorage) DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
- func (s *RedisEventDataStorage) DoesAppliedTransactionExist(ctx context.Context, tx *overlay.AppliedTransaction) (bool, error)
- func (s *RedisEventDataStorage) FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error)
- func (s *RedisEventDataStorage) FindOutput(ctx context.Context, outpoint *transaction.Outpoint, topic *string, ...) (o *engine.Output, err error)
- func (s *RedisEventDataStorage) FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error)
- func (s *RedisEventDataStorage) FindOutputs(ctx context.Context, outpoints []*transaction.Outpoint, topic string, ...) ([]*engine.Output, error)
- func (s *RedisEventDataStorage) FindOutputsForTransaction(ctx context.Context, txid *chainhash.Hash, includeBEEF bool) ([]*engine.Output, error)
- func (s *RedisEventDataStorage) FindUTXOsForTopic(ctx context.Context, topic string, since float64, limit uint32, ...) ([]*engine.Output, error)
- func (s *RedisEventDataStorage) GetLastInteraction(ctx context.Context, host string, topic string) (float64, error)
- func (s *RedisEventDataStorage) GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error)
- func (s *RedisEventDataStorage) GetRedisClient() *redis.Client
- func (s *RedisEventDataStorage) GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error)
- func (s *RedisEventDataStorage) HDel(ctx context.Context, key string, fields ...string) error
- func (s *RedisEventDataStorage) HGet(ctx context.Context, key, field string) (string, error)
- func (s *RedisEventDataStorage) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (s *RedisEventDataStorage) HSet(ctx context.Context, key, field, value string) error
- func (s *RedisEventDataStorage) InsertAppliedTransaction(ctx context.Context, tx *overlay.AppliedTransaction) error
- func (s *RedisEventDataStorage) InsertOutput(ctx context.Context, utxo *engine.Output) (err error)
- func (s *RedisEventDataStorage) LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error)
- func (s *RedisEventDataStorage) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error)
- func (s *RedisEventDataStorage) LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error)
- func (s *RedisEventDataStorage) MarkUTXOAsSpent(ctx context.Context, outpoint *transaction.Outpoint, topic string, beef []byte) error
- func (s *RedisEventDataStorage) MarkUTXOsAsSpent(ctx context.Context, outpoints []*transaction.Outpoint, topic string, ...) error
- func (s *RedisEventDataStorage) SAdd(ctx context.Context, key string, members ...string) error
- func (s *RedisEventDataStorage) SIsMember(ctx context.Context, key, member string) (bool, error)
- func (s *RedisEventDataStorage) SMembers(ctx context.Context, key string) ([]string, error)
- func (s *RedisEventDataStorage) SRem(ctx context.Context, key string, members ...string) error
- func (s *RedisEventDataStorage) SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, ...) error
- func (s *RedisEventDataStorage) UpdateConsumedBy(ctx context.Context, outpoint *transaction.Outpoint, topic string, ...) error
- func (s *RedisEventDataStorage) UpdateLastInteraction(ctx context.Context, host string, topic string, since float64) error
- func (s *RedisEventDataStorage) UpdateOutputBlockHeight(ctx context.Context, outpoint *transaction.Outpoint, topic string, ...) error
- func (s *RedisEventDataStorage) UpdateTransactionBEEF(ctx context.Context, txid *chainhash.Hash, beef []byte) error
- func (s *RedisEventDataStorage) ZAdd(ctx context.Context, key string, members ...ScoredMember) error
- func (s *RedisEventDataStorage) ZCard(ctx context.Context, key string) (int64, error)
- func (s *RedisEventDataStorage) ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error)
- func (s *RedisEventDataStorage) ZRem(ctx context.Context, key string, members ...string) error
- func (s *RedisEventDataStorage) ZScore(ctx context.Context, key, member string) (float64, error)
- type SQLiteEventDataStorage
- func (s *SQLiteEventDataStorage) Close() error
- func (s *SQLiteEventDataStorage) DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
- func (s *SQLiteEventDataStorage) DoesAppliedTransactionExist(ctx context.Context, tx *overlay.AppliedTransaction) (bool, error)
- func (s *SQLiteEventDataStorage) FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error)
- func (s *SQLiteEventDataStorage) FindOutput(ctx context.Context, outpoint *transaction.Outpoint, topic *string, ...) (*engine.Output, error)
- func (s *SQLiteEventDataStorage) FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error)
- func (s *SQLiteEventDataStorage) FindOutputs(ctx context.Context, outpoints []*transaction.Outpoint, topic string, ...) ([]*engine.Output, error)
- func (s *SQLiteEventDataStorage) FindOutputsForTransaction(ctx context.Context, txid *chainhash.Hash, includeBEEF bool) ([]*engine.Output, error)
- func (s *SQLiteEventDataStorage) FindUTXOsForTopic(ctx context.Context, topic string, since float64, limit uint32, ...) ([]*engine.Output, error)
- func (s *SQLiteEventDataStorage) GetLastInteraction(ctx context.Context, host string, topic string) (float64, error)
- func (s *SQLiteEventDataStorage) GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error)
- func (s *SQLiteEventDataStorage) GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error)
- func (s *SQLiteEventDataStorage) HDel(ctx context.Context, key string, fields ...string) error
- func (s *SQLiteEventDataStorage) HGet(ctx context.Context, key, field string) (string, error)
- func (s *SQLiteEventDataStorage) HGetAll(ctx context.Context, key string) (map[string]string, error)
- func (s *SQLiteEventDataStorage) HSet(ctx context.Context, key, field, value string) error
- func (s *SQLiteEventDataStorage) InsertAppliedTransaction(ctx context.Context, tx *overlay.AppliedTransaction) error
- func (s *SQLiteEventDataStorage) InsertOutput(ctx context.Context, utxo *engine.Output) error
- func (s *SQLiteEventDataStorage) LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error)
- func (s *SQLiteEventDataStorage) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error)
- func (s *SQLiteEventDataStorage) LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error)
- func (s *SQLiteEventDataStorage) MarkUTXOsAsSpent(ctx context.Context, outpoints []*transaction.Outpoint, topic string, ...) error
- func (s *SQLiteEventDataStorage) SAdd(ctx context.Context, key string, members ...string) error
- func (s *SQLiteEventDataStorage) SIsMember(ctx context.Context, key, member string) (bool, error)
- func (s *SQLiteEventDataStorage) SMembers(ctx context.Context, key string) ([]string, error)
- func (s *SQLiteEventDataStorage) SRem(ctx context.Context, key string, members ...string) error
- func (s *SQLiteEventDataStorage) SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, ...) error
- func (s *SQLiteEventDataStorage) UpdateConsumedBy(ctx context.Context, outpoint *transaction.Outpoint, topic string, ...) error
- func (s *SQLiteEventDataStorage) UpdateLastInteraction(ctx context.Context, host string, topic string, since float64) error
- func (s *SQLiteEventDataStorage) UpdateOutputBlockHeight(ctx context.Context, outpoint *transaction.Outpoint, topic string, ...) error
- func (s *SQLiteEventDataStorage) UpdateTransactionBEEF(ctx context.Context, txid *chainhash.Hash, beef []byte) error
- func (s *SQLiteEventDataStorage) ZAdd(ctx context.Context, key string, members ...ScoredMember) error
- func (s *SQLiteEventDataStorage) ZCard(ctx context.Context, key string) (int64, error)
- func (s *SQLiteEventDataStorage) ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error)
- func (s *SQLiteEventDataStorage) ZRem(ctx context.Context, key string, members ...string) error
- func (s *SQLiteEventDataStorage) ZScore(ctx context.Context, key, member string) (float64, error)
- type ScoredMember
- type TransactionData
Constants ¶
const SpendsKey = "spends"
Variables ¶
This section is empty.
Functions ¶
func OutMembershipKey ¶
func OutputTopicKey ¶
func OutputTopicKey(outpoint *transaction.Outpoint, topic string) string
func TxMembershipKey ¶
Types ¶
type BSONOutput ¶
type BSONOutput struct { Outpoint string `bson:"outpoint"` Txid string `bson:"txid"` Topic string `bson:"topic"` Script []byte `bson:"script"` Satoshis uint64 `bson:"satoshis"` Spend *string `bson:"spend"` // Changed from Spent bool to Spend *string OutputsConsumed []string `bson:"outputsConsumed"` ConsumedBy []string `bson:"consumedBy"` BlockHeight uint32 `bson:"blockHeight"` BlockIdx uint64 `bson:"blockIdx"` Score float64 `bson:"score"` AncillaryTxids []string `bson:"ancillaryTxids"` AncillaryBeef []byte `bson:"ancillaryBeef"` Events []string `bson:"events"` // Event names this output is associated with Data interface{} `bson:"data,omitempty"` // Arbitrary data associated with the output }
func NewBSONOutput ¶
func NewBSONOutput(o *engine.Output) *BSONOutput
func (*BSONOutput) ToEngineOutput ¶
func (o *BSONOutput) ToEngineOutput() *engine.Output
type BaseEventDataStorage ¶
type BaseEventDataStorage struct {
// contains filtered or unexported fields
}
BaseEventDataStorage provides common fields and methods for all EventDataStorage implementations This uses Go's struct embedding to achieve code reuse across different storage backends
func NewBaseEventDataStorage ¶
func NewBaseEventDataStorage(beefStore beef.BeefStorage, pubsub pubsub.PubSub) BaseEventDataStorage
NewBaseEventDataStorage creates a new BaseEventDataStorage with the given dependencies
func (*BaseEventDataStorage) GetBeefStorage ¶
func (b *BaseEventDataStorage) GetBeefStorage() beef.BeefStorage
GetBeefStorage returns the underlying BEEF storage implementation
func (*BaseEventDataStorage) GetPubSub ¶
func (b *BaseEventDataStorage) GetPubSub() pubsub.PubSub
GetPubSub returns the PubSub interface for event publishing and buffering Returns nil if no pubsub is configured
type EventDataStorage ¶
type EventDataStorage interface { engine.Storage // GetBeefStorage returns the underlying BEEF storage implementation GetBeefStorage() beef.BeefStorage // GetPubSub returns the PubSub interface for event publishing and buffering // Returns nil if no pubsub is configured GetPubSub() pubsub.PubSub // LoadBeefByTxidAndTopic loads merged BEEF for a transaction within a topic context // Finds any output for the txid in the topic, merges main BEEF with AncillaryBeef, // and returns atomic BEEF bytes for the transaction LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error) // Block Data Methods // GetTransactionsByTopicAndHeight returns all transactions for a topic at a specific block height // Returns transaction structure with inputs/outputs but no protocol-specific data fields GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error) // Event Management Methods // SaveEvents associates multiple events with a single output, storing arbitrary data SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, topic string, height uint32, idx uint64, data interface{}) error // FindEvents returns all events associated with a given outpoint FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error) // Event Query Methods // LookupOutpoints returns outpoints matching the given query criteria LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error) // LookupEventScores returns lightweight event scores for simple queries (no parsing/data loading) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error) // GetOutputData retrieves the data associated with a specific output GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error) // FindOutputData returns outputs matching the given query criteria as OutputData objects // Supports paging with score-based 'from' parameter and can include spent outputs for history FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error) // Set Operations - for whitelists, topic management, etc. SAdd(ctx context.Context, key string, members ...string) error SMembers(ctx context.Context, key string) ([]string, error) SRem(ctx context.Context, key string, members ...string) error SIsMember(ctx context.Context, key, member string) (bool, error) // Hash Operations - for peer configurations, output data, etc. HSet(ctx context.Context, key, field, value string) error HGet(ctx context.Context, key, field string) (string, error) HGetAll(ctx context.Context, key string) (map[string]string, error) HDel(ctx context.Context, key string, fields ...string) error // Sorted Set Operations - for queues, progress tracking, event scoring, etc. ZAdd(ctx context.Context, key string, members ...ScoredMember) error ZRem(ctx context.Context, key string, members ...string) error ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error) ZScore(ctx context.Context, key, member string) (float64, error) ZCard(ctx context.Context, key string) (int64, error) }
EventDataStorage extends the base Storage interface with event data and lookup capabilities This consolidates all database operations into a single storage interface
func CreateEventDataStorage ¶
func CreateEventDataStorage(connectionString string, beefStore beef.BeefStorage, pubSubURL string) (EventDataStorage, error)
CreateEventDataStorage creates the appropriate EventDataStorage implementation from a connection string. Auto-detects the storage type from the URL scheme.
Supported formats:
- redis://localhost:6379
- mongodb://localhost:27017/dbname
- sqlite:///path/to/overlay.db or sqlite://overlay.db
- ./overlay.db (inferred as SQLite)
If no connection string is provided, defaults to ./overlay.db The pubSubURL parameter is optional and specifies the pub/sub backend:
- redis://localhost:6379 (for Redis pub/sub)
- channels:// (for in-memory channel-based pub/sub)
- "" (defaults to channels://)
type EventQuestion ¶
type EventQuestion struct { Event string `json:"event"` Events []string `json:"events"` Topic string `json:"topic"` // Required topic scoping JoinType *JoinType `json:"join"` From float64 `json:"from"` Until float64 `json:"until"` Limit int `json:"limit"` UnspentOnly bool `json:"unspentOnly"` Reverse bool `json:"rev"` }
EventQuestion defines query parameters for event-based lookups
type JoinType ¶
type JoinType int
JoinType defines how multiple events are combined in queries
const ( // JoinTypeIntersect returns outputs that have ALL specified events JoinTypeIntersect JoinType = iota // JoinTypeUnion returns outputs that have ANY of the specified events JoinTypeUnion // JoinTypeDifference returns outputs from first event minus those in subsequent events JoinTypeDifference )
type MongoEventDataStorage ¶
type MongoEventDataStorage struct { BaseEventDataStorage DB *mongo.Database }
func NewMongoEventDataStorage ¶
func NewMongoEventDataStorage(connString string, beefStore beef.BeefStorage, pubsub pubsub.PubSub) (*MongoEventDataStorage, error)
func (*MongoEventDataStorage) DeleteOutput ¶
func (s *MongoEventDataStorage) DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
func (*MongoEventDataStorage) DoesAppliedTransactionExist ¶
func (s *MongoEventDataStorage) DoesAppliedTransactionExist(ctx context.Context, tx *overlay.AppliedTransaction) (bool, error)
func (*MongoEventDataStorage) FindEvents ¶
func (s *MongoEventDataStorage) FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error)
FindEvents returns all events associated with a given outpoint
func (*MongoEventDataStorage) FindOutput ¶
func (*MongoEventDataStorage) FindOutputData ¶
func (s *MongoEventDataStorage) FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error)
FindOutputData returns outputs matching the given query criteria as OutputData objects
func (*MongoEventDataStorage) FindOutputs ¶
func (*MongoEventDataStorage) FindOutputsForTransaction ¶
func (*MongoEventDataStorage) FindUTXOsForTopic ¶
func (*MongoEventDataStorage) GetLastInteraction ¶
func (*MongoEventDataStorage) GetOutputData ¶
func (s *MongoEventDataStorage) GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error)
GetOutputData retrieves the data associated with a specific output
func (*MongoEventDataStorage) GetTransactionsByTopicAndHeight ¶
func (s *MongoEventDataStorage) GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error)
GetTransactionsByTopicAndHeight returns all transactions for a topic at a specific block height
func (*MongoEventDataStorage) HSet ¶
func (s *MongoEventDataStorage) HSet(ctx context.Context, key, field, value string) error
Hash Operations - store fields directly in document (no nested fields object)
func (*MongoEventDataStorage) InsertAppliedTransaction ¶
func (s *MongoEventDataStorage) InsertAppliedTransaction(ctx context.Context, tx *overlay.AppliedTransaction) error
func (*MongoEventDataStorage) InsertOutput ¶
func (*MongoEventDataStorage) LoadBeefByTxidAndTopic ¶ added in v0.3.0
func (s *MongoEventDataStorage) LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error)
LoadBeefByTxidAndTopic loads merged BEEF for a transaction within a topic context
func (*MongoEventDataStorage) LookupEventScores ¶
func (s *MongoEventDataStorage) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error)
LookupEventScores returns lightweight event scores for simple queries
func (*MongoEventDataStorage) LookupOutpoints ¶
func (s *MongoEventDataStorage) LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error)
LookupOutpoints returns outpoints matching the given query criteria using aggregations for performance
func (*MongoEventDataStorage) MarkUTXOAsSpent ¶
func (s *MongoEventDataStorage) MarkUTXOAsSpent(ctx context.Context, outpoint *transaction.Outpoint, topic string, beef []byte) error
func (*MongoEventDataStorage) MarkUTXOsAsSpent ¶
func (s *MongoEventDataStorage) MarkUTXOsAsSpent(ctx context.Context, outpoints []*transaction.Outpoint, topic string, spendTxid *chainhash.Hash) error
func (*MongoEventDataStorage) SAdd ¶
Set Operations - implemented using MongoDB's native $addToSet operations
func (*MongoEventDataStorage) SaveEvents ¶
func (s *MongoEventDataStorage) SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, topic string, height uint32, idx uint64, data interface{}) error
SaveEvents associates multiple events with a single output, storing arbitrary data
func (*MongoEventDataStorage) UpdateConsumedBy ¶
func (s *MongoEventDataStorage) UpdateConsumedBy(ctx context.Context, outpoint *transaction.Outpoint, topic string, consumedBy []*transaction.Outpoint) error
func (*MongoEventDataStorage) UpdateLastInteraction ¶
func (*MongoEventDataStorage) UpdateOutputBlockHeight ¶
func (s *MongoEventDataStorage) UpdateOutputBlockHeight(ctx context.Context, outpoint *transaction.Outpoint, topic string, blockHeight uint32, blockIndex uint64, ancelliaryBeef []byte) error
func (*MongoEventDataStorage) UpdateTransactionBEEF ¶
func (*MongoEventDataStorage) ZAdd ¶
func (s *MongoEventDataStorage) ZAdd(ctx context.Context, key string, members ...ScoredMember) error
Sorted Set Operations - using individual documents with indexed scores
func (*MongoEventDataStorage) ZRangeByScore ¶
func (s *MongoEventDataStorage) ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error)
type OutpointResult ¶
type OutpointResult struct { Outpoint *transaction.Outpoint `json:"outpoint"` Score float64 `json:"score"` Data interface{} `json:"data,omitempty"` }
OutpointResult contains the result of an outpoint lookup
type OutputData ¶
type OutputData struct { TxID *chainhash.Hash `json:"txid,omitempty"` // Transaction ID (for inputs: source txid, for outputs: current txid) Vout uint32 `json:"vout"` Data interface{} `json:"data,omitempty"` Script []byte `json:"script"` Satoshis uint64 `json:"satoshis"` Spend *chainhash.Hash `json:"spend,omitempty"` // Spending transaction ID (only populated if spent) Score float64 `json:"score"` // Sort score for ordering/pagination }
OutputData represents an input or output with its data
type RedisEventDataStorage ¶
type RedisEventDataStorage struct { BaseEventDataStorage DB *redis.Client }
func NewRedisEventDataStorage ¶
func NewRedisEventDataStorage(connString string, beefStore beef.BeefStorage, pubsub pubsub.PubSub) (r *RedisEventDataStorage, err error)
func (*RedisEventDataStorage) Close ¶
func (s *RedisEventDataStorage) Close() error
func (*RedisEventDataStorage) DeleteOutput ¶
func (s *RedisEventDataStorage) DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
func (*RedisEventDataStorage) DoesAppliedTransactionExist ¶
func (s *RedisEventDataStorage) DoesAppliedTransactionExist(ctx context.Context, tx *overlay.AppliedTransaction) (bool, error)
func (*RedisEventDataStorage) FindEvents ¶
func (s *RedisEventDataStorage) FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error)
FindEvents returns all events associated with a given outpoint
func (*RedisEventDataStorage) FindOutput ¶
func (*RedisEventDataStorage) FindOutputData ¶
func (s *RedisEventDataStorage) FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error)
FindOutputData returns outputs matching the given query criteria as OutputData objects
func (*RedisEventDataStorage) FindOutputs ¶
func (*RedisEventDataStorage) FindOutputsForTransaction ¶
func (*RedisEventDataStorage) FindUTXOsForTopic ¶
func (*RedisEventDataStorage) GetLastInteraction ¶
func (*RedisEventDataStorage) GetOutputData ¶
func (s *RedisEventDataStorage) GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error)
GetOutputData retrieves the data associated with a specific output
func (*RedisEventDataStorage) GetRedisClient ¶
func (s *RedisEventDataStorage) GetRedisClient() *redis.Client
GetRedisClient returns the underlying Redis client for direct access
func (*RedisEventDataStorage) GetTransactionsByTopicAndHeight ¶
func (s *RedisEventDataStorage) GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error)
GetTransactionsByTopicAndHeight returns all transactions for a topic at a specific block height
func (*RedisEventDataStorage) HSet ¶
func (s *RedisEventDataStorage) HSet(ctx context.Context, key, field, value string) error
Hash Operations
func (*RedisEventDataStorage) InsertAppliedTransaction ¶
func (s *RedisEventDataStorage) InsertAppliedTransaction(ctx context.Context, tx *overlay.AppliedTransaction) error
func (*RedisEventDataStorage) InsertOutput ¶
func (*RedisEventDataStorage) LoadBeefByTxidAndTopic ¶ added in v0.3.0
func (s *RedisEventDataStorage) LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error)
LoadBeefByTxidAndTopic loads merged BEEF for a transaction within a topic context
func (*RedisEventDataStorage) LookupEventScores ¶
func (s *RedisEventDataStorage) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error)
LookupEventScores returns lightweight event scores for simple queries
func (*RedisEventDataStorage) LookupOutpoints ¶
func (s *RedisEventDataStorage) LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error)
LookupOutpoints returns outpoints matching the given query criteria
func (*RedisEventDataStorage) MarkUTXOAsSpent ¶
func (s *RedisEventDataStorage) MarkUTXOAsSpent(ctx context.Context, outpoint *transaction.Outpoint, topic string, beef []byte) error
func (*RedisEventDataStorage) MarkUTXOsAsSpent ¶
func (s *RedisEventDataStorage) MarkUTXOsAsSpent(ctx context.Context, outpoints []*transaction.Outpoint, topic string, spendTxid *chainhash.Hash) error
func (*RedisEventDataStorage) SaveEvents ¶
func (s *RedisEventDataStorage) SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, topic string, height uint32, idx uint64, data interface{}) error
SaveEvents associates multiple events with a single output, storing arbitrary data
func (*RedisEventDataStorage) UpdateConsumedBy ¶
func (s *RedisEventDataStorage) UpdateConsumedBy(ctx context.Context, outpoint *transaction.Outpoint, topic string, consumedBy []*transaction.Outpoint) error
func (*RedisEventDataStorage) UpdateLastInteraction ¶
func (*RedisEventDataStorage) UpdateOutputBlockHeight ¶
func (s *RedisEventDataStorage) UpdateOutputBlockHeight(ctx context.Context, outpoint *transaction.Outpoint, topic string, blockHeight uint32, blockIndex uint64, ancelliaryBeef []byte) error
func (*RedisEventDataStorage) UpdateTransactionBEEF ¶
func (*RedisEventDataStorage) ZAdd ¶
func (s *RedisEventDataStorage) ZAdd(ctx context.Context, key string, members ...ScoredMember) error
Sorted Set Operations
func (*RedisEventDataStorage) ZRangeByScore ¶
func (s *RedisEventDataStorage) ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error)
type SQLiteEventDataStorage ¶
type SQLiteEventDataStorage struct { BaseEventDataStorage // contains filtered or unexported fields }
func NewSQLiteEventDataStorage ¶
func NewSQLiteEventDataStorage(dbPath string, beefStore beef.BeefStorage, pubsub pubsub.PubSub) (*SQLiteEventDataStorage, error)
func (*SQLiteEventDataStorage) Close ¶
func (s *SQLiteEventDataStorage) Close() error
func (*SQLiteEventDataStorage) DeleteOutput ¶
func (s *SQLiteEventDataStorage) DeleteOutput(ctx context.Context, outpoint *transaction.Outpoint, topic string) error
func (*SQLiteEventDataStorage) DoesAppliedTransactionExist ¶
func (s *SQLiteEventDataStorage) DoesAppliedTransactionExist(ctx context.Context, tx *overlay.AppliedTransaction) (bool, error)
func (*SQLiteEventDataStorage) FindEvents ¶
func (s *SQLiteEventDataStorage) FindEvents(ctx context.Context, outpoint *transaction.Outpoint) ([]string, error)
FindEvents returns all events associated with a given outpoint
func (*SQLiteEventDataStorage) FindOutput ¶
func (*SQLiteEventDataStorage) FindOutputData ¶
func (s *SQLiteEventDataStorage) FindOutputData(ctx context.Context, question *EventQuestion) ([]*OutputData, error)
FindOutputData returns outputs matching the given query criteria as OutputData objects
func (*SQLiteEventDataStorage) FindOutputs ¶
func (*SQLiteEventDataStorage) FindOutputsForTransaction ¶
func (*SQLiteEventDataStorage) FindUTXOsForTopic ¶
func (*SQLiteEventDataStorage) GetLastInteraction ¶
func (*SQLiteEventDataStorage) GetOutputData ¶
func (s *SQLiteEventDataStorage) GetOutputData(ctx context.Context, outpoint *transaction.Outpoint) (interface{}, error)
GetOutputData retrieves the data associated with a specific output
func (*SQLiteEventDataStorage) GetTransactionsByTopicAndHeight ¶
func (s *SQLiteEventDataStorage) GetTransactionsByTopicAndHeight(ctx context.Context, topic string, height uint32) ([]*TransactionData, error)
GetTransactionsByTopicAndHeight returns all transactions for a topic at a specific block height
func (*SQLiteEventDataStorage) HSet ¶
func (s *SQLiteEventDataStorage) HSet(ctx context.Context, key, field, value string) error
Hash Operations - implemented using SQLite tables
func (*SQLiteEventDataStorage) InsertAppliedTransaction ¶
func (s *SQLiteEventDataStorage) InsertAppliedTransaction(ctx context.Context, tx *overlay.AppliedTransaction) error
func (*SQLiteEventDataStorage) InsertOutput ¶
func (*SQLiteEventDataStorage) LoadBeefByTxidAndTopic ¶ added in v0.3.0
func (s *SQLiteEventDataStorage) LoadBeefByTxidAndTopic(ctx context.Context, txid *chainhash.Hash, topic string) ([]byte, error)
LoadBeefByTxidAndTopic loads merged BEEF for a transaction within a topic context
func (*SQLiteEventDataStorage) LookupEventScores ¶
func (s *SQLiteEventDataStorage) LookupEventScores(ctx context.Context, topic string, event string, fromScore float64) ([]ScoredMember, error)
LookupEventScores returns lightweight event scores for simple queries
func (*SQLiteEventDataStorage) LookupOutpoints ¶
func (s *SQLiteEventDataStorage) LookupOutpoints(ctx context.Context, question *EventQuestion, includeData ...bool) ([]*OutpointResult, error)
LookupOutpoints returns outpoints matching the given query criteria
func (*SQLiteEventDataStorage) MarkUTXOsAsSpent ¶
func (s *SQLiteEventDataStorage) MarkUTXOsAsSpent(ctx context.Context, outpoints []*transaction.Outpoint, topic string, spendTxid *chainhash.Hash) error
func (*SQLiteEventDataStorage) SaveEvents ¶
func (s *SQLiteEventDataStorage) SaveEvents(ctx context.Context, outpoint *transaction.Outpoint, events []string, topic string, height uint32, idx uint64, data interface{}) error
SaveEvents associates multiple events with a single output, storing arbitrary data
func (*SQLiteEventDataStorage) UpdateConsumedBy ¶
func (s *SQLiteEventDataStorage) UpdateConsumedBy(ctx context.Context, outpoint *transaction.Outpoint, topic string, consumedBy []*transaction.Outpoint) error
func (*SQLiteEventDataStorage) UpdateLastInteraction ¶
func (*SQLiteEventDataStorage) UpdateOutputBlockHeight ¶
func (s *SQLiteEventDataStorage) UpdateOutputBlockHeight(ctx context.Context, outpoint *transaction.Outpoint, topic string, blockHeight uint32, blockIndex uint64, ancillaryBeef []byte) error
func (*SQLiteEventDataStorage) UpdateTransactionBEEF ¶
func (*SQLiteEventDataStorage) ZAdd ¶
func (s *SQLiteEventDataStorage) ZAdd(ctx context.Context, key string, members ...ScoredMember) error
Sorted Set Operations - implemented using SQLite tables
func (*SQLiteEventDataStorage) ZRangeByScore ¶
func (s *SQLiteEventDataStorage) ZRangeByScore(ctx context.Context, key string, min, max float64, offset, count int64) ([]ScoredMember, error)
type ScoredMember ¶
ScoredMember represents a member with its score in sorted set operations
type TransactionData ¶
type TransactionData struct { TxID chainhash.Hash `json:"txid"` Inputs []*OutputData `json:"inputs"` Outputs []*OutputData `json:"outputs"` }
TransactionData represents a transaction with its inputs and outputs