Documentation
¶
Overview ¶
Package pchain provides the P-Chain (Platform) adapter for the LINEAR chain indexer. Handles validators, delegators, subnets, and staking operations.
Index ¶
- Constants
- func NewConfig() chain.Config
- type Adapter
- func (a *Adapter) GetBlockByHeight(ctx context.Context, height uint64) (json.RawMessage, error)
- func (a *Adapter) GetBlockByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) GetBlockchains(ctx context.Context) ([]Blockchain, error)
- func (a *Adapter) GetCurrentValidators(ctx context.Context, netID string) ([]Validator, error)
- func (a *Adapter) GetNets(ctx context.Context) ([]Net, error)
- func (a *Adapter) GetPendingValidators(ctx context.Context, netID string) ([]Validator, error)
- func (a *Adapter) GetRecentBlocks(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseBlock(data json.RawMessage) (*chain.Block, error)
- func (a *Adapter) SyncValidators(ctx context.Context, store storage.Store) error
- type Blockchain
- type Delegator
- type Net
- type PChainBlock
- type PChainTx
- type Validator
Constants ¶
const ( DefaultRPCEndpoint = "http://localhost:9650/ext/bc/P" DefaultHTTPPort = 4100 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements chain.Adapter for P-Chain
func (*Adapter) GetBlockByHeight ¶
GetBlockByHeight implements chain.Adapter
func (*Adapter) GetBlockByID ¶
GetBlockByID implements chain.Adapter
func (*Adapter) GetBlockchains ¶
func (a *Adapter) GetBlockchains(ctx context.Context) ([]Blockchain, error)
GetBlockchains fetches all blockchains from RPC
func (*Adapter) GetCurrentValidators ¶
GetCurrentValidators fetches current validators from RPC
func (*Adapter) GetPendingValidators ¶
GetPendingValidators fetches pending validators from RPC
func (*Adapter) GetRecentBlocks ¶
GetRecentBlocks implements chain.Adapter
func (*Adapter) GetStats ¶
func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
GetStats implements chain.Adapter - returns P-Chain specific statistics
func (*Adapter) InitSchema ¶
InitSchema implements chain.Adapter - creates P-Chain specific tables
func (*Adapter) ParseBlock ¶
ParseBlock implements chain.Adapter
type Blockchain ¶
type Blockchain struct {
ID string `json:"id"`
Name string `json:"name"`
NetID string `json:"netID"`
VMID string `json:"vmID"`
}
Blockchain represents a P-Chain blockchain
type Delegator ¶
type Delegator struct {
TxID string `json:"txID"`
NodeID string `json:"nodeID"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
StakeAmount string `json:"stakeAmount"`
PotentialReward string `json:"potentialReward"`
RewardOwner string `json:"rewardOwner,omitempty"`
}
Delegator represents a P-Chain delegator
type Net ¶
type Net struct {
ID string `json:"id"`
ControlKeys []string `json:"controlKeys"`
Threshold string `json:"threshold"`
}
Net represents a P-Chain network/chain
type PChainBlock ¶
type PChainBlock struct {
ID string `json:"id"`
ParentID string `json:"parentID"`
Height uint64 `json:"height"`
Timestamp int64 `json:"timestamp"` // Unix timestamp
Txs []PChainTx `json:"txs"`
}
PChainBlock represents a P-Chain block from RPC
type PChainTx ¶
type PChainTx struct {
ID string `json:"id"`
Type string `json:"type"`
Inputs json.RawMessage `json:"inputs,omitempty"`
Outputs json.RawMessage `json:"outputs,omitempty"`
Credentials json.RawMessage `json:"credentials,omitempty"`
// Validator-specific fields
NodeID string `json:"nodeID,omitempty"`
StartTime int64 `json:"startTime,omitempty"`
EndTime int64 `json:"endTime,omitempty"`
Weight uint64 `json:"weight,omitempty"`
NetID string `json:"netID,omitempty"` // For subnet operations
}
PChainTx represents a P-Chain transaction
type Validator ¶
type Validator struct {
TxID string `json:"txID"`
NodeID string `json:"nodeID"`
StartTime string `json:"startTime"`
EndTime string `json:"endTime"`
Weight string `json:"weight"`
StakeAmount string `json:"stakeAmount,omitempty"` // Deprecated, use Weight
PotentialReward string `json:"potentialReward"`
DelegationFee string `json:"delegationFee"`
Uptime string `json:"uptime"`
Connected bool `json:"connected"`
Delegators []Delegator `json:"delegators,omitempty"`
}
Validator represents a P-Chain validator