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

Method GetTransactions

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

Source from the content-addressed store, hash-verified

184}
185
186func (s *SmartContract) GetTransactions(ctx contractapi.TransactionContextInterface) ([]EnergyTransaction, error) {
187 count, err := currentID(ctx, energyTxCounterKey)
188 if err != nil {
189 return nil, err
190 }
191 transactions := make([]EnergyTransaction, 0, count)
192 for id := 0; id < count; id++ {
193 transaction, err := s.GetTransactionByID(ctx, strconv.Itoa(id))
194 if err != nil {
195 return nil, err
196 }
197 transactions = append(transactions, *transaction)
198 }
199 return transactions, nil
200}
201
202func putHome(ctx contractapi.TransactionContextInterface, home *Home) error {
203 if err := putJSON(ctx, homeKey(home.Address), home); err != nil {

Callers

nothing calls this directly

Calls 2

GetTransactionByIDMethod · 0.95
currentIDFunction · 0.70

Tested by

no test coverage detected