Documentation
¶
Overview ¶
Package achain provides the A-Chain (AI) adapter for the DAG indexer. Handles AI compute attestations, model hashes, and inference results.
Index ¶
- Constants
- type AIProvider
- type AIReceipt
- type Adapter
- func (a *Adapter) GetRecentVertices(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) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) InitSchema(ctx context.Context, store storage.Store) error
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- func (a *Adapter) StoreAttestation(ctx context.Context, store storage.Store, att *ComputeAttestation, ...) error
- func (a *Adapter) StoreInference(ctx context.Context, store storage.Store, inf *InferenceResult, ...) error
- func (a *Adapter) StoreModel(ctx context.Context, store storage.Store, model *ModelRegistration, ...) error
- func (a *Adapter) StoreProvider(ctx context.Context, store storage.Store, provider *AIProvider, ...) error
- func (a *Adapter) StoreReceipt(ctx context.Context, store storage.Store, receipt *AIReceipt, vertexID string) error
- func (a *Adapter) StoreTrainingJob(ctx context.Context, store storage.Store, job *TrainingJob, vertexID string) error
- type AttestationType
- type ComputeAttestation
- type InferenceResult
- type ModelRegistration
- type TrainingJob
Constants ¶
const ( // DefaultPort for A-Chain indexer API DefaultPort = 4500 // DefaultDatabase name DefaultDatabase = "explorer_achain" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIProvider ¶
type AIProvider struct {
ID string `json:"id"`
Address string `json:"address"`
Name string `json:"name"`
Reputation float64 `json:"reputation"`
Capacity uint64 `json:"capacity"`
Active bool `json:"active"`
Timestamp time.Time `json:"timestamp"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
AIProvider represents an AI compute provider
type AIReceipt ¶
type AIReceipt struct {
ID string `json:"id"`
AttestationID string `json:"attestationId"`
Provider string `json:"provider"`
Requester string `json:"requester"`
Amount uint64 `json:"amount"`
Currency string `json:"currency"`
Status string `json:"status"`
Timestamp time.Time `json:"timestamp"`
}
AIReceipt represents a payment receipt for AI compute services
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements dag.Adapter for A-Chain
func (*Adapter) GetRecentVertices ¶
GetRecentVertices fetches recent vertices from A-Chain via RPC
func (*Adapter) GetStats ¶
func (a *Adapter) GetStats(ctx context.Context, store storage.Store) (map[string]interface{}, error)
GetStats returns A-Chain specific statistics
func (*Adapter) GetVertexByID ¶
GetVertexByID fetches a specific vertex by ID
func (*Adapter) InitSchema ¶
InitSchema creates A-Chain specific database tables
func (*Adapter) ParseVertex ¶
ParseVertex parses A-Chain vertex data from RPC response
func (*Adapter) StoreAttestation ¶
func (a *Adapter) StoreAttestation(ctx context.Context, store storage.Store, att *ComputeAttestation, vertexID string) error
StoreAttestation stores a compute attestation
func (*Adapter) StoreInference ¶
func (a *Adapter) StoreInference(ctx context.Context, store storage.Store, inf *InferenceResult, vertexID string) error
StoreInference stores an inference result
func (*Adapter) StoreModel ¶
func (a *Adapter) StoreModel(ctx context.Context, store storage.Store, model *ModelRegistration, vertexID string) error
StoreModel stores a model registration
func (*Adapter) StoreProvider ¶
func (a *Adapter) StoreProvider(ctx context.Context, store storage.Store, provider *AIProvider, vertexID string) error
StoreProvider stores or updates a provider registration
func (*Adapter) StoreReceipt ¶
func (a *Adapter) StoreReceipt(ctx context.Context, store storage.Store, receipt *AIReceipt, vertexID string) error
StoreReceipt stores a payment receipt
func (*Adapter) StoreTrainingJob ¶
func (a *Adapter) StoreTrainingJob(ctx context.Context, store storage.Store, job *TrainingJob, vertexID string) error
StoreTrainingJob stores a training job
type AttestationType ¶
type AttestationType string
AttestationType categorizes AI attestations
const ( AttestationCompute AttestationType = "compute" // Compute job attestation AttestationModel AttestationType = "model" // Model registration AttestationInference AttestationType = "inference" // Inference result AttestationTraining AttestationType = "training" // Training job )
type ComputeAttestation ¶
type ComputeAttestation struct {
ID string `json:"id"`
Type AttestationType `json:"type"`
ModelHash string `json:"modelHash,omitempty"`
InputHash string `json:"inputHash,omitempty"`
OutputHash string `json:"outputHash,omitempty"`
ComputeUnits uint64 `json:"computeUnits"`
Provider string `json:"provider"`
Requester string `json:"requester"`
Timestamp time.Time `json:"timestamp"`
Status string `json:"status"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
ComputeAttestation represents an AI compute attestation
type InferenceResult ¶
type InferenceResult struct {
ID string `json:"id"`
ModelID string `json:"modelId"`
InputHash string `json:"inputHash"`
OutputHash string `json:"outputHash"`
Confidence float64 `json:"confidence,omitempty"`
Latency time.Duration `json:"latency"`
Provider string `json:"provider"`
Timestamp time.Time `json:"timestamp"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
InferenceResult represents an AI inference result
type ModelRegistration ¶
type ModelRegistration struct {
ID string `json:"id"`
ModelHash string `json:"modelHash"`
Name string `json:"name"`
Version string `json:"version"`
Owner string `json:"owner"`
Framework string `json:"framework,omitempty"`
Parameters uint64 `json:"parameters,omitempty"`
Timestamp time.Time `json:"timestamp"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
ModelRegistration represents a registered AI model
type TrainingJob ¶
type TrainingJob struct {
ID string `json:"id"`
ModelID string `json:"modelId"`
DatasetHash string `json:"datasetHash"`
Epochs int `json:"epochs"`
BatchSize int `json:"batchSize"`
LearningRate float64 `json:"learningRate"`
Provider string `json:"provider"`
Status string `json:"status"`
StartedAt time.Time `json:"startedAt,omitempty"`
CompletedAt time.Time `json:"completedAt,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
TrainingJob represents an AI training job