(ctx contractapi.TransactionContextInterface, fromType int, fromID int, toType int, toID int, amount int)
| 315 | } |
| 316 | |
| 317 | func recordTransaction(ctx contractapi.TransactionContextInterface, fromType int, fromID int, toType int, toID int, amount int) (*Transaction, error) { |
| 318 | id, err := nextID(ctx, transferCounterKey) |
| 319 | if err != nil { |
| 320 | return nil, err |
| 321 | } |
| 322 | timestamp, err := ctx.GetStub().GetTxTimestamp() |
| 323 | if err != nil { |
| 324 | return nil, fmt.Errorf("failed to read transaction timestamp: %w", err) |
| 325 | } |
| 326 | |
| 327 | transaction := &Transaction{ID: id, FromType: fromType, FromID: fromID, ToType: toType, ToID: toID, Time: timestamp.Seconds, Number: amount} |
| 328 | if err := putJSON(ctx, transactionKey(id), transaction); err != nil { |
| 329 | return nil, err |
| 330 | } |
| 331 | return transaction, nil |
| 332 | } |
| 333 | |
| 334 | func readCenterBank(ctx contractapi.TransactionContextInterface) (*CenterBank, error) { |
| 335 | var centerBank CenterBank |
no test coverage detected