Skip to content

Commit

Permalink
Client.GetEpochBlock() wraps 'ftm_getEpochBlock' call
Browse files Browse the repository at this point in the history
  • Loading branch information
rus-alex committed Sep 11, 2023
1 parent a170474 commit def8619
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ftmclient/abft_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"context"
"math/big"

"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/Fantom-foundation/go-opera/inter"
)

// GetValidators returns Lachesis event by hash or short ID.
func (ec *Client) GetValidators(ctx context.Context, epoch *big.Int) (inter.ValidatorProfiles, error) {
func (ec *Client) GetValidators(ctx context.Context, epoch idx.Epoch) (inter.ValidatorProfiles, error) {
var raw map[hexutil.Uint64]interface{}
err := ec.c.CallContext(ctx, &raw, "abft_getValidators", toBlockNumArg(epoch))
err := ec.c.CallContext(ctx, &raw, "abft_getValidators", toBlockNumArg(big.NewInt(int64(epoch))))
if err != nil {
return nil, err
} else if len(raw) == 0 {
Expand Down
17 changes: 17 additions & 0 deletions ftmclient/ftm_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ftmclient

import (
"context"
"math/big"

"github.com/Fantom-foundation/lachesis-base/inter/idx"
"github.com/ethereum/go-ethereum/common/hexutil"
)

// GetEpochBlock returns block height in a beginning of an epoch.
func (ec *Client) GetEpochBlock(ctx context.Context, epoch idx.Epoch) (idx.Block, error) {
var raw hexutil.Uint64
err := ec.c.CallContext(ctx, &raw, "ftm_getEpochBlock", toBlockNumArg(big.NewInt(int64(epoch))))

return idx.Block(raw), err
}

0 comments on commit def8619

Please sign in to comment.