github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/evidence/spec/03_messages.md (about) 1 <!-- 2 order: 3 3 --> 4 5 # Messages 6 7 ## MsgSubmitEvidence 8 9 Evidence is submitted through a `MsgSubmitEvidence` message: 10 11 ```go 12 type MsgSubmitEvidence struct { 13 Evidence Evidence 14 Submitter AccAddress 15 } 16 ``` 17 18 Note, the `Evidence` of a `MsgSubmitEvidence` message must have a corresponding 19 `Handler` registered with the `x/evidence` module's `Router` in order to be processed 20 and routed correctly. 21 22 Given the `Evidence` is registered with a corresponding `Handler`, it is processed 23 as follows: 24 25 ```go 26 func SubmitEvidence(ctx Context, evidence Evidence) error { 27 if _, ok := GetEvidence(ctx, evidence.Hash()); ok { 28 return ErrEvidenceExists(codespace, evidence.Hash().String()) 29 } 30 if !router.HasRoute(evidence.Route()) { 31 return ErrNoEvidenceHandlerExists(codespace, evidence.Route()) 32 } 33 34 handler := router.GetRoute(evidence.Route()) 35 if err := handler(ctx, evidence); err != nil { 36 return ErrInvalidEvidence(codespace, err.Error()) 37 } 38 39 SetEvidence(ctx, evidence) 40 return nil 41 } 42 ``` 43 44 First, there must not already exist valid submitted `Evidence` of the exact same 45 type. Secondly, the `Evidence` is routed to the `Handler` and executed. Finally, 46 if there is no error in handling the `Evidence`, it is persisted to state.