Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed Mar 30, 2022
1 parent 6d713d4 commit 01aeb59
Show file tree
Hide file tree
Showing 14 changed files with 266 additions and 455 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,9 @@ fn parse_make_it_rain(mut args: SplitWhitespace) -> Result<Vec<ParsedArgument>,
// txs per second
let txps = args.next().ok_or_else(|| ParseError::Empty("Txs/s".to_string()))?;
let txps = txps.parse::<f64>().map_err(ParseError::Float)?;
if txps > 25.0 {
println!("Maximum transaction rate is 25/sec");
return Err(ParseError::Invalid("Maximum transaction rate is 25/sec".to_string()));
if txps > 250.0 {
println!("Maximum transaction rate is 250/sec");
return Err(ParseError::Invalid("Maximum transaction rate is 250/sec".to_string()));
}
parsed_args.push(ParsedArgument::Float(txps));

Expand Down
1 change: 0 additions & 1 deletion base_layer/wallet/src/assets/asset_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ impl<T: OutputManagerBackend + 'static> AssetManager<T> {
let outputs = self
.output_database
.fetch_with_features(OutputFlags::ASSET_REGISTRATION)
.await
.map_err(|err| WalletError::OutputManagerError(err.into()))?;

debug!(
Expand Down
4 changes: 2 additions & 2 deletions base_layer/wallet/src/output_manager_service/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,14 @@ pub enum OutputManagerStorageError {
DieselConnectionError(#[from] diesel::ConnectionError),
#[error("Database migration error: `{0}`")]
DatabaseMigrationError(String),
#[error("Blocking task spawn error: `{0}`")]
BlockingTaskSpawnError(String),
#[error("Wallet db is already encrypted and cannot be encrypted until the previous encryption is removed")]
AlreadyEncrypted,
#[error("Byte array error: `{0}`")]
ByteArrayError(#[from] ByteArrayError),
#[error("Aead error: `{0}`")]
AeadError(String),
#[error("Tried to insert a script that already exists in the database")]
DuplicateScript,
#[error("Tari script error : {0}")]
ScriptError(#[from] ScriptError),
#[error("Binary not stored as valid hex:{0}")]
Expand Down
32 changes: 8 additions & 24 deletions base_layer/wallet/src/output_manager_service/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::{fmt, fmt::Formatter, sync::Arc};
use aes_gcm::Aes256Gcm;
use tari_common_types::{
transaction::TxId,
types::{BlockHash, HashOutput, PrivateKey, PublicKey},
types::{HashOutput, PrivateKey, PublicKey},
};
use tari_core::{
covenants::Covenant,
Expand All @@ -52,11 +52,8 @@ use tower::Service;

use crate::output_manager_service::{
error::OutputManagerError,
service::Balance,
storage::{
models::{KnownOneSidedPaymentScript, SpendingPriority},
OutputStatus,
},
service::{Balance, OutputStatusesByTxId},
storage::models::{KnownOneSidedPaymentScript, SpendingPriority},
};

/// API Request enum
Expand Down Expand Up @@ -247,21 +244,12 @@ pub enum OutputManagerResponse {
RewoundOutputs(Vec<RecoveredOutput>),
ScanOutputs(Vec<RecoveredOutput>),
AddKnownOneSidedPaymentScript,
CreateOutputWithFeatures {
output: Box<UnblindedOutputBuilder>,
},
CreatePayToSelfWithOutputs {
transaction: Box<Transaction>,
tx_id: TxId,
},
CreateOutputWithFeatures { output: Box<UnblindedOutputBuilder> },
CreatePayToSelfWithOutputs { transaction: Box<Transaction>, tx_id: TxId },
ReinstatedCancelledInboundTx,
CoinbaseAbandonedSet,
ClaimHtlcTransaction((TxId, MicroTari, MicroTari, Transaction)),
OutputStatusesByTxId {
statuses: Vec<OutputStatus>,
mined_height: Option<u64>,
block_hash: Option<BlockHash>,
},
OutputStatusesByTxId(OutputStatusesByTxId),
}

pub type OutputManagerEventSender = broadcast::Sender<Arc<OutputManagerEvent>>;
Expand Down Expand Up @@ -846,17 +834,13 @@ impl OutputManagerHandle {
pub async fn get_output_statuses_by_tx_id(
&mut self,
tx_id: TxId,
) -> Result<(Vec<OutputStatus>, Option<u64>, Option<BlockHash>), OutputManagerError> {
) -> Result<OutputStatusesByTxId, OutputManagerError> {
match self
.handle
.call(OutputManagerRequest::GetOutputStatusesByTxId(tx_id))
.await??
{
OutputManagerResponse::OutputStatusesByTxId {
statuses,
mined_height,
block_hash,
} => Ok((statuses, mined_height, block_hash)),
OutputManagerResponse::OutputStatusesByTxId(output_statuses_by_tx_id) => Ok(output_statuses_by_tx_id),
_ => Err(OutputManagerError::UnexpectedApiResponse),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ where
)?;
let tx_id = TxId::new_random();
let output_hex = db_output.commitment.to_hex();
if let Err(e) = self.db.add_unspent_output_with_tx_id(tx_id, db_output).await {
if let Err(e) = self.db.add_unspent_output_with_tx_id(tx_id, db_output) {
match e {
OutputManagerStorageError::DuplicateOutput => {
info!(
Expand Down
Loading

0 comments on commit 01aeb59

Please sign in to comment.