-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update verify data payment logic
- Loading branch information
1 parent
7cbeb17
commit 849de7e
Showing
7 changed files
with
92 additions
and
271 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,4 @@ pub use client::Client; | |
|
||
#[cfg(feature = "extension-module")] | ||
mod python; | ||
mod utils; |
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,39 @@ | ||
use crate::client::payment::Receipt; | ||
use ant_evm::{PaymentQuote, ProofOfPayment, QuoteHash, TxHash}; | ||
use ant_networking::PayeeQuote; | ||
use std::collections::{BTreeMap, HashMap}; | ||
use xor_name::XorName; | ||
|
||
pub fn cost_map_to_quotes( | ||
cost_map: HashMap<XorName, PayeeQuote>, | ||
) -> HashMap<XorName, PaymentQuote> { | ||
cost_map.into_iter().map(|(k, (_, _, v))| (k, v)).collect() | ||
} | ||
|
||
pub fn receipt_from_cost_map_and_payments( | ||
cost_map: HashMap<XorName, PayeeQuote>, | ||
payments: &BTreeMap<QuoteHash, TxHash>, | ||
) -> Receipt { | ||
let quotes = cost_map_to_quotes(cost_map); | ||
receipt_from_quotes_and_payments("es, payments) | ||
} | ||
|
||
pub fn receipt_from_quotes_and_payments( | ||
quotes: &HashMap<XorName, PaymentQuote>, | ||
payments: &BTreeMap<QuoteHash, TxHash>, | ||
) -> Receipt { | ||
quotes | ||
.iter() | ||
.filter_map(|(xor_name, quote)| { | ||
payments.get("e.hash()).map(|tx_hash| { | ||
( | ||
*xor_name, | ||
ProofOfPayment { | ||
quote: quote.clone(), | ||
tx_hash: *tx_hash, | ||
}, | ||
) | ||
}) | ||
}) | ||
.collect() | ||
} |
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 was deleted.
Oops, something went wrong.
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.