api

package
v0.9.0-beta Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 18 Imported by: 0

README

Accumuate API

Architecture

Modules

The Accumulate API is segmented into the following modules:

  • The Network module provides methods for querying network metadata such as TPS
  • The Node module provides methods for querying node metadata such as the node's software version.
  • The Query module provides methods for querying records.
  • The Submit module provides methods for submitting transactions.
Layers

The Accumulate API is composed of the following layers:

  • The Network layer executes Network requests by collating information from all network partitions.
  • The Node layer executes Node requests for a node.
  • The Database Query layer executes Query requests using a database.
  • The Tendermint Submit layer executes Submit requests by forwarding them to Tendermint RPC.
  • The Router layer executes Query and Submit requests by forwarding them to the appropriate network partition or data server.
Implementations
  • JSON-RPC
  • Binary
  • REST?

Methods

Query
  • QueryState(account, fragment..., options) queries the state of an account or an account fragment such as a transaction or other chain entry. QueryState can query at most one record at a time. Queries involving multiple records must use QuerySet.
  • QuerySet(account, fragment..., options) queies a set of records relating to an account, such as directory entries, transactions, etc.
  • Search(scope, recordQuery, options) searches for a record within the scope of an account or identity. For example, Search can locate a transaction on the main chain of any account within an ADI.
Submit
  • Submit(envelope, options) submits a transaction for execution. Submit can also be used to validate a transaction without submitting it.
  • Faucet(account, options) funds a lite account (for testnet only).
Network
  • Metrics() collects metrics from the entire network
Node
  • Status() returns the status of the node
  • Version() returns the software version of the node
  • Describe() returns the network configuration of the node
  • Metrics() collects metrics from the node

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientsMap

func ClientsMap[T any](clients map[string]T) func(string) (T, error)

func EqualRecord

func EqualRecord(a, b Record) bool

EqualRecord is used to compare the values of the union

Types

type AccountRecord

type AccountRecord struct {
	Account protocol.Account `json:"account,omitempty" form:"account" query:"account" validate:"required"`
	Chains  []*ChainState    `json:"chains,omitempty" form:"chains" query:"chains" validate:"required"`
	Proof   *Receipt         `json:"proof,omitempty" form:"proof" query:"proof" validate:"required"`
	// contains filtered or unexported fields
}

func (*AccountRecord) Copy

func (v *AccountRecord) Copy() *AccountRecord

func (*AccountRecord) CopyAsInterface

func (v *AccountRecord) CopyAsInterface() interface{}

func (*AccountRecord) Equal

func (v *AccountRecord) Equal(u *AccountRecord) bool

func (*AccountRecord) IsValid

func (v *AccountRecord) IsValid() error

func (*AccountRecord) MarshalBinary

func (v *AccountRecord) MarshalBinary() ([]byte, error)

func (*AccountRecord) MarshalJSON

func (v *AccountRecord) MarshalJSON() ([]byte, error)

func (*AccountRecord) Type

func (*AccountRecord) Type() RecordType

func (*AccountRecord) UnmarshalBinary

func (v *AccountRecord) UnmarshalBinary(data []byte) error

func (*AccountRecord) UnmarshalBinaryFrom

func (v *AccountRecord) UnmarshalBinaryFrom(rd io.Reader) error

func (*AccountRecord) UnmarshalJSON

func (v *AccountRecord) UnmarshalJSON(data []byte) error

type ChainState

type ChainState struct {
	Name   string             `json:"name,omitempty" form:"name" query:"name" validate:"required"`
	Type   protocol.ChainType `json:"type,omitempty" form:"type" query:"type" validate:"required"`
	Height uint64             `json:"height,omitempty" form:"height" query:"height" validate:"required"`
	Roots  [][]byte           `json:"roots,omitempty" form:"roots" query:"roots" validate:"required"`
	// contains filtered or unexported fields
}

func (*ChainState) Copy

func (v *ChainState) Copy() *ChainState

func (*ChainState) CopyAsInterface

func (v *ChainState) CopyAsInterface() interface{}

func (*ChainState) Equal

func (v *ChainState) Equal(u *ChainState) bool

func (*ChainState) IsValid

func (v *ChainState) IsValid() error

func (*ChainState) MarshalBinary

func (v *ChainState) MarshalBinary() ([]byte, error)

func (*ChainState) MarshalJSON

func (v *ChainState) MarshalJSON() ([]byte, error)

func (*ChainState) UnmarshalBinary

func (v *ChainState) UnmarshalBinary(data []byte) error

func (*ChainState) UnmarshalBinaryFrom

func (v *ChainState) UnmarshalBinaryFrom(rd io.Reader) error

func (*ChainState) UnmarshalJSON

func (v *ChainState) UnmarshalJSON(data []byte) error

type DatabaseQueryModule

type DatabaseQueryModule struct {
	Network *config.Describe
	DB      *database.Database
}

func (*DatabaseQueryModule) QuerySet

func (m *DatabaseQueryModule) QuerySet(_ context.Context, account *url.URL, fragment []string, opts QuerySetOptions) (Record, error)

func (*DatabaseQueryModule) QueryState

func (m *DatabaseQueryModule) QueryState(_ context.Context, account *url.URL, fragment []string, opts QueryStateOptions) (Record, error)

func (*DatabaseQueryModule) Search

func (m *DatabaseQueryModule) Search(_ context.Context, scope *url.URL, query string, opts SearchOptions) (Record, error)

type Faucet

type Faucet struct {
	SubmitModule
}

func (Faucet) Faucet

func (f Faucet) Faucet(ctx context.Context, account *url.URL, opts SubmitOptions) (*Submission, error)

type FaucetModule

type FaucetModule interface {
	SubmitModule
	Faucet(ctx context.Context, account *url.URL, opts SubmitOptions) (*Submission, error)
}

type NetworkMetrics

type NetworkMetrics struct {
	TPS float64 `json:"tps,omitempty" form:"tps" query:"tps" validate:"required"`
	// contains filtered or unexported fields
}

func (*NetworkMetrics) Copy

func (v *NetworkMetrics) Copy() *NetworkMetrics

func (*NetworkMetrics) CopyAsInterface

func (v *NetworkMetrics) CopyAsInterface() interface{}

func (*NetworkMetrics) Equal

func (v *NetworkMetrics) Equal(u *NetworkMetrics) bool

func (*NetworkMetrics) IsValid

func (v *NetworkMetrics) IsValid() error

func (*NetworkMetrics) MarshalBinary

func (v *NetworkMetrics) MarshalBinary() ([]byte, error)

func (*NetworkMetrics) UnmarshalBinary

func (v *NetworkMetrics) UnmarshalBinary(data []byte) error

func (*NetworkMetrics) UnmarshalBinaryFrom

func (v *NetworkMetrics) UnmarshalBinaryFrom(rd io.Reader) error

type NetworkModule

type NetworkModule interface {
	Metrics(context.Context) (*NetworkMetrics, error)
}

type NodeDescription

type NodeDescription struct {
	Partition config.Network `json:"partition,omitempty" form:"partition" query:"partition" validate:"required"`
	// contains filtered or unexported fields
}

type NodeMetrics

type NodeMetrics struct {
	TPS float64 `json:"tps,omitempty" form:"tps" query:"tps" validate:"required"`
	// contains filtered or unexported fields
}

func (*NodeMetrics) Copy

func (v *NodeMetrics) Copy() *NodeMetrics

func (*NodeMetrics) CopyAsInterface

func (v *NodeMetrics) CopyAsInterface() interface{}

func (*NodeMetrics) Equal

func (v *NodeMetrics) Equal(u *NodeMetrics) bool

func (*NodeMetrics) IsValid

func (v *NodeMetrics) IsValid() error

func (*NodeMetrics) MarshalBinary

func (v *NodeMetrics) MarshalBinary() ([]byte, error)

func (*NodeMetrics) UnmarshalBinary

func (v *NodeMetrics) UnmarshalBinary(data []byte) error

func (*NodeMetrics) UnmarshalBinaryFrom

func (v *NodeMetrics) UnmarshalBinaryFrom(rd io.Reader) error

type NodeModule

type NodeModule interface {
	Status(context.Context) (*NodeStatus, error)
	Version(context.Context) (*NodeVersion, error)
	Describe(context.Context) (*NodeDescription, error)
	Metrics(context.Context) (*NodeMetrics, error)
}

type NodeStatus

type NodeStatus struct {
	Ok bool `json:"ok,omitempty" form:"ok" query:"ok" validate:"required"`
	// contains filtered or unexported fields
}

func (*NodeStatus) Copy

func (v *NodeStatus) Copy() *NodeStatus

func (*NodeStatus) CopyAsInterface

func (v *NodeStatus) CopyAsInterface() interface{}

func (*NodeStatus) Equal

func (v *NodeStatus) Equal(u *NodeStatus) bool

func (*NodeStatus) IsValid

func (v *NodeStatus) IsValid() error

func (*NodeStatus) MarshalBinary

func (v *NodeStatus) MarshalBinary() ([]byte, error)

func (*NodeStatus) UnmarshalBinary

func (v *NodeStatus) UnmarshalBinary(data []byte) error

func (*NodeStatus) UnmarshalBinaryFrom

func (v *NodeStatus) UnmarshalBinaryFrom(rd io.Reader) error

type NodeVersion

type NodeVersion struct {
	Version        string `json:"version,omitempty" form:"version" query:"version" validate:"required"`
	Commit         string `json:"commit,omitempty" form:"commit" query:"commit" validate:"required"`
	VersionIsKnown bool   `json:"versionIsKnown,omitempty" form:"versionIsKnown" query:"versionIsKnown" validate:"required"`
	IsTestNet      bool   `json:"isTestNet,omitempty" form:"isTestNet" query:"isTestNet" validate:"required"`
	// contains filtered or unexported fields
}

func (*NodeVersion) Copy

func (v *NodeVersion) Copy() *NodeVersion

func (*NodeVersion) CopyAsInterface

func (v *NodeVersion) CopyAsInterface() interface{}

func (*NodeVersion) Equal

func (v *NodeVersion) Equal(u *NodeVersion) bool

func (*NodeVersion) IsValid

func (v *NodeVersion) IsValid() error

func (*NodeVersion) MarshalBinary

func (v *NodeVersion) MarshalBinary() ([]byte, error)

func (*NodeVersion) UnmarshalBinary

func (v *NodeVersion) UnmarshalBinary(data []byte) error

func (*NodeVersion) UnmarshalBinaryFrom

func (v *NodeVersion) UnmarshalBinaryFrom(rd io.Reader) error

type QueryModule

type QueryModule interface {
	QueryState(ctx context.Context, account *url.URL, fragment []string, opts QueryStateOptions) (Record, error)
	QuerySet(ctx context.Context, account *url.URL, fragment []string, opts QuerySetOptions) (Record, error)
	Search(ctx context.Context, scope *url.URL, query string, opts SearchOptions) (Record, error)
}

type QuerySetOptions

type QuerySetOptions struct {

	// Expand requests an expanded response.
	Expand bool `json:"expand,omitempty" form:"expand" query:"expand"`
	// Start is the starting index.
	Start bool `json:"start,omitempty" form:"start" query:"start"`
	// Count is the number of requested results.
	Count bool `json:"count,omitempty" form:"count" query:"count"`
	// contains filtered or unexported fields
}

func (*QuerySetOptions) Copy

func (v *QuerySetOptions) Copy() *QuerySetOptions

func (*QuerySetOptions) CopyAsInterface

func (v *QuerySetOptions) CopyAsInterface() interface{}

func (*QuerySetOptions) Equal

func (v *QuerySetOptions) Equal(u *QuerySetOptions) bool

func (*QuerySetOptions) IsValid

func (v *QuerySetOptions) IsValid() error

func (*QuerySetOptions) MarshalBinary

func (v *QuerySetOptions) MarshalBinary() ([]byte, error)

func (*QuerySetOptions) UnmarshalBinary

func (v *QuerySetOptions) UnmarshalBinary(data []byte) error

func (*QuerySetOptions) UnmarshalBinaryFrom

func (v *QuerySetOptions) UnmarshalBinaryFrom(rd io.Reader) error

type QueryStateOptions

type QueryStateOptions struct {

	// Prove requests a proof.
	Prove bool `json:"prove,omitempty" form:"prove" query:"prove"`
	// Expand requests an expanded response.
	Expand bool `json:"expand,omitempty" form:"expand" query:"expand"`
	// Wait blocks until the record is available.
	Wait time.Duration `json:"wait,omitempty" form:"wait" query:"wait"`
	// Delivered ignores incomplete transactions.
	Delivered bool `json:"delivered,omitempty" form:"delivered" query:"delivered"`
	// contains filtered or unexported fields
}

func (*QueryStateOptions) Copy

func (*QueryStateOptions) CopyAsInterface

func (v *QueryStateOptions) CopyAsInterface() interface{}

func (*QueryStateOptions) Equal

func (*QueryStateOptions) IsValid

func (v *QueryStateOptions) IsValid() error

func (*QueryStateOptions) MarshalBinary

func (v *QueryStateOptions) MarshalBinary() ([]byte, error)

func (*QueryStateOptions) MarshalJSON

func (v *QueryStateOptions) MarshalJSON() ([]byte, error)

func (*QueryStateOptions) UnmarshalBinary

func (v *QueryStateOptions) UnmarshalBinary(data []byte) error

func (*QueryStateOptions) UnmarshalBinaryFrom

func (v *QueryStateOptions) UnmarshalBinaryFrom(rd io.Reader) error

func (*QueryStateOptions) UnmarshalJSON

func (v *QueryStateOptions) UnmarshalJSON(data []byte) error

type Receipt

type Receipt struct {
	LocalBlock     uint64          `json:"localBlock,omitempty" form:"localBlock" query:"localBlock" validate:"required"`
	DirectoryBlock uint64          `json:"directoryBlock,omitempty" form:"directoryBlock" query:"directoryBlock" validate:"required"`
	Proof          managed.Receipt `json:"proof,omitempty" form:"proof" query:"proof" validate:"required"`
	Error          *errors2.Error  `json:"error,omitempty" form:"error" query:"error" validate:"required"`
	// contains filtered or unexported fields
}

func (*Receipt) Copy

func (v *Receipt) Copy() *Receipt

func (*Receipt) CopyAsInterface

func (v *Receipt) CopyAsInterface() interface{}

func (*Receipt) Equal

func (v *Receipt) Equal(u *Receipt) bool

func (*Receipt) IsValid

func (v *Receipt) IsValid() error

func (*Receipt) MarshalBinary

func (v *Receipt) MarshalBinary() ([]byte, error)

func (*Receipt) UnmarshalBinary

func (v *Receipt) UnmarshalBinary(data []byte) error

func (*Receipt) UnmarshalBinaryFrom

func (v *Receipt) UnmarshalBinaryFrom(rd io.Reader) error

type Record

type Record interface {
	encoding.BinaryValue
	Type() RecordType
}

func NewRecord

func NewRecord(typ RecordType) (Record, error)

NewRecord creates a new Record for the specified RecordType.

func UnmarshalRecord

func UnmarshalRecord(data []byte) (Record, error)

UnmarshalRecord unmarshals a Record.

func UnmarshalRecordFrom

func UnmarshalRecordFrom(rd io.ReadSeeker) (Record, error)

UnmarshalRecordFrom unmarshals a Record.

func UnmarshalRecordJSON

func UnmarshalRecordJSON(data []byte) (Record, error)

UnmarshalRecordJson unmarshals a Record.

type RecordType

type RecordType uint64
const RecordTypeAccount RecordType = 1

RecordTypeAccount .

const RecordTypeTransaction RecordType = 2

RecordTypeTransaction .

func RecordTypeByName

func RecordTypeByName(name string) (RecordType, bool)

RecordTypeByName returns the named Record Type.

func UnmarshalRecordType

func UnmarshalRecordType(r io.Reader) (RecordType, error)

UnmarshalRecordType unmarshals the RecordType from the start of a Record.

func (RecordType) GetEnumValue

func (v RecordType) GetEnumValue() uint64

GetEnumValue returns the value of the Record Type

func (RecordType) MarshalJSON

func (v RecordType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Record Type to JSON as a string.

func (*RecordType) SetEnumValue

func (v *RecordType) SetEnumValue(id uint64) bool

SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.

func (RecordType) String

func (v RecordType) String() string

String returns the name of the Record Type.

func (*RecordType) UnmarshalJSON

func (v *RecordType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Record Type from JSON as a string.

type RoutedQueryLayer

type RoutedQueryLayer struct {
	Clients func(string) (QueryModule, error)
	Router  router
}

func (*RoutedQueryLayer) QuerySet

func (r *RoutedQueryLayer) QuerySet(ctx context.Context, account *url.URL, fragment []string, opts QuerySetOptions) (Record, error)

func (*RoutedQueryLayer) QueryState

func (r *RoutedQueryLayer) QueryState(ctx context.Context, account *url.URL, fragment []string, opts QueryStateOptions) (Record, error)

func (*RoutedQueryLayer) Search

func (r *RoutedQueryLayer) Search(ctx context.Context, scope *url.URL, query string, opts SearchOptions) (Record, error)

type RoutedSubmitLayer

type RoutedSubmitLayer struct {
	Clients func(string) (SubmitModule, error)
	Router  router
}

func (*RoutedSubmitLayer) Submit

func (r *RoutedSubmitLayer) Submit(ctx context.Context, envelope *protocol.Envelope, opts SubmitOptions) (*Submission, error)

type SearchOptions

type SearchOptions struct {

	// Kind is the kind of record to search for.
	Kind string `json:"kind,omitempty" form:"kind" query:"kind" validate:"required"`
	// contains filtered or unexported fields
}

func (*SearchOptions) Copy

func (v *SearchOptions) Copy() *SearchOptions

func (*SearchOptions) CopyAsInterface

func (v *SearchOptions) CopyAsInterface() interface{}

func (*SearchOptions) Equal

func (v *SearchOptions) Equal(u *SearchOptions) bool

func (*SearchOptions) IsValid

func (v *SearchOptions) IsValid() error

func (*SearchOptions) MarshalBinary

func (v *SearchOptions) MarshalBinary() ([]byte, error)

func (*SearchOptions) UnmarshalBinary

func (v *SearchOptions) UnmarshalBinary(data []byte) error

func (*SearchOptions) UnmarshalBinaryFrom

func (v *SearchOptions) UnmarshalBinaryFrom(rd io.Reader) error

type Submission

type Submission struct {
	TransactionHashes [][32]byte                    `json:"transactionHashes,omitempty" form:"transactionHashes" query:"transactionHashes" validate:"required"`
	SignatureHashes   [][32]byte                    `json:"signatureHashes,omitempty" form:"signatureHashes" query:"signatureHashes" validate:"required"`
	Status            []*protocol.TransactionStatus `json:"status,omitempty" form:"status" query:"status" validate:"required"`
	// contains filtered or unexported fields
}

func (*Submission) Copy

func (v *Submission) Copy() *Submission

func (*Submission) CopyAsInterface

func (v *Submission) CopyAsInterface() interface{}

func (*Submission) Equal

func (v *Submission) Equal(u *Submission) bool

func (*Submission) IsValid

func (v *Submission) IsValid() error

func (*Submission) MarshalBinary

func (v *Submission) MarshalBinary() ([]byte, error)

func (*Submission) MarshalJSON

func (v *Submission) MarshalJSON() ([]byte, error)

func (*Submission) UnmarshalBinary

func (v *Submission) UnmarshalBinary(data []byte) error

func (*Submission) UnmarshalBinaryFrom

func (v *Submission) UnmarshalBinaryFrom(rd io.Reader) error

func (*Submission) UnmarshalJSON

func (v *Submission) UnmarshalJSON(data []byte) error

type SubmitMode

type SubmitMode uint64
const SubmitModeAsync SubmitMode = 1

SubmitModeAsync submits the transaction asynchronously.

const SubmitModeCheck SubmitMode = 2

SubmitModeCheck checks the transaction but does not submit it.

const SubmitModeSync SubmitMode = 0

SubmitModeSync submits the transaction and blocks until it is accepted into a block.

func SubmitModeByName

func SubmitModeByName(name string) (SubmitMode, bool)

SubmitModeByName returns the named Submit Mode.

func (SubmitMode) GetEnumValue

func (v SubmitMode) GetEnumValue() uint64

GetEnumValue returns the value of the Submit Mode

func (SubmitMode) MarshalJSON

func (v SubmitMode) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Submit Mode to JSON as a string.

func (*SubmitMode) SetEnumValue

func (v *SubmitMode) SetEnumValue(id uint64) bool

SetEnumValue sets the value. SetEnumValue returns false if the value is invalid.

func (SubmitMode) String

func (v SubmitMode) String() string

String returns the name of the Submit Mode.

func (*SubmitMode) UnmarshalJSON

func (v *SubmitMode) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the Submit Mode from JSON as a string.

type SubmitModule

type SubmitModule interface {
	Submit(ctx context.Context, envelope *protocol.Envelope, opts SubmitOptions) (*Submission, error)
}

type SubmitOptions

type SubmitOptions struct {
	Mode SubmitMode `json:"mode,omitempty" form:"mode" query:"mode" validate:"required"`
	// contains filtered or unexported fields
}

func (*SubmitOptions) Copy

func (v *SubmitOptions) Copy() *SubmitOptions

func (*SubmitOptions) CopyAsInterface

func (v *SubmitOptions) CopyAsInterface() interface{}

func (*SubmitOptions) Equal

func (v *SubmitOptions) Equal(u *SubmitOptions) bool

func (*SubmitOptions) IsValid

func (v *SubmitOptions) IsValid() error

func (*SubmitOptions) MarshalBinary

func (v *SubmitOptions) MarshalBinary() ([]byte, error)

func (*SubmitOptions) UnmarshalBinary

func (v *SubmitOptions) UnmarshalBinary(data []byte) error

func (*SubmitOptions) UnmarshalBinaryFrom

func (v *SubmitOptions) UnmarshalBinaryFrom(rd io.Reader) error

type TendermintSubmitModule

type TendermintSubmitModule struct {
	Connection connections.ConnectionContext
}

func (TendermintSubmitModule) Submit

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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