Documentation
¶
Overview ¶
Package rest provides a SawtoothClientTransport implementation for the Sawtooth REST API.
Index ¶
- Constants
- func NewCommonRestIterator(transport *SawtoothClientTransportRest, nextUrl *url.URL, ...) *commonRestIterator
- type SawtoothClientTransportRest
- func (self *SawtoothClientTransportRest) GetBatch(batchId string) (*types.Batch, error)
- func (self *SawtoothClientTransportRest) GetBatchIterator(fetch int, reverse bool) types.BatchIterator
- func (self *SawtoothClientTransportRest) GetBatchStatus(batchId string, wait int) (types.BatchStatus, error)
- func (self *SawtoothClientTransportRest) GetBatchStatusMultiple(batchIds []string, wait int) (map[string]types.BatchStatus, error)
- func (self *SawtoothClientTransportRest) GetBlock(blockId string) (*types.Block, error)
- func (self *SawtoothClientTransportRest) GetBlockIterator(fetch int, reverse bool) types.BlockIterator
- func (self *SawtoothClientTransportRest) GetState(address string) (*types.State, error)
- func (self *SawtoothClientTransportRest) GetStateAtHead(address string, head string) (*types.State, error)
- func (self *SawtoothClientTransportRest) GetStateIterator(addressPrefix string, fetch int, reverse bool) types.StateIterator
- func (self *SawtoothClientTransportRest) GetTransaction(transactionId string) (*types.Transaction, error)
- func (self *SawtoothClientTransportRest) GetTransactionIterator(fetch int, reverse bool) types.TransactionIterator
- func (self *SawtoothClientTransportRest) SubmitBatchList(batchList *batch_pb2.BatchList) error
- type SawtoothClientTransportRestError
Constants ¶
const HTTP_TIMEOUT = time.Second * 60
HTTP_TIMEOUT is the default timeout.
Variables ¶
This section is empty.
Functions ¶
func NewCommonRestIterator ¶
func NewCommonRestIterator(transport *SawtoothClientTransportRest, nextUrl *url.URL, impl restIteratorImpl) *commonRestIterator
NewCommonRestIterator returns a new commonRestIterator for use in composing a usable object iterator.
Types ¶
type SawtoothClientTransportRest ¶
type SawtoothClientTransportRest struct { // URL is the URL to the REST API. URL *url.URL // HttpClient is the client that is maintained throughout the life of this object. HttpClient *http.Client }
SawtoothClientTransportRest represents a connection to the REST API.
func NewSawtoothClientTransportRest ¶
func NewSawtoothClientTransportRest(url *url.URL) (*SawtoothClientTransportRest, error)
NewSawtoothClientTransportRest returns a new SawtoothClientTransportRest for the given URL. Returns an error if a test request to the API does not succeed.
func (*SawtoothClientTransportRest) GetBatch ¶
func (self *SawtoothClientTransportRest) GetBatch(batchId string) (*types.Batch, error)
GetBatch returns the batch represented by batchId.
func (*SawtoothClientTransportRest) GetBatchIterator ¶
func (self *SawtoothClientTransportRest) GetBatchIterator(fetch int, reverse bool) types.BatchIterator
GetBatchIterator returns a types.BatchIterator that can iterate over all batches.
func (*SawtoothClientTransportRest) GetBatchStatus ¶
func (self *SawtoothClientTransportRest) GetBatchStatus(batchId string, wait int) (types.BatchStatus, error)
GetBatchStatus returns the status for a single batch.
func (*SawtoothClientTransportRest) GetBatchStatusMultiple ¶
func (self *SawtoothClientTransportRest) GetBatchStatusMultiple(batchIds []string, wait int) (map[string]types.BatchStatus, error)
GetBatchStatusMultiple returns the statuses for a list of batches.
func (*SawtoothClientTransportRest) GetBlock ¶
func (self *SawtoothClientTransportRest) GetBlock(blockId string) (*types.Block, error)
GetBlock returns a the block represented by blockId.
func (*SawtoothClientTransportRest) GetBlockIterator ¶
func (self *SawtoothClientTransportRest) GetBlockIterator(fetch int, reverse bool) types.BlockIterator
GetBlockIterator returns a types.BlockIterator that can iterate over all blocks.
func (*SawtoothClientTransportRest) GetState ¶
func (self *SawtoothClientTransportRest) GetState(address string) (*types.State, error)
GetState returns the state at the given address.
func (*SawtoothClientTransportRest) GetStateAtHead ¶
func (self *SawtoothClientTransportRest) GetStateAtHead(address string, head string) (*types.State, error)
GetStateAtHead returns the state at the given address, at the given head.
func (*SawtoothClientTransportRest) GetStateIterator ¶
func (self *SawtoothClientTransportRest) GetStateIterator(addressPrefix string, fetch int, reverse bool) types.StateIterator
GetStateData returns a types.StateIterator that can iterate over all state matching the given prefix.
func (*SawtoothClientTransportRest) GetTransaction ¶
func (self *SawtoothClientTransportRest) GetTransaction(transactionId string) (*types.Transaction, error)
GetTransaction returns the transaction represented by transactionId.
func (*SawtoothClientTransportRest) GetTransactionIterator ¶
func (self *SawtoothClientTransportRest) GetTransactionIterator(fetch int, reverse bool) types.TransactionIterator
GetTransactionIterator returns a types.TransactionIterator that can iterate over all transactions.
func (*SawtoothClientTransportRest) SubmitBatchList ¶
func (self *SawtoothClientTransportRest) SubmitBatchList(batchList *batch_pb2.BatchList) error
SubmitBatchList submits a batch list to Sawtooth. The batch list must be in the form of a batch_pb2.BatchList protobuf and be prepared appropriately (all required fields and signatures populated.
type SawtoothClientTransportRestError ¶
type SawtoothClientTransportRestError struct { // Method is the HTTP method used for the request. Method string // StatusCode is the HTTP status code returned from the request. StatusCode int // ErrorResponse is the actual error data returned from the request. ErrorResponse errorRestResponse }
SawtoothClientTransportRestError represents an error returned by SawtoothClientTransportRest.
func NewSawtoothClientTransportRestError ¶
func NewSawtoothClientTransportRestError(response *http.Response) *SawtoothClientTransportRestError
NewSawtoothClientTransportRestError constructs a SawtoothClientTransportRestError from an http.Response.
func (*SawtoothClientTransportRestError) Error ¶
func (self *SawtoothClientTransportRestError) Error() string
Error implements the error interface for SawtoothClientTransportRestError.