MCPcopy Index your code
hub / github.com/yeasy/blockchain_guide / GetBanks

Method GetBanks

11_app_dev/chaincode_example03.go:241–255  ·  view source on GitHub ↗
(ctx contractapi.TransactionContextInterface)

Source from the content-addressed store, hash-verified

239}
240
241func (s *SmartContract) GetBanks(ctx contractapi.TransactionContextInterface) ([]Bank, error) {
242 count, err := currentID(ctx, bankCounterKey)
243 if err != nil {
244 return nil, err
245 }
246 banks := make([]Bank, 0, count)
247 for id := 0; id < count; id++ {
248 bank, err := readBank(ctx, id)
249 if err != nil {
250 return nil, err
251 }
252 banks = append(banks, *bank)
253 }
254 return banks, nil
255}
256
257func (s *SmartContract) GetCompanies(ctx contractapi.TransactionContextInterface) ([]Company, error) {
258 count, err := currentID(ctx, companyCounterKey)

Callers

nothing calls this directly

Calls 2

readBankFunction · 0.85
currentIDFunction · 0.70

Tested by

no test coverage detected