state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CertificationType string = "CertificationType"
	Certification     string = "Certification"

	ChaincodeCertification string = "ChaincodesCertification"

	CertificationFnc string = "state_certification"
)
View Source
const (
	MaxUnicodeRuneValue = utf8.MaxRune // U+10FFFF - maximum (and unallocated) code point

)

Variables

This section is empty.

Functions

func CreateCompositeKey

func CreateCompositeKey(objectType string, attributes []string) (string, error)

func CreateNonce

func CreateNonce() ([]byte, error)

CreateNonce generates a nonce using the common/crypto package.

func CreateNonceOrPanic

func CreateNonceOrPanic() []byte

CreateNonceOrPanic generates a nonce using the common/crypto package and panics if this operation fails.

func CreateRangeKeysForPartialCompositeKey

func CreateRangeKeysForPartialCompositeKey(objectType string, attributes []string) (string, string, error)

func ExchangeRecipientIdentities

func ExchangeRecipientIdentities(context view.Context, recipient view.Identity, opts ...ServiceOption) (view.Identity, view.Identity, error)

ExchangeRecipientIdentities runs the ExchangeRecipientIdentitiesView against the passed receiver. The function returns, the recipient identity of the sender, the recipient identity of the receiver.

func GenerateBytesUUID

func GenerateBytesUUID() []byte

GenerateBytesUUID returns a UUID based on RFC 4122 returning the generated bytes

func GenerateUUID

func GenerateUUID() string

GenerateUUID returns a UUID based on RFC 4122

func GetCertification

func GetCertification(tx TxTransientStore, id string) ([]byte, error)

func GetCertificationType

func GetCertificationType(tx TxTransientStore) (string, []byte, error)

func IDHasPrefixFilter

func IDHasPrefixFilter(prefix string) func(k ID) bool

func InputHasIDPrefixFilter

func InputHasIDPrefixFilter(prefix string) func(i *input) bool

func NewAcceptView

func NewAcceptView(tx *Transaction) view.View

func NewCollectApprovesView

func NewCollectApprovesView(tx *Transaction, parties ...view.Identity) view.View

func NewCollectEndorsementsView

func NewCollectEndorsementsView(tx *Transaction, parties ...view.Identity) view.View

NewCollectEndorsementsView returns a view that does the following: 1. It contacts each passed party sequentially and sends the marshalled version of the passed transaction. 2. It waits for a response containing either the endorsement of the transaction or an error.

func NewEndorseView

func NewEndorseView(tx *Transaction, ids ...view.Identity) view.View

NewEndorseView returns a view that does the following: 1. It signs the transaction with the signing key of each passed identity 2. Send the transaction back on the context's session.

func NewEndorsementOnProposalResponderView

func NewEndorsementOnProposalResponderView(tx *Transaction) view.View

func NewFinalityView

func NewFinalityView(tx *Transaction) view.View

NewFinalityView returns a new instance of the finality view that waits for the finality of the passed transaction.

func NewFinalityWithTimeoutView

func NewFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) view.View

NewFinalityWithTimeoutView runs the finality view for the passed transaction and timeout

func NewOrderingAndFinalityView

func NewOrderingAndFinalityView(tx *Transaction) view.View

NewOrderingAndFinalityView returns a view that does the following: 1. Sends the passed transaction to the ordering service. 2. Waits for the finality of the transaction.

func NewOrderingAndFinalityWithTimeoutView

func NewOrderingAndFinalityWithTimeoutView(tx *Transaction, timeout time.Duration) view.View

func NewParallelCollectEndorsementsOnProposalView

func NewParallelCollectEndorsementsOnProposalView(tx *Transaction, parties ...view.Identity) view.View

func NewPayloadReceiveView

func NewPayloadReceiveView() *payloadReceiveView

func NewReceiveTransactionFromView

func NewReceiveTransactionFromView(party view.Identity) *receiveTransactionView

func NewReceiveTransactionView

func NewReceiveTransactionView() *receiveTransactionView

func NewReceiveView

func NewReceiveView(state interface{}) *receiveView

func NewReplyView

func NewReplyView(state interface{}) *replyView

func NewRespondRequestRecipientIdentityView

func NewRespondRequestRecipientIdentityView() view.View

NewRespondRequestRecipientIdentityView returns a new instance of RespondRequestRecipientIdentityView

func NewSendReceiveView

func NewSendReceiveView(sendState, receiveState interface{}, party view.Identity) *sendReceiveView

func NewSendTransactionBackView

func NewSendTransactionBackView(tx *Transaction) *sendTransactionBackView

func NewSendTransactionView

func NewSendTransactionView(tx *Transaction, parties ...view.Identity) *sendTransactionView

func RequestRecipientIdentity

func RequestRecipientIdentity(context view.Context, other view.Identity) (view.Identity, error)

func RespondExchangeRecipientIdentities

func RespondExchangeRecipientIdentities(context view.Context, opts ...ServiceOption) (view.Identity, view.Identity, error)

RespondExchangeRecipientIdentities runs the RespondExchangeRecipientIdentitiesView

func RespondRequestRecipientIdentity

func RespondRequestRecipientIdentity(context view.Context) (view.Identity, error)

RespondRequestRecipientIdentity runs the RespondRequestRecipientIdentityView and returns the identity sent to the requester. In this case, the identity used is the one returned by fabric.GetFabricNetworkService(context, rr.Network).IdentityProvider().DefaultIdentity()a

func SetCertification

func SetCertification(tx TxTransientStore, id string, value []byte) error

func SetCertificationType

func SetCertificationType(tx TxTransientStore, typ string, value []byte) error

func Unmarshal

func Unmarshal(unmarshaller Unmarshaller, data []byte, v interface{}) error

Types

type AddInputOption

type AddInputOption func(*addInputOptions) error

func WithCertification

func WithCertification() AddInputOption

type AddOutputOption

type AddOutputOption func(*addOutputOptions) error

func WithContract

func WithContract(contract string) AddOutputOption

func WithHashHiding

func WithHashHiding() AddOutputOption

func WithStateBasedEndorsement

func WithStateBasedEndorsement() AddOutputOption

type AutoLinearState

type AutoLinearState interface {
	GetLinearID() (string, error)
}

type Bytes

type Bytes struct {
	Payload []byte
}

type CertificationRequest

type CertificationRequest struct {
	Channel   string
	Namespace string
	Key       string
}

type CertificationView

type CertificationView struct {
	*CertificationRequest
}

func (*CertificationView) Call

func (c *CertificationView) Call(context view.Context) (interface{}, error)

type CertificationViewFactory

type CertificationViewFactory struct{}

func (*CertificationViewFactory) NewView

func (c *CertificationViewFactory) NewView(in []byte) (view.View, error)

type Codec

type Codec interface {
	Marshaller
	Unmarshaller
}

type Command

type Command struct {
	// Name of the commands
	Name string
	// Ids contains the identities that the command involves
	Ids Identities
}

Command models an operation that involve given business parties

type CommonIteratorInterface

type CommonIteratorInterface interface {
	// HasNext returns true if the range query iterator contains additional keys
	// and values.
	HasNext() bool

	// Close closes the iterator. This should be called when done
	// reading from the iterator to free up resources.
	Close() error
}

type EmbeddingState

type EmbeddingState interface {
	GetState() interface{}
}

type EndorseTransaction

type EndorseTransaction interface {
}

type ExchangeRecipientIdentitiesView

type ExchangeRecipientIdentitiesView struct {
	Network       string
	IdentityLabel string
	Other         view.Identity
}

ExchangeRecipientIdentitiesView models the view of the initiator of an exchange of recipient identities.

func (*ExchangeRecipientIdentitiesView) Call

func (f *ExchangeRecipientIdentitiesView) Call(context view.Context) (interface{}, error)

type ExchangeRecipientRequest

type ExchangeRecipientRequest struct {
	Channel       string
	WalletID      []byte
	RecipientData *RecipientData
}

ExchangeRecipientRequest models a request of exchange of recipient identities

func (*ExchangeRecipientRequest) Bytes

func (r *ExchangeRecipientRequest) Bytes() ([]byte, error)

Bytes returns the byte representation of this struct

func (*ExchangeRecipientRequest) FromBytes

func (r *ExchangeRecipientRequest) FromBytes(raw []byte) error

FromBytes unmarshalls the passed bytes into this struct

type Header struct {
	Commands []*Command
}

type ID

type ID string

func (ID) HasPrefix

func (k ID) HasPrefix(prefix string) bool

type IDs

type IDs []ID

func (IDs) Count

func (k IDs) Count() int

func (IDs) Filter

func (k IDs) Filter(f func(k ID) bool) IDs

func (IDs) Match

func (k IDs) Match(keys IDs) bool

type Identities

type Identities []view.Identity

func (Identities) Contain

func (i Identities) Contain(id view.Identity) bool

func (Identities) Count

func (i Identities) Count() int

Count returns the number of identities in the list

func (Identities) Filter

func (i Identities) Filter(f func(identity view.Identity) bool) Identities

func (Identities) Match

func (i Identities) Match(ids []view.Identity) bool

Match returns true if the list of passed identities is equal to this set of identities modulo the position of each identity.

func (Identities) Others

func (i Identities) Others(me view.Identity) Identities

type JSONCodec

type JSONCodec struct{}

func (*JSONCodec) Marshal

func (J *JSONCodec) Marshal(v interface{}) ([]byte, error)

func (*JSONCodec) Unmarshal

func (J *JSONCodec) Unmarshal(data []byte, v interface{}) error

type LinearState

type LinearState interface {
	// SetLinearID assigns the passed id to the state
	SetLinearID(id string) string
}

LinearState models a state with a unique identifier that does not change through the evolution of the state.

type Marshaller

type Marshaller interface {
	Marshal(v interface{}) ([]byte, error)
}

type MetaHandler

type MetaHandler interface {
	StoreMeta(ns *Namespace, s interface{}, namespace string, key string, options *addOutputOptions) error
}

type Namespace

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

func NewNamespace

func NewNamespace(tx *endorser.Transaction, forceSBE bool) *Namespace

func NewNamespaceForName

func NewNamespaceForName(tx *endorser.Transaction, ns string, forceSBE bool) *Namespace

func (*Namespace) AddCommand

func (n *Namespace) AddCommand(command string, ids ...view.Identity) error

AddCommand appends a new Command to this namespace

func (*Namespace) AddInputByLinearID

func (n *Namespace) AddInputByLinearID(id string, state interface{}, opts ...AddInputOption) error

AddInputByLinearID add a reference to the state with the passed id. In addition, the function pupulates the passed state with the content of state associated to the passed id and stored in the vault. Options can be passed to change the behaviour of the function.

func (*Namespace) AddOutput

func (n *Namespace) AddOutput(st interface{}, opts ...AddOutputOption) error

AddOutput adds the passed state following the passed options. This corresponds to a write entry in the RWSet

func (*Namespace) Commands

func (n *Namespace) Commands() *commandStream

Commands returns a stream containing the commands in this namespace

func (*Namespace) Delete

func (n *Namespace) Delete(state interface{}) error

func (*Namespace) GetInputAt

func (n *Namespace) GetInputAt(index int, state interface{}) error

GetInputAt populates the passed state with the content of the input in the passed position. The content of the input is loaded from the vault.

func (*Namespace) GetOutputAt

func (n *Namespace) GetOutputAt(index int, state interface{}) error

GetOutputAt populates the passed state with the content of the output in the passed position

func (*Namespace) GetService

func (n *Namespace) GetService(v interface{}) (interface{}, error)

func (*Namespace) Inputs

func (n *Namespace) Inputs() *inputStream

Inputs returns a stream containing the inputs in this namespace

func (*Namespace) NumInputs

func (n *Namespace) NumInputs() int

NumInputs returns the number of inputs (or reads in the RWSet) contained in this namespace

func (*Namespace) NumOutputs

func (n *Namespace) NumOutputs() int

NumOutputs returns the number of outputs (or writes in the RWSet) contained in this namespace

func (*Namespace) Outputs

func (n *Namespace) Outputs() *outputStream

Outputs returns a stream containing the outputs in this namespace

func (*Namespace) Present

func (n *Namespace) Present() bool

func (*Namespace) RWSet

func (n *Namespace) RWSet() (*fabric.RWSet, error)

TODO: remove

func (*Namespace) SetNamespace

func (n *Namespace) SetNamespace(ns string)

SetNamespace sets the name of this namespace

func (*Namespace) VerifyInputCertificationAt

func (n *Namespace) VerifyInputCertificationAt(index int, key string) error

type Namespaces

type Namespaces []string

func (Namespaces) Count

func (k Namespaces) Count() int

func (Namespaces) Filter

func (k Namespaces) Filter(f func(k string) bool) Namespaces

func (Namespaces) Match

func (k Namespaces) Match(keys Namespaces) bool

type Network

type Network interface {
	Channel(name string) (*fabric.Channel, error)
}

type Ownable

type Ownable interface {
	// Owners returns the identities of the owners of this state
	Owners() Identities
}

Ownable models an ownable state

type QueryIteratorInterface

type QueryIteratorInterface interface {
	CommonIteratorInterface

	Next(state interface{}) (string, error)
}

QueryIteratorInterface models a state iterator

type RWSetProcessor

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

func NewRWSetProcessor

func NewRWSetProcessor(network Network) *RWSetProcessor

func (*RWSetProcessor) Process

type RecipientData

type RecipientData struct {
	// Identity is the recipient identity
	Identity view.Identity
}

RecipientData models the answer to a request of recipient identity

func (*RecipientData) Bytes

func (r *RecipientData) Bytes() ([]byte, error)

Bytes returns the byte representation of this struct

func (*RecipientData) FromBytes

func (r *RecipientData) FromBytes(raw []byte) error

FromBytes unmarshalls the passed bytes into this struct

type RecipientRequest

type RecipientRequest struct {
	// Network identifier
	Network string
}

RecipientRequest models a request of recipient identity

func (*RecipientRequest) Bytes

func (r *RecipientRequest) Bytes() ([]byte, error)

Bytes returns the byte representation of this struct

func (*RecipientRequest) FromBytes

func (r *RecipientRequest) FromBytes(raw []byte) error

FromBytes unmarshalls the passed bytes into this struct

type RequestRecipientIdentityView

type RequestRecipientIdentityView struct {
	Network string
	Other   view.Identity
}

func (RequestRecipientIdentityView) Call

func (f RequestRecipientIdentityView) Call(context view.Context) (interface{}, error)

type RespondExchangeRecipientIdentitiesView

type RespondExchangeRecipientIdentitiesView struct {
	Network       string
	IdentityLabel string
}

RespondExchangeRecipientIdentitiesView models the view of the responder of an exchange of recipient identities.

func (*RespondExchangeRecipientIdentitiesView) Call

func (s *RespondExchangeRecipientIdentitiesView) Call(context view.Context) (interface{}, error)

type RespondRequestRecipientIdentityView

type RespondRequestRecipientIdentityView struct {
	Identity view.Identity
}

RespondRequestRecipientIdentityView models a view of a responder to a request of recipient identity

func (*RespondRequestRecipientIdentityView) Call

func (s *RespondRequestRecipientIdentityView) Call(context view.Context) (interface{}, error)

Call does the following: 1. Reads a first message from the context's session 2. Unmarshall the message into rr = RecipientRequest 3. If the identity to send back is not set, it is set to fabric.GetFabricNetworkService(context, rr.Network).IdentityProvider().DefaultIdentity() 4. Send back marshalled RecipientData struct

type Serializable

type Serializable interface {
	Bytes() ([]byte, error)
}

type ServiceOption

type ServiceOption func(*ServiceOptions) error

ServiceOption models an option

func WithChannel

func WithChannel(channel string) ServiceOption

WithChannel is a ServiceOption to set the channel

func WithIdentity

func WithIdentity(identity string) ServiceOption

WithIdentity is a ServiceOption to set the identity

func WithNetwork

func WithNetwork(network string) ServiceOption

WithNetwork is a ServiceOption to set the network

type ServiceOptions

type ServiceOptions struct {
	// Network is the name of the network to use
	Network string
	// Channel is the name of the channel to use
	Channel string
	// Identity is the name of the identity to use
	Identity string
}

ServiceOptions defines the options for the state service

func CompileServiceOptions

func CompileServiceOptions(opts ...ServiceOption) (*ServiceOptions, error)

CompileServiceOptions compiles the service options

type State

type State interface {
	SetFromBytes(raw []byte) error
}

type Transaction

type Transaction struct {
	*endorser.Transaction
	*Namespace
}

func NewAnonymousTransaction

func NewAnonymousTransaction(context view.Context) (*Transaction, error)

NewAnonymousTransaction returns a new instance of a state-based transaction that embeds a single namespace and is signed by an anonymous identity

func NewTransaction

func NewTransaction(context view.Context) (*Transaction, error)

NewTransaction returns a new instance of a state-based transaction that embeds a single namespace.

func NewTransactionFromBytes

func NewTransactionFromBytes(context view.Context, raw []byte) (*Transaction, error)

func ReceiveTransaction

func ReceiveTransaction(context view.Context) (*Transaction, error)

ReceiveTransaction runs the receiveTransactionView that expects on the context's session a byte representation of a state transaction.

func ReceiveTransactionFrom

func ReceiveTransactionFrom(context view.Context, party view.Identity) (*Transaction, error)

func SendAndReceiveTransaction

func SendAndReceiveTransaction(context view.Context, tx *Transaction, party view.Identity) (*Transaction, error)

func SendBackAndReceiveTransaction

func SendBackAndReceiveTransaction(context view.Context, tx *Transaction) (*Transaction, error)

func Wrap

func Wrap(tx *endorser.Transaction) (*Transaction, error)

type TxTransientStore

type TxTransientStore interface {
	SetTransient(key string, raw []byte) error
	GetTransient(key string) []byte
}

type Unmarshaller

type Unmarshaller interface {
	Unmarshal(data []byte, v interface{}) error
}

type Vault

type Vault interface {
	// GetState loads the state identified by the tuple [namespace, id] into the passed state reference.
	GetState(namespace string, id string, state interface{}) error

	GetStateCertification(namespace string, key string) ([]byte, error)

	GetStateByPartialCompositeID(ns string, prefix string, attrs []string) (QueryIteratorInterface, error)
}

Vault models a container of states

func GetVault

func GetVault(ctx view2.ServiceProvider) Vault

func GetVaultForChannel

func GetVaultForChannel(ctx view2.ServiceProvider, channel string) Vault

type VaultService

type VaultService interface {
	// Vault returns the world state for the passed channel.
	Vault(network string, channel string) (Vault, error)
}

VaultService models a vault instance provider

func GetVaultService

func GetVaultService(ctx view2.ServiceProvider) VaultService

type ViewManager

type ViewManager interface {
	InitiateView(view view.View) (interface{}, error)
}

Directories

Path Synopsis
cc
query Module
api

Jump to

Keyboard shortcuts

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