Documentation
¶
Overview ¶
Package chain provides shared linear chain indexing for LUX chains (P). Based on luxfi/consensus/engine/chain/block - single parent per block.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
ParseBlock(data json.RawMessage) (*Block, error)
GetRecentBlocks(ctx context.Context, limit int) ([]json.RawMessage, error)
GetBlockByID(ctx context.Context, id string) (json.RawMessage, error)
GetBlockByHeight(ctx context.Context, height uint64) (json.RawMessage, error)
InitSchema(ctx context.Context, store storage.Store) error
GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
}
Adapter interface for chain-specific logic
type Block ¶
type Block struct {
ID string `json:"id"`
ParentID string `json:"parentId"` // Single parent (linear)
Height uint64 `json:"height"`
Timestamp time.Time `json:"timestamp"`
Status Status `json:"status"`
TxCount int `json:"txCount,omitempty"`
TxIDs []string `json:"txIds,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
Block represents a linear chain block (from luxfi/consensus) Single parent only (linear chain structure)
type ChainType ¶
type ChainType string
ChainType identifies the linear chain
const (
ChainP ChainType = "pchain" // Platform - validators, staking
)
type Config ¶
type Config struct {
ChainType ChainType
ChainName string
RPCEndpoint string
RPCMethod string // pvm
HTTPPort int
PollInterval time.Duration
DataDir string // For default storage
}
Config for chain indexer
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer for linear chains
func (*Indexer) StoreBlock ¶
StoreBlock stores a block and broadcasts to subscribers
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
Poller polls for new blocks
func NewPoller ¶
func NewPoller(idx *Indexer, sub *Subscriber) *Poller
type Stats ¶
type Stats struct {
TotalBlocks int64 `json:"total_blocks"`
LatestHeight uint64 `json:"latest_height"`
PendingBlocks int64 `json:"pending_blocks"`
AcceptedBlocks int64 `json:"accepted_blocks"`
ChainType ChainType `json:"chain_type"`
LastUpdated time.Time `json:"last_updated"`
}
Stats for linear chain
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber handles WebSocket for live block streaming
func NewSubscriber ¶
func NewSubscriber(ct ChainType) *Subscriber
func (*Subscriber) BroadcastBlock ¶
func (s *Subscriber) BroadcastBlock(b *Block)
func (*Subscriber) ClientCount ¶
func (s *Subscriber) ClientCount() int
func (*Subscriber) HandleWebSocket ¶
func (s *Subscriber) HandleWebSocket(w http.ResponseWriter, r *http.Request)
func (*Subscriber) Run ¶
func (s *Subscriber) Run(ctx context.Context)
Click to show internal directories.
Click to hide internal directories.