statebased

package
v0.0.0-...-6f64d5f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyLevelValidationParameterManager

type KeyLevelValidationParameterManager interface {
	// GetValidationParameterForKey returns the validation parameter for the
	// supplied KVS key identified by (ch, cc, coll, key) at the specified block
	// TODO: remove ch from the comment on the previous line as part of FAB-9908
	// height h. The function returns the validation parameter and no error in case of
	// success, or nil and an error otherwise. One particular error that may be
	// returned is ValidationParameterUpdatedErr, which is returned in case the
	// validation parmeters for the given KVS key have been changed by a transaction
	// with txNum smaller than the one supplied by the caller. This protects from a
	// scenario where a transaction changing validation parameters is marked as valid
	// by VSCC and is later invalidated by the committer for other reasons (e.g. MVCC
	// conflicts).  This function may be blocking until sufficient information has
	// been passed (by calling ApplyRWSetUpdates and ApplyValidatedRWSetUpdates) for
	// all txes with txNum smaller than the one supplied by the caller.
	GetValidationParameterForKey(ch, cc, coll, key string, blockNum, txNum uint64) ([]byte, error)

	// ExtractValidationParameterDependency is used to determine which validation parameters are
	// updated by transaction at height `h` on channel `ch`. This is needed to determine which txes
	// have dependencies for specific validation parameters and will determine whether
	// GetValidationParameterForKey may block.
	ExtractValidationParameterDependency(ch, cc string, blockNum, txNum uint64, rwset []byte)

	// SetTxValidationCode sets the validation code transaction at height `h` on channel `ch`.
	// This is used to determine whether the dependencies set by
	// ExtractValidationParameterDependency matter or not.
	SetTxValidationCode(ch, cc string, blockNum, txNum uint64, vc peer.TxValidationCode)
}

KeyLevelValidationParameterManager is used by validation plugins in order to retrieve validation parameters for individual KVS keys. The functions are supposed to be called in the following order:

  1. the validation plugin called to validate a certain tx calls ExtractValidationParameterDependency in order for the manager to be able to determine whether validation parameters from the ledger can be used or whether they are being updated by a transaction in this block.
  2. the validation plugin issues 0 or more calls to GetValidationParameterForKey.
  3. the validation plugin determines the validation code for the tx and calls SetTxValidationCode.

type StateBasedValidator

type StateBasedValidator interface {
	// PreValidate sets the internal data structures of the validator needed before validation
	// of `rwset` on the specified channel at the specified height
	PreValidate(ch, cc string, blockNum, txNum uint64, rwset []byte) error

	// Validate determines whether the transaction on the specified channel at the specified height
	// is valid according to its chaincode-level endorsement policy and any key-level validation
	// parametres
	Validate(ch, cc string, blockNum, txNum uint64, rwset, prp, ep []byte, endorsements []*peer.Endorsement) error

	// PostValidate sets the internal data structures of the validator needed after the validation
	// code was determined for a transaction on the specified channel at the specified height
	PostValidate(ch, cc string, blockNum, txNum uint64, vc peer.TxValidationCode) error
}

StateBasedValidator is used to validate a transaction that performs changes to KVS keys that use key-level endorsement policies. This interface is supposed to be called by any validator plugin (including the default validator plugin). The functions of this interface are to be called as follows:

  1. the validator plugin extracts the read-write set from the transaction and calls PreValidate (even before determining whether the transaction is valid)
  2. the validator plugin calls Validate before or after having determined the validity of the transaction based on other considerations
  3. the validator plugin determines the overall validity of the transaction and then calls PostValidate

type ValidationParameterUpdatedErr

type ValidationParameterUpdatedErr struct {
	Key    string
	Height uint64
}

ValidationParameterUpdatedErr is returned whenever Validation Parameters for a key could not be supplied because they are being updated

func (ValidationParameterUpdatedErr) Error

Jump to

Keyboard shortcuts

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