當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Ledger.GetTempStateHashWithTxDeltaStateHashes方法代碼示例

本文整理匯總了Golang中github.com/hyperledger/fabric/core/ledger.Ledger.GetTempStateHashWithTxDeltaStateHashes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Ledger.GetTempStateHashWithTxDeltaStateHashes方法的具體用法?Golang Ledger.GetTempStateHashWithTxDeltaStateHashes怎麽用?Golang Ledger.GetTempStateHashWithTxDeltaStateHashes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/hyperledger/fabric/core/ledger.Ledger的用法示例。


在下文中一共展示了Ledger.GetTempStateHashWithTxDeltaStateHashes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

		It("creates, populates and finishes a transaction", func() {
			ledgerPtr.TxBegin("txUuid2")
			Expect(ledgerPtr.SetState("chaincode2", "key2", []byte("value2"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid2", true)
		})
		It("creates, but does not populate and finishes a transaction", func() {
			ledgerPtr.TxBegin("txUuid3")
			ledgerPtr.TxFinished("txUuid3", true)
		})
		It("creates, populates and finishes a transaction", func() {
			ledgerPtr.TxBegin("txUuid4")
			Expect(ledgerPtr.SetState("chaincode4", "key4", []byte("value4"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid4", false)
		})
		It("should retrieve the delta state hash array containing expected values", func() {
			_, txDeltaHashes, err := ledgerPtr.GetTempStateHashWithTxDeltaStateHashes()
			Expect(err).To(BeNil())
			Expect(util.ComputeCryptoHash(appendAll([]byte("chaincode1key1value1")))).To(Equal(txDeltaHashes["txUuid1"]))
			Expect(util.ComputeCryptoHash(appendAll([]byte("chaincode2key2value2")))).To(Equal(txDeltaHashes["txUuid2"]))
			Expect(txDeltaHashes["txUuid3"]).To(BeNil())
			_, ok := txDeltaHashes["txUuid4"]
			Expect(ok).To(Equal(false))
		})
		It("should commit the batch", func() {
			Expect(ledgerPtr.CommitTxBatch(1, []*protos.Transaction{}, nil, []byte("proof"))).To(BeNil())
		})
		It("creates, populates and finishes a transaction", func() {
			Expect(ledgerPtr.BeginTxBatch(2)).To(BeNil())
			ledgerPtr.TxBegin("txUuid1")
			Expect(ledgerPtr.SetState("chaincode1", "key1", []byte("value1"))).To(BeNil())
			ledgerPtr.TxFinished("txUuid1", true)
開發者ID:Colearo,項目名稱:fabric,代碼行數:31,代碼來源:ledger_test.go


注:本文中的github.com/hyperledger/fabric/core/ledger.Ledger.GetTempStateHashWithTxDeltaStateHashes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。