|
@@ -1,7 +1,7 @@
|
|
|
//! Storage layer trait
|
|
|
use crate::{
|
|
|
amount::AmountCents, payment::PaymentTo, transaction::Type, AccountId, Amount, Asset,
|
|
|
- PaymentFrom, PaymentId, Transaction, TransactionId,
|
|
|
+ PaymentFrom, PaymentId, RevisionId, Transaction,
|
|
|
};
|
|
|
use serde::Serialize;
|
|
|
|
|
@@ -108,14 +108,14 @@ pub trait Batch<'a> {
|
|
|
/// is expected to put some hold on the transaction
|
|
|
async fn get_transaction_with_revision(
|
|
|
&mut self,
|
|
|
- transaction_id: &TransactionId,
|
|
|
- revision_id: &TransactionId,
|
|
|
+ transaction_id: &RevisionId,
|
|
|
+ revision_id: &RevisionId,
|
|
|
) -> Result<Transaction, Error>;
|
|
|
|
|
|
/// Flag the given payments as spent by the given transaction.
|
|
|
async fn spend_payments(
|
|
|
&mut self,
|
|
|
- transaction_id: &TransactionId,
|
|
|
+ transaction_id: &RevisionId,
|
|
|
spends: Vec<PaymentId>,
|
|
|
status: Status,
|
|
|
) -> Result<(), Error>;
|
|
@@ -123,7 +123,7 @@ pub trait Batch<'a> {
|
|
|
/// Create a new list of payments
|
|
|
async fn create_payments(
|
|
|
&mut self,
|
|
|
- transaction_id: &TransactionId,
|
|
|
+ transaction_id: &RevisionId,
|
|
|
recipients: &[PaymentTo],
|
|
|
status: Status,
|
|
|
) -> Result<(), Error>;
|
|
@@ -137,7 +137,7 @@ pub trait Batch<'a> {
|
|
|
/// from NotSpentable to Spendable can only be done by the parent transaction, and not other.
|
|
|
async fn update_transaction_payments(
|
|
|
&mut self,
|
|
|
- transaction_id: &TransactionId,
|
|
|
+ transaction_id: &RevisionId,
|
|
|
create_status: Status,
|
|
|
spend_status: Status,
|
|
|
) -> Result<(usize, usize), Error>;
|
|
@@ -145,7 +145,7 @@ pub trait Batch<'a> {
|
|
|
/// Returns the stats of a payment from the point of view of the on-going transaction
|
|
|
async fn get_payment_status(
|
|
|
&mut self,
|
|
|
- transaction_id: &TransactionId,
|
|
|
+ transaction_id: &RevisionId,
|
|
|
) -> Result<Option<Status>, Error>;
|
|
|
|
|
|
/// Stores a transaction
|
|
@@ -167,7 +167,7 @@ pub trait Batch<'a> {
|
|
|
/// layer.
|
|
|
async fn relate_account_to_transaction(
|
|
|
&mut self,
|
|
|
- transaction: &TransactionId,
|
|
|
+ transaction: &RevisionId,
|
|
|
account: &AccountId,
|
|
|
typ: Type,
|
|
|
) -> Result<(), Error>;
|
|
@@ -213,7 +213,7 @@ pub trait Storage {
|
|
|
) -> Result<Vec<PaymentFrom>, Error>;
|
|
|
|
|
|
/// Returns a transaction object by id
|
|
|
- async fn get_transaction(&self, transaction_id: &TransactionId) -> Result<Transaction, Error>;
|
|
|
+ async fn get_transaction(&self, transaction_id: &RevisionId) -> Result<Transaction, Error>;
|
|
|
|
|
|
/// Returns a list of a transactions for a given account (and optionally
|
|
|
/// filter by types). The list of transactions is expected to be sorted by
|
|
@@ -377,7 +377,7 @@ pub mod test {
|
|
|
.expect("valid amount");
|
|
|
|
|
|
for (i, status) in [Status::Locked, Status::Spendable].into_iter().enumerate() {
|
|
|
- let transaction_id: TransactionId = vec![i as u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction_id: RevisionId = vec![i as u8; 32].try_into().expect("valid tx id");
|
|
|
|
|
|
writer
|
|
|
.create_payments(
|
|
@@ -420,7 +420,7 @@ pub mod test {
|
|
|
.expect("valid amount");
|
|
|
|
|
|
for (i, status) in [Status::Failed, Status::Spent].into_iter().enumerate() {
|
|
|
- let transaction_id: TransactionId = vec![i as u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction_id: RevisionId = vec![i as u8; 32].try_into().expect("valid tx id");
|
|
|
|
|
|
writer
|
|
|
.create_payments(
|
|
@@ -467,8 +467,7 @@ pub mod test {
|
|
|
let usd: Asset = "USD/2".parse().expect("valid asset");
|
|
|
|
|
|
for (index, account) in accounts.iter().enumerate() {
|
|
|
- let transaction_id: TransactionId =
|
|
|
- vec![index as u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction_id: RevisionId = vec![index as u8; 32].try_into().expect("valid tx id");
|
|
|
let recipients = (0..target_inputs_per_account)
|
|
|
.map(|_| {
|
|
|
let amount = usd
|
|
@@ -593,7 +592,7 @@ pub mod test {
|
|
|
.from_human(&format!("{}", rng.gen_range(10.0..10000.0)))
|
|
|
.expect("valid amount");
|
|
|
|
|
|
- let transaction: TransactionId = vec![0u8; 32].try_into().expect("valid tx id");
|
|
|
+ let transaction: RevisionId = vec![0u8; 32].try_into().expect("valid tx id");
|
|
|
|
|
|
writer
|
|
|
.create_payments(
|