Documentation ¶
Index ¶
- Variables
- func BlockHeaderBytes(b *common.BlockHeader) []byte
- func CheckIntegrity(previousblock, currentblock *Block) bool
- type Action
- func (a *Action) ChaincodeAction() (*peer.ChaincodeAction, error)
- func (a *Action) ChaincodeActionPayload() *peer.ChaincodeActionPayload
- func (a *Action) ChaincodeEvent() (*peer.ChaincodeEvent, error)
- func (a *Action) ChaincodeInput() ([]string, error)
- func (a *Action) ChaincodeProposalPayload() (*peer.ChaincodeProposalPayload, error)
- func (a *Action) CreatorCertBytes() ([]byte, error)
- func (a *Action) CreatorCertHashHex() (string, error)
- func (a *Action) CreatorMSPID() (string, error)
- func (a *Action) Decorations() (map[string][]byte, error)
- func (a *Action) Endorsements() []*peer.Endorsement
- func (a *Action) IsInit() (bool, error)
- func (a *Action) ProposalHash() ([]byte, error)
- func (a *Action) ProposalResponsePayload() (*peer.ProposalResponsePayload, error)
- func (a *Action) RWSets() ([]RwSet, error)
- func (a *Action) TransientMap() (map[string][]byte, error)
- type BFTSerializedIdentity
- type Block
- func (b *Block) DataHash() []byte
- func (b *Block) HeaderHash() []byte
- func (b *Block) IsConfig() bool
- func (b *Block) LastConfig() (uint64, error)
- func (b *Block) Number() uint64
- func (b *Block) OrderersSignatures() []BlockSignature
- func (b *Block) PreviousHash() []byte
- func (b *Block) Txs() ([]Tx, error)
- func (b *Block) TxsFromOrdererBlock() ([]Tx, error)
- type BlockSignature
- type RwSet
- type Tx
- func (tx *Tx) Actions() ([]Action, error)
- func (tx *Tx) CfgEnvLastUpdateCreatorSignatureBytes() ([]byte, error)
- func (tx *Tx) CfgEnvLastUpdateCreatorSignatureHex() (string, error)
- func (tx *Tx) ChaincodeId() (*peer.ChaincodeID, error)
- func (tx *Tx) ChannelHeader() (*common.ChannelHeader, error)
- func (tx *Tx) ConfigEnvelope() (*common.ConfigEnvelope, error)
- func (tx *Tx) ConfigEnvelopeLastUpdatePayload() (*common.Payload, error)
- func (tx *Tx) ConfigGroup() (*common.ConfigGroup, error)
- func (tx *Tx) ConfigSequence() (uint64, error)
- func (tx *Tx) ConfigUpdate() (*common.ConfigUpdate, error)
- func (tx *Tx) Creator() (string, []byte, error)
- func (tx *Tx) CreatorSignatureBytes() ([]byte, error)
- func (tx *Tx) CreatorSignatureHexString() (string, error)
- func (tx *Tx) Envelope() (*common.Envelope, error)
- func (tx *Tx) Epoch() (uint64, error)
- func (tx *Tx) IsValid() bool
- func (tx *Tx) Payload() (*common.Payload, error)
- func (tx *Tx) PeerTransaction() (*peer.Transaction, error)
- func (tx *Tx) SignatureHeader() (*common.SignatureHeader, error)
- func (tx *Tx) Timestamp() (time.Time, error)
- func (tx *Tx) TlsCertHash() ([]byte, error)
- func (tx *Tx) TxId() (string, error)
- func (tx *Tx) ValidationCode() int32
- func (tx *Tx) ValidationStatus() string
- type TxValidationCode
- type TxValidationFlags
Constants ¶
This section is empty.
Variables ¶
var TxValidationCode_name = map[int32]string{
0: "VALID",
1: "NIL_ENVELOPE",
2: "BAD_PAYLOAD",
3: "BAD_COMMON_HEADER",
4: "BAD_CREATOR_SIGNATURE",
5: "INVALID_ENDORSER_TRANSACTION",
6: "INVALID_CONFIG_TRANSACTION",
7: "UNSUPPORTED_TX_PAYLOAD",
8: "BAD_PROPOSAL_TXID",
9: "DUPLICATE_TXID",
10: "ENDORSEMENT_POLICY_FAILURE",
11: "MVCC_READ_CONFLICT",
12: "PHANTOM_READ_CONFLICT",
13: "UNKNOWN_TX_TYPE",
14: "TARGET_CHAIN_NOT_FOUND",
15: "MARSHAL_TX_ERROR",
16: "NIL_TXACTION",
17: "EXPIRED_CHAINCODE",
18: "CHAINCODE_VERSION_CONFLICT",
19: "BAD_HEADER_EXTENSION",
20: "BAD_CHANNEL_HEADER",
21: "BAD_RESPONSE_PAYLOAD",
22: "BAD_RWSET",
23: "ILLEGAL_WRITESET",
24: "INVALID_WRITESET",
25: "INVALID_CHAINCODE",
254: "NOT_VALIDATED",
255: "INVALID_OTHER_REASON",
}
Functions ¶
func BlockHeaderBytes ¶
func BlockHeaderBytes(b *common.BlockHeader) []byte
func CheckIntegrity ¶
CheckIntegrity checks that two blocks are 'connected'. This func compares current block header 'PreviousHash' (hash of block number, data and PreviousHash - think of it as a link to the previous block) with actual previous block header hash.
Types ¶
type Action ¶
type Action struct { Payload *peer.ChaincodeActionPayload SignatureHeader *common.SignatureHeader }
func (*Action) ChaincodeAction ¶
func (a *Action) ChaincodeAction() (*peer.ChaincodeAction, error)
ChaincodeAction returns a pointer to peer.ChaincodeAction that contains and actions the events generated by the execution of the chaincode.
func (*Action) ChaincodeActionPayload ¶
func (a *Action) ChaincodeActionPayload() *peer.ChaincodeActionPayload
ChaincodeActionPayload returns pointer to peer.ChaincodeActionPayload. ChaincodeActionPayload is the message to be used for the TransactionAction's payload when the Header's type is set to CHAINCODE. It carries the chaincodeProposalPayload and an endorsed action to apply to the ledger.
func (*Action) ChaincodeEvent ¶
func (a *Action) ChaincodeEvent() (*peer.ChaincodeEvent, error)
ChaincodeEvent returns a pointer to peer.ChaincodeEvent that contains events info.
func (*Action) ChaincodeInput ¶
ChaincodeInput retrieves chaincode input, format and returns it as string slice.
func (*Action) ChaincodeProposalPayload ¶
func (a *Action) ChaincodeProposalPayload() (*peer.ChaincodeProposalPayload, error)
ChaincodeProposalPayload returns a pointer to peer.ChaincodeProposalPayload. This method should be used for retrieving input or transient data of the chaincode invocation.
func (*Action) CreatorCertBytes ¶
CreatorCertBytes returns pem-encoded certificate of transaction creator.
func (*Action) CreatorCertHashHex ¶
CreatorCertHashHex returns hex-encoded SHA256 hash of pem-encoded certificate of transaction creator.
func (*Action) CreatorMSPID ¶
CreatorMSPID returns MSP ID of the organization the creator belongs to.
func (*Action) Decorations ¶
Decorations returns additional data (if applicable) about the proposal that originated from the peer. This data is set by the decorators of the peer, which append or mutate the chaincode input passed to the chaincode.
unfortunately decorations are always nil in the current HLF versions https://github.com/hyperledger/fabric/blob/master/core/endorser/support.go#L121
func (*Action) Endorsements ¶
func (a *Action) Endorsements() []*peer.Endorsement
Endorsements returns a slice of pointers to peer.Endorsement. An endorsement is a signature of an endorser over a proposal response. By producing an endorsement message, an endorser implicitly "approves" that proposal response and the actions contained therein. When enough endorsements have been collected, a transaction can be generated out of a set of proposal responses. Note that this message only contains an identity and a signature but no signed payload. This is intentional because endorsements are supposed to be collected in a transaction, and they are all expected to endorse a single proposal response/action (many endorsements over a single proposal response).
func (*Action) IsInit ¶
IsInit returns true (is Init invoked) or false (not Init invoked). is_init is used for the application to signal that an invocation is to be routed to the legacy 'Init' function for compatibility with chaincodes which handled Init in the old way. New applications should manage their initialized state themselves.
func (*Action) ProposalHash ¶
ProposalHash returns SHA256 hash of common.ChannelHeader, common.SignatureHeader and peer.ProposalResponsePayload.
func (*Action) ProposalResponsePayload ¶
func (a *Action) ProposalResponsePayload() (*peer.ProposalResponsePayload, error)
ProposalResponsePayload returns a pointer to peer.ProposalResponsePayload. ProposalResponsePayload is the payload of a proposal response. This message is the "bridge" between the client's request and the endorser's action in response to that request. Concretely, for chaincodes, it contains a hashed representation of the proposal (proposalHash) and a representation of the chaincode state changes and events inside the extension field.
func (*Action) TransientMap ¶
TransientMap contains data (e.g. cryptographic material) that might be used to implement some form of application-level confidentiality. The contents of this field are supposed to always be omitted from the transaction and excluded from the ledger.
type BFTSerializedIdentity ¶
type BFTSerializedIdentity struct { ConsenterId uint64 Identity msp.SerializedIdentity }
type Block ¶
Block contains all the necessary information about the blockchain block
func FromBFTFabricBlock ¶
FromBFTFabricBlock converts common.Block produced by BFT-orderer to blocklib.Block.
func FromFabricBlock ¶
FromFabricBlock converts common.Block to blocklib.Block. Such conversion is necessary for further comfortable work with information from the block.
func (*Block) HeaderHash ¶
HeaderHash returns hash of the this block's header.
func (*Block) IsConfig ¶
IsConfig returns a boolean value that indicates whether the block is a configuration block.
func (*Block) LastConfig ¶
LastConfig returns last configuration block index for provided block.
func (*Block) OrderersSignatures ¶
func (b *Block) OrderersSignatures() []BlockSignature
OrderersSignatures returns signatures of orderers, their cert, MSP ID and nonce.
func (*Block) PreviousHash ¶
PreviousHash returns hash of the previous block.
func (*Block) TxsFromOrdererBlock ¶
TxsFromOrdererBlock returns transactions from orderer block without validation code and validation status, because odrerer ledger does not contain them.
type BlockSignature ¶
type BlockSignature struct { Cert []byte // pem-encoded MSPID string Signature []byte Nonce []byte }
BlockSignature contains nonce, cert, MSP ID and signature of the orderer which signed the block
type RwSet ¶
type RwSet struct { NameSpace string `json:"namespace"` KVRWSet kvrwset.KVRWSet `json:"kv_rw_set"` CollectionHashedReadWriteSet []*rwset.CollectionHashedReadWriteSet `json:"collection_hashed_rw_set"` }
type Tx ¶
type Tx struct { Data []byte // contains filtered or unexported fields }
func (*Tx) CfgEnvLastUpdateCreatorSignatureBytes ¶
CfgEnvLastUpdateCreatorSignatureBytes extracts signature of transaction creator as bytes slice.
func (*Tx) CfgEnvLastUpdateCreatorSignatureHex ¶
CfgEnvLastUpdateCreatorSignatureHex extracts signature of transaction creator as hex-encoded string.
func (*Tx) ChaincodeId ¶
func (tx *Tx) ChaincodeId() (*peer.ChaincodeID, error)
ChaincodeId returns peer.ChaincodeID (name, version and path) of the target chaincode (only if it's type is common.HeaderType_ENDORSER_TRANSACTION).
func (*Tx) ChannelHeader ¶
func (tx *Tx) ChannelHeader() (*common.ChannelHeader, error)
ChannelHeader returns pointer to common.ChannelHeader of the transaction.
func (*Tx) ConfigEnvelope ¶
func (tx *Tx) ConfigEnvelope() (*common.ConfigEnvelope, error)
ConfigEnvelope returns pointer to common.ConfigEnvelope. common.Envelope contains config and last update payload.
func (*Tx) ConfigEnvelopeLastUpdatePayload ¶
ConfigEnvelopeLastUpdatePayload payload of last config update.
func (*Tx) ConfigGroup ¶
func (tx *Tx) ConfigGroup() (*common.ConfigGroup, error)
ConfigGroup returns a pointer to common.ConfigGroup. ConfigGroup is the hierarchical data structure for holding config.
func (*Tx) ConfigSequence ¶
ConfigSequence returns sequence number of config.
func (*Tx) ConfigUpdate ¶
func (tx *Tx) ConfigUpdate() (*common.ConfigUpdate, error)
ConfigUpdate extracts configuration transaction info from raw transaction.
func (*Tx) Creator ¶
Creator can be used to extract tx creator's MSP ID and PEM-encoded certificate.
func (*Tx) CreatorSignatureBytes ¶
CreatorSignatureBytes extracts signature of transaction creator as bytes slice.
func (*Tx) CreatorSignatureHexString ¶
CreatorSignatureHexString extracts signature of transaction creator as hex-encoded string.
func (*Tx) Envelope ¶
Envelope returns pointer to common.Envelope. common.Envelope contains payload with a signature.
func (*Tx) Epoch ¶
Epoch returns the epoch in which this header was generated, where epoch is defined based on block height Epoch in which the response has been generated. This field identifies a logical window of time. A proposal response is accepted by a peer only if two conditions hold: 1. the epoch specified in the message is the current epoch 2. this message has been only seen once during this epoch (i.e. it hasn't been replayed)
Always equals to 0 because of this reason: https://github.com/hyperledger/fabric/blob/release-2.1/core/common/validation/msgvalidation.go#L110
func (*Tx) IsValid ¶
IsValid checks if transaction with specified number (txNumber int) in block (block *common.Block) is valid or not and returns corresponding bool value.
func (*Tx) Payload ¶
Payload returns pointer to common.Payload. common.Payload is the message contents (and header to allow for signing).
func (*Tx) PeerTransaction ¶
func (tx *Tx) PeerTransaction() (*peer.Transaction, error)
PeerTransaction returns pointer to peer.Transaction. The transaction to be sent to the ordering service. A transaction contains one or more TransactionAction. Each TransactionAction binds a proposal to potentially multiple actions. The transaction is atomic meaning that either all actions in the transaction will be committed or none will. Note that while a Transaction might include more than one Header, the Header.creator field must be the same in each. A single client is free to issue a number of independent Proposal, each with their header (Header) and request payload (ChaincodeProposalPayload). Each proposal is independently endorsed generating an action (ProposalResponsePayload) with one signature per Endorser. Any number of independent proposals (and their action) might be included in a transaction to ensure that they are treated atomically.
func (*Tx) SignatureHeader ¶
func (tx *Tx) SignatureHeader() (*common.SignatureHeader, error)
SignatureHeader returns pointer to common.SignatureHeader that contains nonce and creator (msp.SerializedIdentity).
func (*Tx) TlsCertHash ¶
TlsCertHash returns hash of the client's TLS certificate (if mutual TLS is employed).
func (*Tx) ValidationCode ¶
ValidationCode returns validation code for transaction with specified number (txNumber int) in block (block *common.Block).
func (*Tx) ValidationStatus ¶
ValidationStatus returns string representation of validation code for transaction with specified number (txNumber int) in block (block *common.Block).
type TxValidationCode ¶
type TxValidationCode int32
const ( TxValidationCode_VALID TxValidationCode = 0 TxValidationCode_NIL_ENVELOPE TxValidationCode = 1 TxValidationCode_BAD_PAYLOAD TxValidationCode = 2 TxValidationCode_BAD_COMMON_HEADER TxValidationCode = 3 TxValidationCode_BAD_CREATOR_SIGNATURE TxValidationCode = 4 TxValidationCode_INVALID_ENDORSER_TRANSACTION TxValidationCode = 5 TxValidationCode_INVALID_CONFIG_TRANSACTION TxValidationCode = 6 TxValidationCode_UNSUPPORTED_TX_PAYLOAD TxValidationCode = 7 TxValidationCode_BAD_PROPOSAL_TXID TxValidationCode = 8 TxValidationCode_DUPLICATE_TXID TxValidationCode = 9 TxValidationCode_ENDORSEMENT_POLICY_FAILURE TxValidationCode = 10 TxValidationCode_MVCC_READ_CONFLICT TxValidationCode = 11 TxValidationCode_PHANTOM_READ_CONFLICT TxValidationCode = 12 TxValidationCode_UNKNOWN_TX_TYPE TxValidationCode = 13 TxValidationCode_TARGET_CHAIN_NOT_FOUND TxValidationCode = 14 TxValidationCode_MARSHAL_TX_ERROR TxValidationCode = 15 TxValidationCode_NIL_TXACTION TxValidationCode = 16 TxValidationCode_EXPIRED_CHAINCODE TxValidationCode = 17 TxValidationCode_CHAINCODE_VERSION_CONFLICT TxValidationCode = 18 TxValidationCode_BAD_HEADER_EXTENSION TxValidationCode = 19 TxValidationCode_BAD_CHANNEL_HEADER TxValidationCode = 20 TxValidationCode_BAD_RESPONSE_PAYLOAD TxValidationCode = 21 TxValidationCode_BAD_RWSET TxValidationCode = 22 TxValidationCode_ILLEGAL_WRITESET TxValidationCode = 23 TxValidationCode_INVALID_WRITESET TxValidationCode = 24 TxValidationCode_INVALID_CHAINCODE TxValidationCode = 25 TxValidationCode_NOT_VALIDATED TxValidationCode = 254 TxValidationCode_INVALID_OTHER_REASON TxValidationCode = 255 )
type TxValidationFlags ¶
type TxValidationFlags []uint8