diff --git a/controller/resolutions.go b/controller/resolutions.go index 79f9f2b..873efa0 100644 --- a/controller/resolutions.go +++ b/controller/resolutions.go @@ -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() } diff --git a/rpc/dependencies.go b/rpc/dependencies.go index 9b05089..7ffe7cc 100644 --- a/rpc/dependencies.go +++ b/rpc/dependencies.go @@ -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" @@ -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 diff --git a/rpc/jsonrpc_server.go b/rpc/jsonrpc_server.go index d6c122e..caa77cd 100644 --- a/rpc/jsonrpc_server.go +++ b/rpc/jsonrpc_server.go @@ -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" @@ -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) @@ -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 { diff --git a/storage/storage.go b/storage/storage.go index 4b4d677..4c24d26 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -536,7 +536,7 @@ func getEpochExit( } // Used to serve RPC queries -func GetEpochExitFromState( +func GetEpochExitsFromState( ctx context.Context, f ReadState, epoch uint64, diff --git a/types/types.go b/types/types.go index ad40cdd..39e1eee 100644 --- a/types/types.go +++ b/types/types.go @@ -212,3 +212,7 @@ type GetBlockTransactionsByNamespaceArgs struct { Height uint64 `json:"height"` Namespace string `json:"namespace"` } + +type GetEpochExits struct { + Height uint64 `json:"height"` +}