transform

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LifecycleChaincodeName = "_lifecycle"

	// MetadataPrefix - this is the prefix of the state key, which stores information about the keys
	// in the corresponding namespace. Each committed chaincode in the channel has this state
	MetadataPrefix = "namespaces/metadata"

	// FieldsPrefix - prefix of the state key, which stores the parameters
	// of the committed chaincode in the channel
	FieldsPrefix = "namespaces/fields"

	// CollectionField ValidationInfoField EndorsementInfoField SequenceField - state key suffixes
	// that store the parameters of the committed chaincode in the channel
	CollectionField      = "Collections"
	ValidationInfoField  = "ValidationInfo"
	EndorsementInfoField = "EndorsementInfo"
	SequenceField        = "Sequence"

	Collection      = FieldsPrefix + "/" + CollectionField
	ValidationInfo  = FieldsPrefix + "/" + ValidationInfoField
	EndorsementInfo = FieldsPrefix + "/" + EndorsementInfoField
	Sequence        = FieldsPrefix + "/" + SequenceField
)

Variables

View Source
var LifecycleTransformers = []hlfproto.Transformer{
	NewAction(
		TxChaincodeIDMatch(LifecycleChaincodeName),
		WithKVWriteTransformer(
			KVWriteKeyReplace(LifecycleStateKeyStrMapping(), func(write *kvrwset.KVWrite) error {
				write.Key = keyReplace(write.Key)
				return nil
			}),
		),
	),
	NewAction(
		TxChaincodeAnyMatch(),
		WithKVReadTransformer(
			KVReadKeyReplace(LifecycleStateKeyStrMapping(), func(read *kvrwset.KVRead) error {
				read.Key = keyReplace(read.Key)
				return nil
			}),
		),
	),
}

Functions

func LifecycleStateKeyStrMapping

func LifecycleStateKeyStrMapping() map[string]string

func MappingPrefixes

func MappingPrefixes(mapping map[string]string) []string

func Proto2JSON

func Proto2JSON(serialized []byte, target proto.Message) ([]byte, error)

func RemoveBytesNullBytes

func RemoveBytesNullBytes(str []byte) []byte

func RemoveStringNullBytes

func RemoveStringNullBytes(str string) string

func ReplaceBytesU0000ToNullBytes

func ReplaceBytesU0000ToNullBytes(str []byte) []byte

func ReplaceStringNullBytesToSeparator

func ReplaceStringNullBytesToSeparator(str string) string

func ReplaceStringSeparatorToNullBytes

func ReplaceStringSeparatorToNullBytes(str string) string

Types

type Action

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

func NewAction

func NewAction(actionMach TxActionMatch, opts ...ActionOpt) *Action

func (*Action) Transform

func (s *Action) Transform(block *hlfproto.Block) (*hlfproto.Block, error)

type ActionOpt

type ActionOpt func(*Action)

func WithActionPayloadTransformer

func WithActionPayloadTransformer(actionTransformers ...ActionPayloadTransformer) ActionOpt

func WithEventTransformer

func WithEventTransformer(eventTransformers ...EventTransformer) ActionOpt

func WithInputArgsTransformer

func WithInputArgsTransformer(inputArgsTransformers ...InputArgsTransformer) ActionOpt

func WithKVReadTransformer

func WithKVReadTransformer(kvReadTransformers ...KVReadTransformer) ActionOpt

func WithKVWriteTransformer

func WithKVWriteTransformer(kvWriteTransformers ...KVWriteTransformer) ActionOpt

type ActionPayload

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

func ActionPayloadProto

func ActionPayloadProto(methodName string, txAction proto.Message) *ActionPayload

func NewActionPayload

func NewActionPayload(match ActionPayloadMatch, mutators ...ActionPayloadMutate) *ActionPayload

func (*ActionPayload) Transform

func (action *ActionPayload) Transform(txAction *hlfproto.TransactionAction) error

type ActionPayloadMatch

type ActionPayloadMatch func(string) bool

func ActionPayloadMatchFunc

func ActionPayloadMatchFunc(str string) ActionPayloadMatch

type ActionPayloadMutate

type ActionPayloadMutate func(*hlfproto.TransactionAction) error

func ActionPayloadMutateProto

func ActionPayloadMutateProto(target proto.Message) ActionPayloadMutate

type ActionPayloadTransformer

type ActionPayloadTransformer interface {
	Transform(*hlfproto.TransactionAction) error
}

type Event

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

func EventProto

func EventProto(eventName string, target proto.Message) *Event

func NewEvent

func NewEvent(match EventMatch, mutate EventMutate) *Event

func (*Event) Transform

func (e *Event) Transform(event *peer.ChaincodeEvent) error

type EventMatch

type EventMatch func(string) bool

func EventMatchFunc

func EventMatchFunc(str string) EventMatch

type EventMutate

type EventMutate func(*peer.ChaincodeEvent) error

func EventMutateProto

func EventMutateProto(target proto.Message) EventMutate

type EventTransformer

type EventTransformer interface {
	Transform(*peer.ChaincodeEvent) error
}

type InputArgs

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

func InputArgsProto

func InputArgsProto(fn string, target proto.Message) *InputArgs

func NewInputArgs

func NewInputArgs(match InputArgsMatch, mutate InputArgsMutate) *InputArgs

func (*InputArgs) Transform

func (tr *InputArgs) Transform(args [][]byte) error

type InputArgsMatch

type InputArgsMatch func([][]byte) bool

func InputArgsMatchFunc

func InputArgsMatchFunc(fn string) InputArgsMatch

func InputArgsMatchString

func InputArgsMatchString(pos int, str string) InputArgsMatch

type InputArgsMutate

type InputArgsMutate func([][]byte) error

func InputArgsMutateProto

func InputArgsMutateProto(target proto.Message) InputArgsMutate

func InputArgsMutateProtoAtPos

func InputArgsMutateProtoAtPos(target proto.Message, pos int) InputArgsMutate

type InputArgsTransformer

type InputArgsTransformer interface {
	Transform([][]byte) error
}

type KVRead

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

func KVReadKeyObjectTypeReplaceByMap

func KVReadKeyObjectTypeReplaceByMap(mapping map[string]string, additionalMutators ...KVReadMutate) *KVRead

func KVReadKeyReplace

func KVReadKeyReplace(mapping map[string]string, additionalMutators ...KVReadMutate) *KVRead

func KVReadMutatorWithKeyPrefix

func KVReadMutatorWithKeyPrefix(prefix string, mutator KVReadMutate) *KVRead

func KVReadProtoWithKeyPrefix

func KVReadProtoWithKeyPrefix(prefix string, target proto.Message) *KVRead

func NewKVRead

func NewKVRead(match KVReadMatch, mutators ...KVReadMutate) *KVRead

func (*KVRead) Transform

func (kvread *KVRead) Transform(w *kvrwset.KVRead) error

type KVReadMatch

type KVReadMatch func(*kvrwset.KVRead) bool

func KVReadMatchKey

func KVReadMatchKey(contents ...string) KVReadMatch

func KVReadMatchKeyPrefix

func KVReadMatchKeyPrefix(prefixes ...string) KVReadMatch

type KVReadMutate

type KVReadMutate func(*kvrwset.KVRead) error

func KVReadKeyReplacer

func KVReadKeyReplacer(mapping map[string]string) KVReadMutate

type KVReadTransformer

type KVReadTransformer interface {
	Transform(*kvrwset.KVRead) error
}

type KVWrite

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

func KVWriteKeyObjectTypeReplaceByMap

func KVWriteKeyObjectTypeReplaceByMap(mapping map[string]string, additionalMutators ...KVWriteMutate) *KVWrite

func KVWriteKeyReplace

func KVWriteKeyReplace(mapping map[string]string, additionalMutators ...KVWriteMutate) *KVWrite

func KVWriteMutatorWithKeyPrefix

func KVWriteMutatorWithKeyPrefix(prefix string, mutator KVWriteMutate) *KVWrite

func KVWriteProtoWithKeyPrefix

func KVWriteProtoWithKeyPrefix(prefix string, target proto.Message) *KVWrite

func NewKVWrite

func NewKVWrite(match KVWriteMatch, mutators ...KVWriteMutate) *KVWrite

func (*KVWrite) Transform

func (kvwrite *KVWrite) Transform(w *kvrwset.KVWrite) error

type KVWriteMatch

type KVWriteMatch func(*kvrwset.KVWrite) bool

func KVWriteMatchKey

func KVWriteMatchKey(contents ...string) KVWriteMatch

func KVWriteMatchKeyPrefix

func KVWriteMatchKeyPrefix(prefixes ...string) KVWriteMatch

type KVWriteMutate

type KVWriteMutate func(*kvrwset.KVWrite) error

func KVWriteKeyReplacer

func KVWriteKeyReplacer(mapping map[string]string) KVWriteMutate

func KVWriteMutateProto

func KVWriteMutateProto(target proto.Message) KVWriteMutate

type KVWriteTransformer

type KVWriteTransformer interface {
	Transform(*kvrwset.KVWrite) error
}

type TxActionMatch

type TxActionMatch func(*hlfproto.TransactionAction) bool

func TxChaincodeAnyMatch

func TxChaincodeAnyMatch() TxActionMatch

func TxChaincodeIDMatch

func TxChaincodeIDMatch(chaincode string) TxActionMatch

func TxChaincodeIDNotMatch

func TxChaincodeIDNotMatch(chaincode string) TxActionMatch

func TxChaincodePatternsIDRegexpExclude

func TxChaincodePatternsIDRegexpExclude(chaincodePatterns ...string) TxActionMatch

func TxChaincodesIDMatch

func TxChaincodesIDMatch(chaincodes ...string) TxActionMatch

func TxChaincodesIDRegexp

func TxChaincodesIDRegexp(chaincodePattern string) TxActionMatch

func TxChaincodesIDRegexpExclude

func TxChaincodesIDRegexpExclude(chaincodePattern string) TxActionMatch

type TxActionMutate

type TxActionMutate func(*hlfproto.TransactionAction)

Jump to

Keyboard shortcuts

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