state

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RuntimeVersionSubscription added in v1.0.0

type RuntimeVersionSubscription struct {
	// contains filtered or unexported fields
}

RuntimeVersionSubscription is a subscription established through one of the Client's subscribe methods.

func (*RuntimeVersionSubscription) Chan added in v1.0.0

Chan returns the subscription channel.

The channel is closed when Unsubscribe is called on the subscription.

func (*RuntimeVersionSubscription) Err added in v1.0.0

func (s *RuntimeVersionSubscription) Err() <-chan error

Err returns the subscription error channel. The intended use of Err is to schedule resubscription when the client connection is closed unexpectedly.

The error channel receives a value when the subscription has ended due to an error. The received error is nil if Close has been called on the underlying client and no other error has occurred.

The error channel is closed when Unsubscribe is called on the subscription.

func (*RuntimeVersionSubscription) Unsubscribe added in v1.0.0

func (s *RuntimeVersionSubscription) Unsubscribe()

Unsubscribe unsubscribes the notification and closes the error channel. It can safely be called more than once.

type State

type State struct {
	// contains filtered or unexported fields
}

State exposes methods for querying state

func NewState

func NewState(c client.Client) *State

NewState creates a new State struct

func (*State) GetChildKeys added in v0.0.3

func (s *State) GetChildKeys(childStorageKey, prefix types.StorageKey, blockHash types.Hash) (
	[]types.StorageKey, error)

GetChildKeys retreives the keys with the given prefix of a specific child storage

func (*State) GetChildKeysLatest added in v0.0.3

func (s *State) GetChildKeysLatest(childStorageKey, prefix types.StorageKey) ([]types.StorageKey, error)

GetChildKeysLatest retreives the keys with the given prefix of a specific child storage for the latest block height

func (*State) GetChildStorage added in v0.0.3

func (s *State) GetChildStorage(childStorageKey, key types.StorageKey, target interface{}, blockHash types.Hash) (
	ok bool, err error)

GetChildStorage retreives the child storage for a key and decodes them into the provided interface. Ok is true if the value is not empty.

func (*State) GetChildStorageHash added in v0.0.3

func (s *State) GetChildStorageHash(childStorageKey, key types.StorageKey, blockHash types.Hash) (types.Hash, error)

GetChildStorageHash retreives the child storage hash for the given key

func (*State) GetChildStorageHashLatest added in v0.0.3

func (s *State) GetChildStorageHashLatest(childStorageKey, key types.StorageKey) (types.Hash, error)

GetChildStorageHashLatest retreives the child storage hash for the given key for the latest block height

func (*State) GetChildStorageLatest added in v0.0.3

func (s *State) GetChildStorageLatest(childStorageKey, key types.StorageKey, target interface{}) (ok bool, err error)

GetChildStorageLatest retreives the child storage for a key for the latest block height and decodes them into the provided interface. Ok is true if the value is not empty.

func (*State) GetChildStorageRaw added in v0.0.3

func (s *State) GetChildStorageRaw(childStorageKey, key types.StorageKey, blockHash types.Hash) (
	*types.StorageDataRaw, error)

GetChildStorageRaw retreives the child storage for a key as raw bytes, without decoding them

func (*State) GetChildStorageRawLatest added in v0.0.3

func (s *State) GetChildStorageRawLatest(childStorageKey, key types.StorageKey) (*types.StorageDataRaw, error)

GetChildStorageRawLatest retreives the child storage for a key for the latest block height as raw bytes, without decoding them

func (*State) GetChildStorageSize added in v0.0.3

func (s *State) GetChildStorageSize(childStorageKey, key types.StorageKey, blockHash types.Hash) (types.U64, error)

GetChildStorageSize retreives the child storage size for the given key

func (*State) GetChildStorageSizeLatest added in v0.0.3

func (s *State) GetChildStorageSizeLatest(childStorageKey, key types.StorageKey) (types.U64, error)

GetChildStorageSizeLatest retreives the child storage size for the given key for the latest block height

func (*State) GetKeys added in v0.0.3

func (s *State) GetKeys(prefix types.StorageKey, blockHash types.Hash) ([]types.StorageKey, error)

GetKeys retreives the keys with the given prefix

func (*State) GetKeysLatest added in v0.0.3

func (s *State) GetKeysLatest(prefix types.StorageKey) ([]types.StorageKey, error)

GetKeysLatest retreives the keys with the given prefix for the latest block height

func (*State) GetMetadata

func (s *State) GetMetadata(blockHash types.Hash) (*types.Metadata, error)

GetMetadata returns the metadata at the given block

func (*State) GetMetadataLatest

func (s *State) GetMetadataLatest() (*types.Metadata, error)

GetMetadataLatest returns the latest metadata

func (*State) GetRuntimeVersion

func (s *State) GetRuntimeVersion(blockHash types.Hash) (*types.RuntimeVersion, error)

GetRuntimeVersion returns the runtime version at the given block

func (*State) GetRuntimeVersionLatest

func (s *State) GetRuntimeVersionLatest() (*types.RuntimeVersion, error)

GetRuntimeVersionLatest returns the latest runtime version

func (*State) GetStorage added in v0.0.3

func (s *State) GetStorage(key types.StorageKey, target interface{}, blockHash types.Hash) (ok bool, err error)

GetStorage retreives the stored data and decodes them into the provided interface. Ok is true if the value is not empty.

func (*State) GetStorageHash added in v0.0.3

func (s *State) GetStorageHash(key types.StorageKey, blockHash types.Hash) (types.Hash, error)

GetStorageHash retreives the storage hash for the given key

func (*State) GetStorageHashLatest added in v0.0.3

func (s *State) GetStorageHashLatest(key types.StorageKey) (types.Hash, error)

GetStorageHashLatest retreives the storage hash for the given key for the latest block height

func (*State) GetStorageLatest added in v0.0.3

func (s *State) GetStorageLatest(key types.StorageKey, target interface{}) (ok bool, err error)

GetStorageLatest retreives the stored data for the latest block height and decodes them into the provided interface. Ok is true if the value is not empty.

func (*State) GetStorageRaw added in v0.0.3

func (s *State) GetStorageRaw(key types.StorageKey, blockHash types.Hash) (*types.StorageDataRaw, error)

GetStorageRaw retreives the stored data as raw bytes, without decoding them

func (*State) GetStorageRawLatest added in v0.0.3

func (s *State) GetStorageRawLatest(key types.StorageKey) (*types.StorageDataRaw, error)

GetStorageRawLatest retreives the stored data for the latest block height as raw bytes, without decoding them

func (*State) GetStorageSize added in v0.0.3

func (s *State) GetStorageSize(key types.StorageKey, blockHash types.Hash) (types.U64, error)

GetStorageSize retreives the storage size for the given key

func (*State) GetStorageSizeLatest added in v0.0.3

func (s *State) GetStorageSizeLatest(key types.StorageKey) (types.U64, error)

GetStorageSizeLatest retreives the storage size for the given key for the latest block height

func (*State) QueryStorage added in v1.0.0

func (s *State) QueryStorage(keys []types.StorageKey, startBlock types.Hash, block types.Hash) (
	[]types.StorageChangeSet, error)

QueryStorage queries historical storage entries (by key) starting from a start block until an end block

func (*State) QueryStorageLatest added in v1.0.0

func (s *State) QueryStorageLatest(keys []types.StorageKey, startBlock types.Hash) ([]types.StorageChangeSet, error)

QueryStorageLatest queries historical storage entries (by key) starting from a start block until the latest block

func (*State) SubscribeRuntimeVersion added in v1.0.0

func (s *State) SubscribeRuntimeVersion() (
	*RuntimeVersionSubscription, error)

SubscribeRuntimeVersion subscribes the runtime version, returning a subscription that will receive server notifications containing the RuntimeVersion.

func (*State) SubscribeStorageRaw added in v1.0.0

func (s *State) SubscribeStorageRaw(keys []types.StorageKey) (
	*StorageSubscription, error)

SubscribeStorageRaw subscribes the storage for the given keys, returning a subscription that will receive server notifications containing the storage change sets.

Slow subscribers will be dropped eventually. Client buffers up to 20000 notifications before considering the subscriber dead. The subscription Err channel will receive ErrSubscriptionQueueOverflow. Use a sufficiently large buffer on the channel or ensure that the channel usually has at least one reader to prevent this issue.

type StorageSubscription added in v1.0.0

type StorageSubscription struct {
	// contains filtered or unexported fields
}

StorageSubscription is a subscription established through one of the Client's subscribe methods.

func (*StorageSubscription) Chan added in v1.0.0

func (s *StorageSubscription) Chan() <-chan types.StorageChangeSet

Chan returns the subscription channel.

The channel is closed when Unsubscribe is called on the subscription.

func (*StorageSubscription) Err added in v1.0.0

func (s *StorageSubscription) Err() <-chan error

Err returns the subscription error channel. The intended use of Err is to schedule resubscription when the client connection is closed unexpectedly.

The error channel receives a value when the subscription has ended due to an error. The received error is nil if Close has been called on the underlying client and no other error has occurred.

The error channel is closed when Unsubscribe is called on the subscription.

func (*StorageSubscription) Unsubscribe added in v1.0.0

func (s *StorageSubscription) Unsubscribe()

Unsubscribe unsubscribes the notification and closes the error channel. It can safely be called more than once.

Jump to

Keyboard shortcuts

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