MCPcopy Create free account
hub / github.com/cairoeth/preconfirmations / receive

Method receive

preconf-operator/receiverapi/receiverapi.go:64–93  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

62}
63
64func (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
95func run(logger logging.Logger, httpServer *http.Server) <-chan error {
96 errChan := make(chan error, 1)

Callers

nothing calls this directly

Calls 2

jsonResponseFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected