(c *gin.Context)
| 33 | } |
| 34 | |
| 35 | func proofUpload(c *gin.Context) { |
| 36 | req := ProofUploadRequest{} |
| 37 | err := c.BindJSON(&req) |
| 38 | if err != nil { |
| 39 | errorResp(c, 400, xerrors.Errorf("parse request failed: %w", err)) |
| 40 | return |
| 41 | } |
| 42 | pubkey, err := mycrypto.StringToPubkey(req.PublicKey) |
| 43 | if err != nil { |
| 44 | errorResp(c, 400, xerrors.Errorf("%w", err)) |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | previous_pc, err := model.ProofChainFindLatest(mycrypto.CompressedPubkeyHex(pubkey)) |
| 49 | if err != nil { |
| 50 | errorResp(c, 500, xerrors.Errorf("internal database error")) |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | validator, err := validateProof(req, previous_pc, pubkey) |
| 55 | if err != nil { |
| 56 | errorResp(c, 400, xerrors.Errorf("%w", err)) |
| 57 | return |
| 58 | } |
| 59 | |
| 60 | if err = applyUpload(&validator); err != nil { |
| 61 | errorResp(c, 400, xerrors.Errorf("%w", err)) |
| 62 | return |
| 63 | } |
| 64 | |
| 65 | if err = triggerArweave(model.MarshalPersona(pubkey)); err != nil { |
| 66 | // Do not errorResp here, since it is a tolerable error. |
| 67 | l.Warnf("error sending arweave upload message: %v", err) |
| 68 | } |
| 69 | |
| 70 | c.JSON(http.StatusCreated, gin.H{}) |
| 71 | } |
| 72 | |
| 73 | func validateProof(req ProofUploadRequest, prev *model.ProofChain, pubkey *ecdsa.PublicKey) (validator.Base, error) { |
| 74 | prev_signature := "" |
nothing calls this directly
no test coverage detected