rest

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package rest provides a SawtoothClientTransport implementation for the Sawtooth REST API.

Index

Constants

View Source
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

Error implements the error interface for SawtoothClientTransportRestError.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL