本文整理匯總了Golang中github.com/hyperledger/fabric/core/ledger.Ledger.GetStateRangeScanIterator方法的典型用法代碼示例。如果您正苦於以下問題:Golang Ledger.GetStateRangeScanIterator方法的具體用法?Golang Ledger.GetStateRangeScanIterator怎麽用?Golang Ledger.GetStateRangeScanIterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hyperledger/fabric/core/ledger.Ledger
的用法示例。
在下文中一共展示了Ledger.GetStateRangeScanIterator方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
actual := make(map[string][]byte)
for itr.Next() {
count++
k, v := itr.GetKeyValue()
actual[k] = v
}
Expect(count).To(Equal(len(expected)))
for k, v := range expected {
Expect(actual[k]).To(Equal(v))
}
}
///////// Test with an empty Ledger //////////
//////////////////////////////////////////////
It("does a bunch of stuff", func() {
itr, _ := ledgerPtr.GetStateRangeScanIterator("chaincodeID2", "key2", "key5", false)
expected := map[string][]byte{}
AssertIteratorContains(itr, expected)
itr.Close()
itr, _ = ledgerPtr.GetStateRangeScanIterator("chaincodeID2", "key2", "key5", true)
expected = map[string][]byte{}
AssertIteratorContains(itr, expected)
itr.Close()
// Commit initial data to ledger
ledgerPtr.BeginTxBatch(0)
ledgerPtr.TxBegin("txUuid1")
ledgerPtr.SetState("chaincodeID1", "key1", []byte("value1"))
ledgerPtr.SetState("chaincodeID2", "key1", []byte("value1"))