Skip to content

Commit

Permalink
opt-out method
Browse files Browse the repository at this point in the history
  • Loading branch information
mtgnoah committed Oct 14, 2024
1 parent 7885c0b commit e1f7878
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
7 changes: 7 additions & 0 deletions controller/resolutions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ func (c *Controller) GetRegisteredAnchorsFromState(
return storage.GetAnchorsFromState(ctx, c.inner.ReadState)
}

func (c *Controller) GetEpochExitsFromState(
ctx context.Context,
epoch uint64,
) (*storage.EpochExitInfo, error) {
return storage.GetEpochExitsFromState(ctx, c.inner.ReadState, epoch)
}

func (c *Controller) GetAcceptedBlockWindow() int {
return c.config.GetAcceptedBlockWindow()
}
Expand Down
2 changes: 2 additions & 0 deletions rpc/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/AnomalyFi/hypersdk/fees"
"github.com/AnomalyFi/nodekit-seq/archiver"
"github.com/AnomalyFi/nodekit-seq/genesis"
"github.com/AnomalyFi/nodekit-seq/storage"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/trace"
"github.com/ava-labs/avalanchego/utils/logging"
Expand All @@ -25,6 +26,7 @@ type Controller interface {
GetTransaction(context.Context, ids.ID) (bool, int64, bool, fees.Dimensions, uint64, error)
GetBalanceFromState(context.Context, codec.Address) (uint64, error)
GetRegisteredAnchorsFromState(context.Context) ([][]byte, []*hactions.AnchorInfo, error)
GetEpochExitsFromState(ctx context.Context, epoch uint64) (*storage.EpochExitInfo, error)
UnitPrices(ctx context.Context) (fees.Dimensions, error)
NameSpacesPrice(ctx context.Context, namespaces []string) ([]uint64, error)
GetAcceptedBlockWindow() int
Expand Down
19 changes: 18 additions & 1 deletion rpc/jsonrpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/AnomalyFi/hypersdk/utils"
"github.com/AnomalyFi/nodekit-seq/auth"
seqconsts "github.com/AnomalyFi/nodekit-seq/consts"
"github.com/AnomalyFi/nodekit-seq/storage"

"github.com/AnomalyFi/hypersdk/codec"

Expand Down Expand Up @@ -361,7 +362,7 @@ type RegisteredAnchorReply struct {
}

func (j *JSONRPCServer) RegisteredAnchors(req *http.Request, args *struct{}, reply *RegisteredAnchorReply) error {
ctx, span := j.c.Tracer().Start(req.Context(), "Server.Balance")
ctx, span := j.c.Tracer().Start(req.Context(), "Server.RegisteredAnchors")
defer span.End()

namespaces, infos, err := j.c.GetRegisteredAnchorsFromState(ctx)
Expand All @@ -373,6 +374,22 @@ func (j *JSONRPCServer) RegisteredAnchors(req *http.Request, args *struct{}, rep
return err
}

type EpochExitsReply struct {
Info *storage.EpochExitInfo `json:"info"`
}

func (j *JSONRPCServer) GetEpochExits(req *http.Request, args *types.GetEpochExits, reply *EpochExitsReply) error {
ctx, span := j.c.Tracer().Start(req.Context(), "Server.GetEpochExits")
defer span.End()

info, err := j.c.GetEpochExitsFromState(ctx, args.Height)
if err != nil {
return err
}
reply.Info = info
return err
}

var _ chain.Parser = (*ServerParser)(nil)

type ServerParser struct {
Expand Down
2 changes: 1 addition & 1 deletion storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func getEpochExit(
}

// Used to serve RPC queries
func GetEpochExitFromState(
func GetEpochExitsFromState(
ctx context.Context,
f ReadState,
epoch uint64,
Expand Down
4 changes: 4 additions & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,7 @@ type GetBlockTransactionsByNamespaceArgs struct {
Height uint64 `json:"height"`
Namespace string `json:"namespace"`
}

type GetEpochExits struct {
Height uint64 `json:"height"`
}

0 comments on commit e1f7878

Please sign in to comment.