go谈话区块链教程源代码putils protos/utils东西包

  伯仲连区块链教程fabric1.0源代码领会putils(protos/utils东西包),2021年下星期,区块链行业正...

go谈话区块链教程源代码putils protos/utils东西包

  伯仲连区块链教程fabric1.0源代码领会putils(protos/utils东西包),2021年 下星期,区块链行业正渐渐褪去兴盛之初的烦躁、回归理性,外表上看关系人才需要与身价犹如正在回落区块链伯仲。但究竟上,恰是前期泡沫的渐退,让人们更多的关心点放在了区块链真实的本领之上。

  # fabric1.0源代码条记之putils(protos/utils东西包)

  ## 1、putils概括

币小哥资源讯息:protos/utils目次下区块链伯仲。

币小哥资源讯息:txutils.go、proputils.go、commonutils.go、blockutils.go区块链伯仲。

  ## 2、txutils

  ```go

  //transactionaction.payload => chaincodeactionpayload

  //chaincodeactionpayload.action.proposalresponsepayload => proposalresponsepayload

  //proposalresponsepayload.extension => chaincodeaction

  //从transactionaction中获得chaincodeactionpayload和chaincodeaction

  func getpayloads(txactions *peer.transactionaction) (*peer.chaincodeactionpayload, *peer.chaincodeaction, error)

  //[]byte反序列化为envelope

  func getenvelopefromblock(data []byte) (*common.envelope, error)

  func createsignedenvelope(txtype common.headertype, channelid string, signer crypto.localsigner, datamsg proto.message, msgversion int32, epoch uint64) (*common.envelope, error)

  //由proposal创造出面买卖envelope

  func createsignedtx(proposal *peer.proposal, signer msp.signingidentity, resps ...*peer.proposalresponse) (*common.envelope, error) {

  func createproposalresponse(hdrbytes []byte, payl []byte, response *peer.response, results []byte, events []byte, ccid *peer.chaincodeid, visibility []byte, signingendorser msp.signingidentity) (*peer.proposalresponse, error)

  func createproposalresponsefailure(hdrbytes []byte, payl []byte, response *peer.response, results []byte, events []byte, ccid *peer.chaincodeid, visibility []byte) (*peer.proposalresponse, error)

  //出面proposal

  func getsignedproposal(prop *peer.proposal, signer msp.signingidentity) (*peer.signedproposal, error)

  func getsignedevent(evt *peer.event, signer msp.signingidentity) (*peer.signedevent, error)

  func mocksignedendorserproposalorpanic(chainid string, cs *peer.chaincodespec, creator, signature []byte) (*peer.signedproposal, *peer.proposal)

  func mocksignedendorserproposal2orpanic(chainid string, cs *peer.chaincodespec, signer msp.signingidentity) (*peer.signedproposal, *peer.proposal)

  func getbytesproposalpayloadfortx(payload *peer.chaincodeproposalpayload, visibility []byte) ([]byte, error)

  func getproposalhash2(header *common.header, ccproppayl []byte) ([]byte, error)

  func getproposalhash1(header *common.header, ccproppayl []byte, visibility []byte) ([]byte, error)

  //代码在protos/utils/txutils.go

  ## 3、proputils

  ```go

  func getchaincodeinvocationspec(prop *peer.proposal) (*peer.chaincodeinvocationspec, error)

  func getchaincodeproposalcontext(prop *peer.proposal) ([]byte, map[string][]byte, error)

  //反序列化为common.header

  func getheader(bytes []byte) (*common.header, error)

  func getnonce(prop *peer.proposal) ([]byte, error)

  //header.channelheader反序列化为peer.chaincodeheaderextension

  func getchaincodeheaderextension(hdr *common.header) (*peer.chaincodeheaderextension, error)

  func getproposalresponse(prbytes []byte) (*peer.proposalresponse, error)

  func getchaincodedeploymentspec(code []byte) (*peer.chaincodedeploymentspec, error)

  func getchaincodeaction(cabytes []byte) (*peer.chaincodeaction, error)

  func getresponse(resbytes []byte) (*peer.response, error)

  func getchaincodeevents(ebytes []byte) (*peer.chaincodeevent, error)

  func getproposalresponsepayload(prpbytes []byte) (*peer.proposalresponsepayload, error)

  func getproposal(propbytes []byte) (*peer.proposal, error)

  //e.payload反序列化为payload

  func getpayload(e *common.envelope) (*common.payload, error)

  //[]byte反序列化为transaction

  func gettransaction(txbytes []byte) (*peer.transaction, error)

  func getchaincodeactionpayload(capbytes []byte) (*peer.chaincodeactionpayload, error)

  //反序列化为peer.chaincodeproposalpayload

  func getchaincodeproposalpayload(bytes []byte) (*peer.chaincodeproposalpayload, error)

  //反序列化为common.signatureheader

  func getsignatureheader(bytes []byte) (*common.signatureheader, error)

  func createchaincodeproposal(typ common.headertype, chainid string, cis *peer.chaincodeinvocationspec, creator []byte) (*peer.proposal, string, error)

  func createchaincodeproposalwithtransient(typ common.headertype, chainid string, cis *peer.chaincodeinvocationspec, creator []byte, transientmap map[string][]byte) (*peer.proposal, string, error)

  func createchaincodeproposalwithtxidnonceandtransient(txid string, typ common.headertype, chainid string, cis *peer.chaincodeinvocationspec, nonce, creator []byte, transientmap map[string][]byte) (*peer.proposal, string, error)

  func getbytesproposalresponsepayload(hash []byte, response *peer.response, result []byte, event []byte, ccid *peer.chaincodeid) ([]byte, error)

  func getbyteschaincodeproposalpayload(cpp *peer.chaincodeproposalpayload) ([]byte, error)

  func getbytesresponse(res *peer.response) ([]byte, error)

  func getbyteschaincodeevent(event *peer.chaincodeevent) ([]byte, error)

  func getbyteschaincodeactionpayload(cap *peer.chaincodeactionpayload) ([]byte, error)

  func getbytesproposalresponse(pr *peer.proposalresponse) ([]byte, error)

  func getbytesproposal(prop *peer.proposal) ([]byte, error)

  func getbytesheader(hdr *common.header) ([]byte, error)

  func getbytessignatureheader(hdr *common.signatureheader) ([]byte, error)

  func getbytestransaction(tx *peer.transaction) ([]byte, error)

  func getbytespayload(payl *common.payload) ([]byte, error)

  func getbytesenvelope(env *common.envelope) ([]byte, error)

  //从envbytes []byte中获得chaincodeaction

  func getactionfromenvelope(envbytes []byte) (*peer.chaincodeaction, error)

  func createproposalfromcis(typ common.headertype, chainid string, cis *peer.chaincodeinvocationspec, creator []byte) (*peer.proposal, string, error)

  func createinstallproposalfromcds(ccpack proto.message, creator []byte) (*peer.proposal, string, error)

  //按chaincodedeploymentspec创造deployproposal

  func createdeployproposalfromcds(chainid string, cds *peer.chaincodedeploymentspec, creator []byte, policy []byte, escc []byte, vscc []byte) (*peer.proposal, string, error)

  func createupgradeproposalfromcds(chainid string, cds *peer.chaincodedeploymentspec, creator []byte, policy []byte, escc []byte, vscc []byte) (*peer.proposal, string, error)

  func createproposalfromcds(chainid string, msg proto.message, creator []byte, policy []byte, escc []byte, vscc []byte, proptype string) (*peer.proposal, string, error)

  func computeproposaltxid(nonce, creator []byte) (string, error)

  func checkproposaltxid(txid string, nonce, creator []byte) error

  func computeproposalbinding(proposal *peer.proposal) ([]byte, error)

  func computeproposalbindinginternal(nonce, creator []byte, epoch uint64) ([]byte, error)

  //代码在protos/utils/proputils.go

  ## 4、commonutils

  ```go

  func marshalorpanic(pb proto.message) []byte

  func marshal(pb proto.message) ([]byte, error)

  func createnonceorpanic() []byte

  func createnonce() ([]byte, error)

  func unmarshalpayloadorpanic(encoded []byte) *cb.payload

  func unmarshalpayload(encoded []byte) (*cb.payload, error)

  func unmarshalenvelopeorpanic(encoded []byte) *cb.envelope

  func unmarshalenvelope(encoded []byte) (*cb.envelope, error)

  func unmarshalenvelopeoftype(envelope *cb.envelope, headertype cb.headertype, message proto.message) (*cb.channelheader, error)

  func extractenvelopeorpanic(block *cb.block, index int) *cb.envelope

  func extractenvelope(block *cb.block, index int) (*cb.envelope, error)

  func extractpayloadorpanic(envelope *cb.envelope) *cb.payload

  func extractpayload(envelope *cb.envelope) (*cb.payload, error)

  func makechannelheader(headertype cb.headertype, version int32, chainid string, epoch uint64) *cb.channelheader

  func makesignatureheader(serializedcreatorcertchain []byte, nonce []byte) *cb.signatureheader

  func settxid(channelheader *cb.channelheader, signatureheader *cb.signatureheader) error

  func makepayloadheader(ch *cb.channelheader, sh *cb.signatureheader) *cb.header

  func newsignatureheaderorpanic(signer crypto.localsigner) *cb.signatureheader

  func signorpanic(signer crypto.localsigner, msg []byte) []byte

  //[]byte反序列化为channelheader

  func unmarshalchannelheader(bytes []byte) (*cb.channelheader, error)

  func unmarshalchaincodeid(bytes []byte) (*pb.chaincodeid, error)

  func isconfigblock(block *cb.block) bool

  //代码在protos/utils/commonutils.go

  ## 5、blockutils

  ```go

  //[]byte变换为block区块链伯仲,从block中获得chainid(即channelid)

  func getchainidfromblockbytes(bytes []byte) (string, error)

  //从block中获得chainid(即channelid)

  func getchainidfromblock(block *cb.block) (string, error)

  //从block中按index获得metadata

  func getmetadatafromblock(block *cb.block, index cb.blockmetadataindex) (*cb.metadata, error)

  //从block中按index获得metadata区块链伯仲,即使波折则panic

  func getmetadatafromblockorpanic(block *cb.block, index cb.blockmetadataindex) *cb.metadata

  //从block.metadata.metadata中获得lastconfig

  func getlastconfigindexfromblock(block *cb.block) (uint64, error)

  //从block.metadata.metadata中获得lastconfig区块链伯仲,即使波折则panic

  func getlastconfigindexfromblockorpanic(block *cb.block) uint64

  //[]byte变换为block

  func getblockfromblockbytes(blockbytes []byte) (*cb.block, error)

  //正片block.metadata

  func copyblockmetadata(src *cb.block, dst *cb.block)

  //初始化block.metadata.metadata

  func initblockmetadata(block *cb.block)

  //代码在protos/utils/blockutils.go

本文转载自互联网,如有侵权,联系删除

相关推荐

《9/4币圈》那点事儿······

《9/4币圈》那点事儿······

  在2021年9月4日前2个月的功夫里,我即是农户口中的新韭菜,伴跟着财产效力,而后猖獗的加入到了区块链行业聚币网。固然是从二级商场发...

okex合约 2022.01.03 6 14

狗狗币的刊行量是几何?

暂时,狗狗币的价钱是0.02元一个,1千元不妨买5万个狗狗币官网。而达尔币暂时的价钱是0.0001元钱,即使想要让一千元形成二千元,就须要...

okex合约 2022.01.03 8 14

评论列表
  • 如果在农村,你跟警察说U警察都不知道是什么

    2021-11-28 17:18:22 回复该评论
  • 感觉合约的人,都在赚

    2021-11-28 17:18:22 回复该评论
  • 比特派确实算是做的还不错了,老牌大钱包了!

    2021-11-28 17:18:22 回复该评论
  • 兑换钱没了,然后钱转到别的地址了,我连矿工费都没有怎么能转到别处

    2021-11-30 02:51:17 回复该评论
  • 嫩韭菜别去学人家玩合约,没两下子你的保证金都亏完了

    2021-11-30 19:22:18 回复该评论