-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Offence reporting returns a result #5082
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,14 +91,21 @@ pub trait Offence<Offender> { | |
| ) -> Perbill; | ||
| } | ||
|
|
||
| /// Errors that may happen on offence reports. | ||
| #[derive(PartialEq, sp_runtime::RuntimeDebug)] | ||
| pub enum OffenceError { | ||
| /// The report has already been sumbmitted. | ||
| DuplicateReport, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we at least want to have a variant that may takes a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will remind you on your next pr :P
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, added it here |
||
| } | ||
|
|
||
| /// A trait for decoupling offence reporters from the actual handling of offence reports. | ||
| pub trait ReportOffence<Reporter, Offender, O: Offence<Offender>> { | ||
| /// Report an `offence` and reward given `reporters`. | ||
| fn report_offence(reporters: Vec<Reporter>, offence: O); | ||
| fn report_offence(reporters: Vec<Reporter>, offence: O) -> Result<(), OffenceError>; | ||
| } | ||
|
|
||
| impl<Reporter, Offender, O: Offence<Offender>> ReportOffence<Reporter, Offender, O> for () { | ||
| fn report_offence(_reporters: Vec<Reporter>, _offence: O) {} | ||
| fn report_offence(_reporters: Vec<Reporter>, _offence: O) -> Result<(), OffenceError> { Ok(()) } | ||
| } | ||
|
|
||
| /// A trait to take action on an offence. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this, it will never be printed (in wasm). This functionality is only for offchain workers (it requires that the
RuntimeLoggeris intialized). Better to just usesp_runtime::print.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the rest of the code in this module uses this format so I decided to keep it the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code you are referring too is offchain, that is the reason it uses this format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done