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

Method GetTransactions

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

Source from the content-addressed store, hash-verified

276}
277
278func (s *SmartContract) GetTransactions(ctx contractapi.TransactionContextInterface) ([]Transaction, error) {
279 count, err := currentID(ctx, transferCounterKey)
280 if err != nil {
281 return nil, err
282 }
283 transactions := make([]Transaction, 0, count)
284 for id := 0; id < count; id++ {
285 transaction, err := readTransaction(ctx, id)
286 if err != nil {
287 return nil, err
288 }
289 transactions = append(transactions, *transaction)
290 }
291 return transactions, nil
292}
293
294func parseIDAndAmount(id string, amount string) (int, int, error) {
295 parsedID, err := strconv.Atoi(id)

Callers

nothing calls this directly

Calls 2

readTransactionFunction · 0.85
currentIDFunction · 0.70

Tested by

no test coverage detected