Skip to content

Commit

Permalink
feat: implement GetPoolRegistrations
Browse files Browse the repository at this point in the history
Signed-off-by: Marko Kungla <marko@mkungla.dev>
  • Loading branch information
mkungla committed May 30, 2024
1 parent a794be1 commit 4fba9b4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

0 comments on commit 4fba9b4

Please sign in to comment.