github.com/algorand/go-algorand-sdk@v1.24.0/client/v2/indexer/lookupBlock.go (about)

     1  package indexer
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/algorand/go-algorand-sdk/client/v2/common"
     8  	"github.com/algorand/go-algorand-sdk/client/v2/common/models"
     9  )
    10  
    11  // LookupBlockParams contains all of the query parameters for url serialization.
    12  type LookupBlockParams struct {
    13  
    14  	// HeaderOnly header only flag. When this is set to true, returned block does not
    15  	// contain the transactions
    16  	HeaderOnly bool `url:"header-only,omitempty"`
    17  }
    18  
    19  // LookupBlock lookup block.
    20  type LookupBlock struct {
    21  	c *Client
    22  
    23  	roundNumber uint64
    24  
    25  	p LookupBlockParams
    26  }
    27  
    28  // HeaderOnly header only flag. When this is set to true, returned block does not
    29  // contain the transactions
    30  func (s *LookupBlock) HeaderOnly(HeaderOnly bool) *LookupBlock {
    31  	s.p.HeaderOnly = HeaderOnly
    32  
    33  	return s
    34  }
    35  
    36  // Do performs the HTTP request
    37  func (s *LookupBlock) Do(ctx context.Context, headers ...*common.Header) (response models.Block, err error) {
    38  	err = s.c.get(ctx, &response, fmt.Sprintf("/v2/blocks/%s", common.EscapeParams(s.roundNumber)...), s.p, headers)
    39  	return
    40  }