package block import ( "context" "fmt" "git.dragonchain.com/dragonchain/prime-sdk-go/client" "git.dragonchain.com/dragonchain/prime-sdk-go/models" ) type BlockClient struct { client *client.Client } func NewBlockClient(c *client.Client) *BlockClient { return &BlockClient{client: c} } func (bc *BlockClient) Get(ctx context.Context, blockID string) (*models.Block, error) { var resp models.Block path := fmt.Sprintf("/api/v1/block/%s", blockID) err := bc.client.Get(ctx, path, &resp) if err != nil { return nil, err } return &resp, nil } // GetInterchain traces a block to the validator (verification) blocks that // validated it and the public-chain interchain anchors those validator blocks // were bundled into. // // By default it returns the first anchor per public chain (anchor proofs are // chained, so the earliest per chain is the meaningful one). Use // client.WithPerChain / client.WithChains to return more anchors per chain or // restrict to specific chains. func (bc *BlockClient) GetInterchain(ctx context.Context, blockID string, opts ...client.InterchainOption) (*models.InterchainTrace, error) { var resp models.InterchainTrace path := fmt.Sprintf("/api/v1/block/%s/interchain%s", blockID, client.InterchainQuery(opts...)) err := bc.client.Get(ctx, path, &resp) if err != nil { return nil, err } return &resp, nil }