gcx/backend/services/chain-indexer/internal/domain/repository/chain_client.go

21 lines
672 B
Go

package repository
import (
"context"
"github.com/genex/chain-indexer/internal/domain/entity"
)
// ChainClient defines the contract for interacting with the blockchain node.
// Infrastructure layer (e.g. go-ethereum ethclient) provides the concrete implementation.
type ChainClient interface {
// GetLatestBlockNumber returns the current head block number on the chain.
GetLatestBlockNumber(ctx context.Context) (int64, error)
// GetBlockByNumber fetches a block and its transactions from the chain.
GetBlockByNumber(ctx context.Context, height int64) (*entity.Block, []*entity.ChainTransaction, error)
// Close releases any underlying connections.
Close()
}