本文整理匯總了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)