Documentation
¶
Index ¶
- Constants
- func ExtractLeaderBlock(data []byte) (*common.Block, error)
- func HeaderBytes(b *common.BlockHeader) []byte
- func HeaderHash(b *common.BlockHeader) []byte
- type ApplicationValues
- type Blocklator
- func (bl *Blocklator) GetBlockHash() string
- func (bl *Blocklator) GetBlockNum() uint64
- func (bl *Blocklator) GetBlockPrehash() string
- func (bl *Blocklator) GetChannel() (string, error)
- func (bl *Blocklator) GetCommitHash() (string, error)
- func (bl *Blocklator) GetConfig() *common.Config
- func (bl *Blocklator) GetMetaDataLastConfig() (uint64, error)
- func (bl *Blocklator) GetMetaDataTransFilter() ([]bool, error)
- func (bl *Blocklator) GetMetaDataTransValidationCode() ([]peer.TxValidationCode, error)
- func (bl *Blocklator) GetSummary() (*Summary, error)
- func (bl *Blocklator) GetTransactions() []*common.Envelope
- func (bl *Blocklator) ToDesc() (*Desc, error)
- type Cert
- type CollHashedRwSet
- type ConfigDesc
- type ConfigValues
- type Configlator
- func (c *Configlator) GetApplicationOrgs() []*GroupOrg
- func (c *Configlator) GetApplicationValues() *ApplicationValues
- func (c *Configlator) GetConsensusInfo() *ConsensusInfo
- func (c *Configlator) GetConsortiumOrgs() map[string][]*GroupOrg
- func (c *Configlator) GetOrdererOrgs() []*GroupOrg
- func (c *Configlator) GetValues() *ConfigValues
- func (c *Configlator) ToDesc() *ConfigDesc
- type ConsensusInfo
- type Desc
- type Envelope
- type GroupOrg
- type Ledgerlator
- type NsRwSet
- type SignInfo
- type Summary
- type TranDesc
- type Translator
- type TxRwSet
Constants ¶
const ( FABRIC int32 = iota // MSP is of FABRIC type IDEMIX // MSP is of IDEMIX type OTHER // MSP is of OTHER TYPE // ConsortiumKey is the key for the ConfigValue of a // Consortium. ConsortiumKey = "Consortium" // HashingAlgorithmKey is the key for the ConfigValue of a // HashingAlgorithm. HashingAlgorithmKey = "HashingAlgorithm" // BlockDataHashingStructureKey is the key for the ConfigValue // of a BlockDataHashingStructure. BlockDataHashingStructureKey = "BlockDataHashingStructure" // OrdererAddressesKey is the key for the ConfigValue, OrdererAddresses. OrdererAddressesKey = "OrdererAddresses" // CapabilitiesKey is the key for the ConfigValue, capabilities. // CapabiltiesKey can be used at the channel, application, and orderer levels. CapabilitiesKey = "Capabilities" // EndpointsKey is the key for the ConfigValue, Endpoints in // a OrdererOrgGroup. EndpointsKey = "Endpoints" // MSPKey is the key for the ConfigValue, MSP. MSPKey = "MSP" // ConsensusTypeKey is the key for the ConfigValue, ConsensusType. ConsensusTypeKey = "ConsensusType" // BatchSizeKey is the key for the ConfigValue, BatchSize. BatchSizeKey = "BatchSize" // BatchTimeoutKey is the key for the ConfigValue, BatchSize. BatchTimeoutKey = "BatchTimeout" // KafkaBrokersKey is the key for the ConfigValue, KafkaBrokers. KafkaBrokersKey = "KafkaBrokers" // AdminsPolicyKey is the key used for the admin policy. AdminsPolicyKey = "Admins" // ReadersPolicyKey is the key used for the read policy. ReadersPolicyKey = "Readers" // WritersPolicyKey is the key used for the write policy. WritersPolicyKey = "Writers" // EndorsementPolicyKey is the key used for the endorsement policy. EndorsementPolicyKey = "Endorsement" // LifecycleEndorsementPolicyKey is the key used for the lifecycle endorsement // policy. LifecycleEndorsementPolicyKey = "LifecycleEndorsement" // BlockValidationPolicyKey is the key used for the block validation policy in // the OrdererOrgGroup. BlockValidationPolicyKey = "BlockValidation" // ChannelCreationPolicyKey is the key used in the consortium config to denote // the policy to be used in evaluating whether a channel creation request // is authorized. ChannelCreationPolicyKey = "ChannelCreationPolicy" // ChannelGroupKey is the group name for the channel config. ChannelGroupKey = "Channel" // ConsortiumsGroupKey is the group name for the consortiums config. ConsortiumsGroupKey = "Consortiums" // OrdererGroupKey is the group name for the orderer config. OrdererGroupKey = "Orderer" // ApplicationGroupKey is the group name for the Application config. ApplicationGroupKey = "Application" // ACLsKey is the name of the ACLs config. ACLsKey = "ACLs" // AnchorPeersKey is the key name for the AnchorPeers ConfigValue. AnchorPeersKey = "AnchorPeers" // ImplicitMetaPolicyType is the 'Type' string for implicit meta policies. ImplicitMetaPolicyType = "ImplicitMeta" // SignaturePolicyType is the 'Type' string for signature policies. SignaturePolicyType = "Signature" )
const
const ( BlockTypeTrans = iota BlockTypeConfig )
block type
Variables ¶
This section is empty.
Functions ¶
func ExtractLeaderBlock ¶
ExtractLeaderBlock extract block from ledger serialize block
Types ¶
type ApplicationValues ¶
type ApplicationValues struct {
ACLs map[string]string
Capabilities []string `json:"capabilities,omitempty" db:"capabilities"`
}
ApplicationValues values of application
type Blocklator ¶
type Blocklator struct {
// contains filtered or unexported fields
}
Blocklator for block translate
func NewBlocklator ¶
func NewBlocklator(raw []byte) (*Blocklator, error)
NewBlocklator return new Blocklator
func NewBlocklatorFromLedgerRaw ¶
func NewBlocklatorFromLedgerRaw(raw []byte) (*Blocklator, error)
NewBlocklatorFromLedgerRaw return new Blocklator from block data in ledger
func (*Blocklator) GetBlockHash ¶
func (bl *Blocklator) GetBlockHash() string
GetBlockHash return block hash
func (*Blocklator) GetBlockNum ¶
func (bl *Blocklator) GetBlockNum() uint64
GetBlockNum return block num
func (*Blocklator) GetBlockPrehash ¶
func (bl *Blocklator) GetBlockPrehash() string
GetBlockPrehash return block previoous hash
func (*Blocklator) GetChannel ¶
func (bl *Blocklator) GetChannel() (string, error)
GetChannel return channel id
func (*Blocklator) GetCommitHash ¶
func (bl *Blocklator) GetCommitHash() (string, error)
GetCommitHash get commit hash of the block
func (*Blocklator) GetConfig ¶
func (bl *Blocklator) GetConfig() *common.Config
GetConfig get config from block
func (*Blocklator) GetMetaDataLastConfig ¶
func (bl *Blocklator) GetMetaDataLastConfig() (uint64, error)
GetMetaDataLastConfig get the last config block num
func (*Blocklator) GetMetaDataTransFilter ¶
func (bl *Blocklator) GetMetaDataTransFilter() ([]bool, error)
GetMetaDataTransFilter 获取交易有效性标志
func (*Blocklator) GetMetaDataTransValidationCode ¶
func (bl *Blocklator) GetMetaDataTransValidationCode() ([]peer.TxValidationCode, error)
GetMetaDataTransValidationCode 获取交易有效性标志
func (*Blocklator) GetSummary ¶
func (bl *Blocklator) GetSummary() (*Summary, error)
GetSummary get block summary info
func (*Blocklator) GetTransactions ¶
func (bl *Blocklator) GetTransactions() []*common.Envelope
GetTransactions get transction envelops from block
type Cert ¶
type Cert struct {
Pem string `json:"pem,omitempty" db:"pem"`
CN string `json:"cn,omitempty" db:"cn"`
OU string `json:"ou,omitempty" db:"ou"`
Org string `json:"org,omitempty" db:"org"`
}
Cert cert
type CollHashedRwSet ¶
type CollHashedRwSet struct {
CollectionName string `json:"collection_name,omitempty" db:"collection_name"`
HashedRwSet *kvrwset.HashedRWSet `json:"hashed_rw_set,omitempty" db:"hashed_rw_set"`
PvtRwSetHash []byte `json:"pvt_rw_set_hash,omitempty" db:"pvt_rw_set_hash"`
}
CollHashedRwSet encapsulates 'kvrwset.HashedRWSet' proto message for a specific collection
type ConfigDesc ¶
type ConfigDesc struct {
OrdererOrgs []*GroupOrg `json:"orderer_orgs" db:"orderer_orgs"`
ConsortiumOrgs map[string][]*GroupOrg `json:"consortium_orgs" db:"consortium_orgs"`
ApplicationOrgs []*GroupOrg `json:"application_orgs" db:"application_orgs"`
ApplicationValues *ApplicationValues `json:"application_values" `
Values *ConfigValues `json:"values" db:"values"`
Consensus *ConsensusInfo `json:"consensus" db:"consensus"`
}
ConfigDesc config description
type ConfigValues ¶
type ConfigValues struct {
Consortium string `json:"consortium,omitempty" db:"consortium"`
HashingAlgorithm string `json:"hashing_algorithm,omitempty" db:"hashing_algorithm"`
OrdererAddresses []string `json:"orderer_addresses,omitempty" db:"orderer_addresses"`
BlockDataHashingWidth int `json:"block_data_hashing_width,omitempty" db:"block_data_hashing_width"`
Capabilities []string `json:"capabilities,omitempty" db:"capabilities"`
}
ConfigValues config values
type Configlator ¶
type Configlator struct {
// contains filtered or unexported fields
}
Configlator 配置信息解析
func NewConfiglator ¶
func NewConfiglator(config *common.Config) *Configlator
NewConfiglator 返回一个 Configlator
func (*Configlator) GetApplicationOrgs ¶
func (c *Configlator) GetApplicationOrgs() []*GroupOrg
GetApplicationOrgs 解析配置块中的应用组织
func (*Configlator) GetApplicationValues ¶
func (c *Configlator) GetApplicationValues() *ApplicationValues
GetApplicationValues 解析 Application 节中的 Values 信息
func (*Configlator) GetConsensusInfo ¶
func (c *Configlator) GetConsensusInfo() *ConsensusInfo
GetConsensusInfo 解析配置块中的共识相关配置信息
func (*Configlator) GetConsortiumOrgs ¶
func (c *Configlator) GetConsortiumOrgs() map[string][]*GroupOrg
GetConsortiumOrgs 解析系统配置块中的联盟组织
func (*Configlator) GetOrdererOrgs ¶
func (c *Configlator) GetOrdererOrgs() []*GroupOrg
GetOrdererOrgs 解析配置块中的 orderer 组织
func (*Configlator) GetValues ¶
func (c *Configlator) GetValues() *ConfigValues
GetValues 解析配置块中的基本参数信息
type ConsensusInfo ¶
type ConsensusInfo struct {
Type string `json:"type,omitempty" db:"type"`
RaftMetadata *etcdraft.ConfigMetadata `json:"raft_metadata,omitempty" db:"raft_metadata"`
MaxMessageCount uint32 `json:"max_message_count,omitempty" db:"max_message_count"`
AbsoluteMaxBytes uint32 `json:"absolute_max_bytes,omitempty" db:"absolute_max_bytes"`
PreferredMaxBytes uint32 `json:"preferred_max_bytes,omitempty" db:"preferred_max_bytes"`
BatchTimeOut string `json:"batch_time_out,omitempty" db:"batch_time_out"`
Borkers []string `json:"borkers,omitempty" db:"borkers"`
Capabilities []string `json:"capabilities,omitempty" db:"capabilities"`
}
ConsensusInfo 配置快中的共识信息
type Desc ¶
type Desc struct {
Summary
// BlockNum uint64 `json:"block_num" db:"block_num"`
// Hash string `json:"hash" db:"hash"`
// PreHash string `json:"pre_hash" db:"pre_hash"`
// Channel string `json:"channel" db:"channel"`
// Type int `json:"type" db:"type"` // 0: transaction 1: config
Config *ConfigDesc `json:"config" db:"config"`
Transactions []*TranDesc `json:"transactions" db:"transactions"`
}
Desc block description
type Envelope ¶
type Envelope struct {
Payload struct {
Header struct {
ChannelHeader *common.ChannelHeader
SignatureHeader *common.SignatureHeader
}
Transaction struct {
Header *common.SignatureHeader
ChaincodeAction struct {
Proposal struct {
Input *peer.ChaincodeSpec
}
Response struct {
ProposalHash []byte
ChaincodeAction *peer.ChaincodeAction
RWSet *TxRwSet
}
Endorses []*peer.Endorsement
}
}
}
Signature []byte
}
Envelope clean struct for envelope
type GroupOrg ¶
type GroupOrg struct {
Type int32 `json:"type" db:"type"`
TypeName string `json:"type_name" db:"type_name"`
Name string `json:"name" db:"name"`
RootCert string `json:"root_cert" db:"root_cert"`
TLSRootCert string `json:"tls_root_cert" db:"tls_root_cert"`
Admin string `json:"admin" db:"admin"`
RevocationList [][]byte `json:"revocation_list" db:"revocation_list"`
Endpoints []string `json:"endpoints" db:"endpoints"` // peer: anchorpeers orderer: ordereraddress
}
GroupOrg 配置块中的组织信息
type Ledgerlator ¶
type Ledgerlator struct {
// contains filtered or unexported fields
}
Ledgerlator translator for ledger data
func NewLedgerlator ¶
func NewLedgerlator(ledger *bufio.Reader) *Ledgerlator
NewLedgerlator return new ledgerlator from a Reader
func (Ledgerlator) RetriveBlocks ¶
func (l Ledgerlator) RetriveBlocks() ([][]byte, error)
RetriveBlocks retrive blocks from ledger
type NsRwSet ¶
type NsRwSet struct {
NameSpace string `json:"name_space,omitempty" db:"name_space"`
KvRwSet *kvrwset.KVRWSet `json:"kv_rw_set,omitempty" db:"kv_rw_set"`
CollHashedRwSets []*CollHashedRwSet `json:"coll_hashed_rw_sets,omitempty" db:"coll_hashed_rw_sets"`
}
NsRwSet encapsulates 'kvrwset.KVRWSet' proto message for a specific name space (chaincode)
type SignInfo ¶
type SignInfo struct {
MSPID string `json:"mspid,omitempty" db:"mspid"`
Cert *Cert `json:"cert,omitempty" db:"cert"`
Signature string `json:"signature,omitempty" db:"signature"`
}
SignInfo sign info
type Summary ¶
type Summary struct {
BlockNum uint64 `json:"block_num" db:"block_num"`
Hash string `json:"hash" db:"hash"`
PreHash string `json:"pre_hash" db:"pre_hash"`
Channel string `json:"channel" db:"channel"`
Type int `json:"type" db:"type"` // 0: transaction 1: config
TransCount int `json:"trans_count" db:"trans_count"`
CommitHash string `json:"commit_hash" db:"commit_hash"`
LastConfig uint64 `json:"last_config" db:"last_config"`
}
Summary block summary info
type TranDesc ¶
type TranDesc struct {
Channel string `json:"channel" db:"channel"`
TxID string `json:"tx_id" db:"tx_id"`
Time time.Time `json:"time" db:"time"`
Chaincode string `json:"chaincode" db:"chaincode"`
Func string `json:"func" db:"func"`
Args []string `json:"args" db:"args"`
Resp struct {
Status int32 `json:"status" db:"status"`
Message string `json:"message" db:"message"`
Data string `json:"data" db:"data"`
} `json:"resp" db:"resp"`
TxRwSet *TxRwSet `json:"tx_rw_set" `
Filter bool `json:"filter" db:"filter"`
ValidationCode string `json:"validation_code" db:"validation_code"`
Signer *SignInfo `json:"signer" db:"signer"`
Endorsers []*SignInfo `json:"endorsers," db:"endorsers"`
}
TranDesc transaction description
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator translator for transaction envelope
func NewTranslator ¶
func NewTranslator(env *common.Envelope) (*Translator, error)
NewTranslator return new Translator
func (*Translator) GetChannel ¶
func (t *Translator) GetChannel() string
GetChannel return channel id
func (*Translator) ToDesc ¶
func (t *Translator) ToDesc() *TranDesc
ToDesc transaction block to TranDesc
type TxRwSet ¶
type TxRwSet struct {
NsRwSets []*NsRwSet `json:"ns_rw_sets,omitempty" db:"ns_rw_sets"`
}
TxRwSet 交易读写集
func TxRwSetFromProtoMsg ¶
func TxRwSetFromProtoMsg(protoMsg *rwset.TxReadWriteSet) (*TxRwSet, error)
TxRwSetFromProtoMsg ...
func (*TxRwSet) FromProtoBytes ¶
FromProtoBytes 解析 TxRwSet