Skip to content

Commit

Permalink
Working refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pschork committed Jan 2, 2025
1 parent 943030b commit be6d12f
Show file tree
Hide file tree
Showing 23 changed files with 1,520 additions and 2,122 deletions.
3 changes: 2 additions & 1 deletion disperser/cmd/dataapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/Layr-Labs/eigenda/disperser/dataapi"
"github.com/Layr-Labs/eigenda/disperser/dataapi/prometheus"
"github.com/Layr-Labs/eigenda/disperser/dataapi/subgraph"
serverv1 "github.com/Layr-Labs/eigenda/disperser/dataapi/v1"
serverv2 "github.com/Layr-Labs/eigenda/disperser/dataapi/v2"
"github.com/Layr-Labs/eigensdk-go/logging"

Expand Down Expand Up @@ -100,7 +101,7 @@ func RunDataApi(ctx *cli.Context) error {
chainState = coreeth.NewChainState(tx, client)
indexedChainState = thegraph.MakeIndexedChainState(config.ChainStateConfig, chainState, logger)
metrics = dataapi.NewMetrics(blobMetadataStore, config.MetricsConfig.HTTPPort, logger)
server = dataapi.NewServer(
server = serverv1.NewServer(
dataapi.Config{
ServerMode: config.ServerMode,
SocketAddr: config.SocketAddr,
Expand Down
4 changes: 2 additions & 2 deletions disperser/dataapi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ test:

generate-swagger-v1:
@echo " > Generating v1 swagger..."
swag init -g server.go --parseDependency --parseInternal --output docs/v1 --instanceName V1 --packageName v1 --dir . --parseDepth 1
swag fmt --dir .
swag init -g swagger.go --parseDependency --parseInternal --output docs/v1 --instanceName V1 --packageName v1 --dir ./v1 --parseDepth 1
swag fmt --dir ./v1

generate-swagger-v2:
@echo " > Generating v2 swagger..."
Expand Down
72 changes: 72 additions & 0 deletions disperser/dataapi/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package dataapi

import (
"errors"
"math/big"

"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/disperser/common/semver"
)

var errNotFound = errors.New("not found")

type (
ErrorResponse struct {
Error string `json:"error"`
}

MetricSummary struct {
AvgThroughput float64 `json:"avg_throughput"`
}

OperatorStake struct {
QuorumId string `json:"quorum_id"`
OperatorId string `json:"operator_id"`
StakePercentage float64 `json:"stake_percentage"`
Rank int `json:"rank"`
}

OperatorsStakeResponse struct {
StakeRankedOperators map[string][]*OperatorStake `json:"stake_ranked_operators"`
}

OperatorPortCheckResponse struct {
OperatorId string `json:"operator_id"`
DispersalSocket string `json:"dispersal_socket"`
RetrievalSocket string `json:"retrieval_socket"`
DispersalOnline bool `json:"dispersal_online"`
RetrievalOnline bool `json:"retrieval_online"`
}

QueriedOperatorEjections struct {
OperatorId string `json:"operator_id"`
OperatorAddress string `json:"operator_address"`
Quorum uint8 `json:"quorum"`
BlockNumber uint64 `json:"block_number"`
BlockTimestamp string `json:"block_timestamp"`
TransactionHash string `json:"transaction_hash"`
StakePercentage float64 `json:"stake_percentage"`
}

SemverReportResponse struct {
Semver map[string]*semver.SemverMetrics `json:"semver"`
}

Metric struct {
Throughput float64 `json:"throughput"`
CostInGas float64 `json:"cost_in_gas"`
// deprecated: use TotalStakePerQuorum instead. Remove when the frontend is updated.
TotalStake *big.Int `json:"total_stake"`
TotalStakePerQuorum map[core.QuorumID]*big.Int `json:"total_stake_per_quorum"`
}

Throughput struct {
Throughput float64 `json:"throughput"`
Timestamp uint64 `json:"timestamp"`
}

Meta struct {
Size int `json:"size"`
NextToken string `json:"next_token,omitempty"`
}
)
Loading

0 comments on commit be6d12f

Please sign in to comment.