From 4fba9b4ca4503234cc5e330d0ad0bc367e69fd56 Mon Sep 17 00:00:00 2001 From: Marko Kungla Date: Sat, 30 Mar 2024 12:40:59 +0200 Subject: [PATCH] feat: implement GetPoolRegistrations Signed-off-by: Marko Kungla --- pool.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pool.go b/pool.go index dcb9985..fbf4eb8 100644 --- a/pool.go +++ b/pool.go @@ -47,6 +47,16 @@ type ( RetiringEpoch *EpochNo `json:"retiring_epoch.omitempty"` } + PoolRegistration struct { + PoolIDBech32 PoolID `json:"pool_id_bech32"` + TxHash TxHash `json:"tx_hash"` + BlockHash BlockHash `json:"block_hash"` + BlockHeight uint64 `json:"block_height"` + EpochNo EpochNo `json:"epoch_no"` + EpochSlot Slot `json:"epoch_slot"` + ActiveEpochNo EpochNo `json:"active_epoch_no"` + } + // PoolMetaJSON pool meadata json. PoolMetaJSON struct { // Pool description @@ -353,6 +363,11 @@ type ( Response Data []PoolHistory `json:"data"` } + + PoolRegistrationsResponse struct { + Response + Data []PoolRegistration `json:"data"` + } ) // GetPoolList returns the list of all currently registered/retiring (not retired) pools. @@ -590,3 +605,25 @@ func poolIdsPL(pids []PoolID) io.Reader { }() return rpipe } + +func (c *Client) GetPoolRegistrations( + ctx context.Context, + epoch EpochNo, + opts *RequestOptions, +) (res *PoolRegistrationsResponse, err error) { + res = &PoolRegistrationsResponse{} + if opts == nil { + opts = c.NewRequestOptions() + } + + if epoch > 0 { + opts.QuerySet("_epoch_no", epoch.String()) + } + + rsp, err := c.request(ctx, &res.Response, "GET", "/pool_registrations", nil, opts) + if err != nil { + return + } + err = ReadAndUnmarshalResponse(rsp, &res.Response, &res.Data) + return +}