Skip to content

Commit

Permalink
Support RPC GetDeploymentsInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Aug 4, 2024
1 parent 5a7ed70 commit ac786a7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ type Client interface {
//GetCellsCapacity returns the live cells capacity by the lock or type script.
GetCellsCapacity(ctx context.Context, searchKey *indexer.SearchKey) (*indexer.Capacity, error)

// GetDeploymentsInfo returns statistics about the chain.
GetDeploymentsInfo(ctx context.Context) (*types.DeploymentsInfo, error)

// Close close client
Close()

Expand Down Expand Up @@ -764,6 +767,15 @@ func (cli *client) GetCellsCapacity(ctx context.Context, searchKey *indexer.Sear
return &result, nil
}

func (cli *Client) GetDeploymentsInfo(ctx context.Context) (*types.DeploymentsInfo, error) {
var result types.DeploymentsInfo
err := cli.c.CallContext(ctx, &result, "get_deployments_info")
if err != nil {
return nil, err
}
return &result, nil
}

func (cli *client) GetCells(ctx context.Context, searchKey *indexer.SearchKey, order indexer.SearchOrder, limit uint64, afterCursor string) (*indexer.LiveCells, error) {
var (
result indexer.LiveCells
Expand Down
45 changes: 45 additions & 0 deletions types/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,48 @@ type BlockchainInfo struct {
IsInitialBlockDownload bool `json:"is_initial_block_download"`
MedianTime uint64 `json:"median_time"`
}

// DeploymentState represents the possible states of a deployment.
type DeploymentState int

const (
// Defined is the first state that each softfork starts.
Defined DeploymentState = iota
// Started is the state for epochs past the `start` epoch.
Started
// LockedIn is the state for epochs after the first epoch period with STARTED epochs of which at least `threshold` has the associated bit set in `version`.
LockedIn
// Active is the state for all epochs after the LOCKED_IN epoch.
Active
// Failed is the state for epochs past the `timeout_epoch`, if LOCKED_IN was not reached.
Failed
)

// DeploymentPos represents the possible positions for deployments.
type DeploymentPos int

const (
// Testdummy represents a dummy deployment.
Testdummy DeploymentPos = iota
// LightClient represents the light client protocol deployment.
LightClient
)

// DeploymentInfo represents information about a deployment.
type DeploymentInfo struct {
Bit uint8
Start uint64
Timeout uint64
MinActivationEpoch uint64
Period uint64
Threshold RationalU256
Since uint64
State DeploymentState
}

// DeploymentsInfo represents information about multiple deployments.
type DeploymentsInfo struct {
Hash Hash
Epoch uint64
Deployments map[DeploymentPos]DeploymentInfo
}

0 comments on commit ac786a7

Please sign in to comment.