This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from radixdlt/finish_early_strategy
- Loading branch information
Showing
11 changed files
with
240 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
mod signatures_collecting_continuation; | ||
mod signatures_collector; | ||
mod signatures_collector_dependencies; | ||
mod signatures_collector_preprocessor; | ||
mod signatures_collector_state; | ||
mod signing_finish_early_strategy; | ||
|
||
pub use signatures_collecting_continuation::*; | ||
pub use signatures_collector::*; | ||
pub use signatures_collector_preprocessor::*; | ||
pub use signing_finish_early_strategy::*; |
14 changes: 14 additions & 0 deletions
14
src/signing/collector/signatures_collecting_continuation.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/// Whether to continue collecting signatures or finish early. | ||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub enum SignaturesCollectingContinuation { | ||
/// It is meaningless to continue collecting signatures, either since either | ||
/// all transactions are valid, and the collector is configured to finish early | ||
/// in that case, or some transaction is invalid and the collector is configured | ||
/// finish early in that case. | ||
FinishEarly, | ||
|
||
/// We should continue collecting signatures, either since the collector is | ||
/// configured to not finish early, even though we can, or since we cannot | ||
/// finish early since not enough factor sources have been signed with. | ||
Continue, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::prelude::*; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub struct WhenAllTransactionsAreValid(pub SignaturesCollectingContinuation); | ||
|
||
impl Default for WhenAllTransactionsAreValid { | ||
fn default() -> Self { | ||
Self(SignaturesCollectingContinuation::FinishEarly) | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
pub struct WhenSomeTransactionIsInvalid(pub SignaturesCollectingContinuation); | ||
|
||
impl Default for WhenSomeTransactionIsInvalid { | ||
fn default() -> Self { | ||
Self(SignaturesCollectingContinuation::FinishEarly) | ||
} | ||
} | ||
|
||
/// Strategy to use for finishing early, i.e. stop collecting more signatures | ||
#[derive(Clone, Default, Copy, Debug, PartialEq, Eq)] | ||
pub struct SigningFinishEarlyStrategy { | ||
pub when_all_transactions_are_valid: WhenAllTransactionsAreValid, | ||
pub when_some_transaction_is_invalid: WhenSomeTransactionIsInvalid, | ||
} | ||
impl SigningFinishEarlyStrategy { | ||
pub fn new( | ||
when_all_transactions_are_valid: WhenAllTransactionsAreValid, | ||
when_some_transaction_is_invalid: WhenSomeTransactionIsInvalid, | ||
) -> Self { | ||
Self { | ||
when_all_transactions_are_valid, | ||
when_some_transaction_is_invalid, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.