(w http.ResponseWriter, r *http.Request)
| 62 | } |
| 63 | |
| 64 | func (api *ReceiveAPI) receive(w http.ResponseWriter, r *http.Request) { |
| 65 | decoder := json.NewDecoder(r.Body) |
| 66 | var txs JSONRPCRequest |
| 67 | err := decoder.Decode(&txs) |
| 68 | if err != nil { |
| 69 | api.logger.Error("could not read request body", "err", err) |
| 70 | } |
| 71 | api.logger.Info("processed receive", "txs", txs) |
| 72 | |
| 73 | for _, tx := range txs.Params { |
| 74 | api.logger.Info("tx received", "tx", tx.Tx) |
| 75 | |
| 76 | var txBytes types.Transaction |
| 77 | err := txBytes.UnmarshalBinary(*tx.Tx) |
| 78 | if err != nil { |
| 79 | api.logger.Error("could not decode tx into bytes", "err", err) |
| 80 | } |
| 81 | |
| 82 | err = api.client.SendTransaction(context.Background(), &txBytes) |
| 83 | if err != nil { |
| 84 | api.logger.Error("could not send tx to rpc", "err", err) |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | response := &ReceiveResponse{"2.0", 1} |
| 89 | err = jsonResponse(w, response) |
| 90 | if err != nil { |
| 91 | api.logger.Error("Error in receive endpoint", "err", err) |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | func run(logger logging.Logger, httpServer *http.Server) <-chan error { |
| 96 | errChan := make(chan error, 1) |
nothing calls this directly
no test coverage detected