MCPcopy
hub / github.com/yeasy/blockchain_guide / GetHomes

Method GetHomes

11_app_dev/chaincode_example05.go:158–172  ·  view source on GitHub ↗
(ctx contractapi.TransactionContextInterface)

Source from the content-addressed store, hash-verified

156}
157
158func (s *SmartContract) GetHomes(ctx contractapi.TransactionContextInterface) ([]Home, error) {
159 count, err := currentID(ctx, homeCounterKey)
160 if err != nil {
161 return nil, err
162 }
163 homes := make([]Home, 0, count)
164 for id := 0; id < count; id++ {
165 home, err := readHomeByID(ctx, id)
166 if err != nil {
167 return nil, err
168 }
169 homes = append(homes, *home)
170 }
171 return homes, nil
172}
173
174func (s *SmartContract) GetTransactionByID(ctx contractapi.TransactionContextInterface, id string) (*EnergyTransaction, error) {
175 transactionID, err := strconv.Atoi(id)

Callers

nothing calls this directly

Calls 2

readHomeByIDFunction · 0.85
currentIDFunction · 0.70

Tested by

no test coverage detected