本文整理匯總了Golang中github.com/hyperledger/fabric/core/ledger.Ledger.CopyState方法的典型用法代碼示例。如果您正苦於以下問題:Golang Ledger.CopyState方法的具體用法?Golang Ledger.CopyState怎麽用?Golang Ledger.CopyState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/core/ledger.Ledger
的用法示例。
在下文中一共展示了Ledger.CopyState方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
ledgerPtr := InitSpec()
It("creates, populates, finishes, commits and validates a batch", func() {
Expect(ledgerPtr.BeginTxBatch(0)).To(BeNil())
ledgerPtr.TxBegin("txUuid1")
ledgerPtr.SetStateMultipleKeys("chaincodeID", map[string][]byte{"key1": []byte("value1"), "key2": []byte("value2")})
ledgerPtr.TxFinished("txUuid1", true)
uuid := util.GenerateUUID()
tx, err := protos.NewTransaction(protos.ChaincodeID{Path: "testUrl"}, uuid, "anyfunction", []string{"param1, param2"})
Expect(err).To(BeNil())
err = ledgerPtr.CommitTxBatch(0, []*protos.Transaction{tx}, nil, []byte("proof"))
Expect(err).To(BeNil())
})
It("copies state without error and validates values are equal", func() {
Expect(ledgerPtr.BeginTxBatch(1)).To(BeNil())
ledgerPtr.TxBegin("txUuid1")
ledgerPtr.CopyState("chaincodeID", "chaincodeID2")
ledgerPtr.TxFinished("txUuid1", true)
uuid := util.GenerateUUID()
tx, err := protos.NewTransaction(protos.ChaincodeID{Path: "testUrl"}, uuid, "anyfunction", []string{"param1, param2"})
Expect(err).To(BeNil())
err = ledgerPtr.CommitTxBatch(1, []*protos.Transaction{tx}, nil, []byte("proof"))
Expect(err).To(BeNil())
values, err := ledgerPtr.GetStateMultipleKeys("chaincodeID2", []string{"key1", "key2"}, true)
Expect(err).To(BeNil())
Expect(values).To(Equal([][]byte{[]byte("value1"), []byte("value2")}))
})
})
Describe("Ledger EmptyArrayValue", func() {
ledgerPtr := InitSpec()
It("creates, populates, finishes, commits and validates a batch", func() {