@@ -345,9 +345,6 @@ impl<P1, R1, N1>
345345pub trait ShieldedUtils :
346346 Sized + BorshDeserialize + BorshSerialize + Default + Clone
347347{
348- /// The type of the Tendermint client to make queries with
349- type C : crate :: ledger:: queries:: Client + std:: marker:: Sync ;
350-
351348 /// Get a MASP transaction prover
352349 fn local_tx_prover ( & self ) -> LocalTxProver ;
353350
@@ -631,9 +628,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
631628
632629 /// Fetch the current state of the multi-asset shielded pool into a
633630 /// ShieldedContext
634- pub async fn fetch (
631+ pub async fn fetch < C : Client + Sync > (
635632 & mut self ,
636- client : & U :: C ,
633+ client : & C ,
637634 sks : & [ ExtendedSpendingKey ] ,
638635 fvks : & [ ViewingKey ] ,
639636 ) {
@@ -699,8 +696,8 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
699696 /// transactions as a vector. More concretely, the HEAD_TX_KEY location
700697 /// stores the index of the last accepted transaction and each transaction
701698 /// is stored at a key derived from its index.
702- pub async fn fetch_shielded_transfers (
703- client : & U :: C ,
699+ pub async fn fetch_shielded_transfers < C : Client + Sync > (
700+ client : & C ,
704701 last_txidx : u64 ,
705702 ) -> BTreeMap < ( BlockHeight , TxIndex ) , ( Epoch , Transfer , Transaction ) > {
706703 // The address of the MASP account
@@ -710,7 +707,7 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
710707 . push ( & HEAD_TX_KEY . to_owned ( ) )
711708 . expect ( "Cannot obtain a storage key" ) ;
712709 // Query for the index of the last accepted transaction
713- let head_txidx = query_storage_value :: < U :: C , u64 > ( client, & head_tx_key)
710+ let head_txidx = query_storage_value :: < C , u64 > ( client, & head_tx_key)
714711 . await
715712 . unwrap_or ( 0 ) ;
716713 let mut shielded_txs = BTreeMap :: new ( ) ;
@@ -723,7 +720,7 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
723720 // Obtain the current transaction
724721 let ( tx_epoch, tx_height, tx_index, current_tx, current_stx) =
725722 query_storage_value :: <
726- U :: C ,
723+ C ,
727724 ( Epoch , BlockHeight , TxIndex , Transfer , Transaction ) ,
728725 > ( client, & current_tx_key)
729726 . await
@@ -744,10 +741,10 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
744741 /// associated to notes, memos, and diversifiers. And the set of notes that
745742 /// we have spent are updated. The witness map is maintained to make it
746743 /// easier to construct note merkle paths in other code. See
747- /// <https://zips.z.cash/protocol/protocol.pdf#scan>.
748- pub async fn scan_tx (
744+ /// <https://zips.z.cash/protocol/protocol.pdf#scan>
745+ pub async fn scan_tx < C : Client + Sync > (
749746 & mut self ,
750- client : & U :: C ,
747+ client : & C ,
751748 height : BlockHeight ,
752749 index : TxIndex ,
753750 epoch : Epoch ,
@@ -883,9 +880,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
883880 /// Compute the total unspent notes associated with the viewing key in the
884881 /// context. If the key is not in the context, then we do not know the
885882 /// balance and hence we return None.
886- pub async fn compute_shielded_balance (
883+ pub async fn compute_shielded_balance < C : Client + Sync > (
887884 & mut self ,
888- client : & U :: C ,
885+ client : & C ,
889886 vk : & ViewingKey ,
890887 ) -> Option < MaspAmount > {
891888 // Cannot query the balance of a key that's not in the map
@@ -913,9 +910,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
913910
914911 /// Query the ledger for the decoding of the given asset type and cache it
915912 /// if it is found.
916- pub async fn decode_asset_type (
913+ pub async fn decode_asset_type < C : Client + Sync > (
917914 & mut self ,
918- client : & U :: C ,
915+ client : & C ,
919916 asset_type : AssetType ,
920917 ) -> Option < ( Address , Option < Key > , MaspDenom , Epoch ) > {
921918 // Try to find the decoding in the cache
@@ -938,9 +935,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
938935
939936 /// Query the ledger for the conversion that is allowed for the given asset
940937 /// type and cache it.
941- async fn query_allowed_conversion < ' a > (
938+ async fn query_allowed_conversion < ' a , C : Client + Sync > (
942939 & ' a mut self ,
943- client : & U :: C ,
940+ client : & C ,
944941 asset_type : AssetType ,
945942 conversions : & ' a mut Conversions ,
946943 ) {
@@ -963,9 +960,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
963960 /// context and express that value in terms of the currently timestamped
964961 /// asset types. If the key is not in the context, then we do not know the
965962 /// balance and hence we return None.
966- pub async fn compute_exchanged_balance (
963+ pub async fn compute_exchanged_balance < C : Client + Sync > (
967964 & mut self ,
968- client : & U :: C ,
965+ client : & C ,
969966 vk : & ViewingKey ,
970967 target_epoch : Epoch ,
971968 ) -> Option < MaspAmount > {
@@ -993,9 +990,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
993990 /// the trace amount that could not be converted is moved from input to
994991 /// output.
995992 #[ allow( clippy:: too_many_arguments) ]
996- async fn apply_conversion (
993+ async fn apply_conversion < C : Client + Sync > (
997994 & mut self ,
998- client : & U :: C ,
995+ client : & C ,
999996 conv : AllowedConversion ,
1000997 asset_type : ( Epoch , TokenAddress , MaspDenom ) ,
1001998 value : i128 ,
@@ -1047,9 +1044,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
10471044 /// note of the conversions that were used. Note that this function does
10481045 /// not assume that allowed conversions from the ledger are expressed in
10491046 /// terms of the latest asset types.
1050- pub async fn compute_exchanged_amount (
1047+ pub async fn compute_exchanged_amount < C : Client + Sync > (
10511048 & mut self ,
1052- client : & U :: C ,
1049+ client : & C ,
10531050 mut input : MaspAmount ,
10541051 target_epoch : Epoch ,
10551052 mut conversions : Conversions ,
@@ -1156,9 +1153,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
11561153 /// of the specified asset type. Return the total value accumulated plus
11571154 /// notes and the corresponding diversifiers/merkle paths that were used to
11581155 /// achieve the total value.
1159- pub async fn collect_unspent_notes (
1156+ pub async fn collect_unspent_notes < C : Client + Sync > (
11601157 & mut self ,
1161- client : & U :: C ,
1158+ client : & C ,
11621159 vk : & ViewingKey ,
11631160 target : Amount ,
11641161 target_epoch : Epoch ,
@@ -1226,8 +1223,8 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
12261223 /// keys to try to decrypt the output notes. If no transaction is pinned at
12271224 /// the given payment address fails with
12281225 /// `PinnedBalanceError::NoTransactionPinned`.
1229- pub async fn compute_pinned_balance (
1230- client : & U :: C ,
1226+ pub async fn compute_pinned_balance < C : Client + Sync > (
1227+ client : & C ,
12311228 owner : PaymentAddress ,
12321229 viewing_key : & ViewingKey ,
12331230 ) -> Result < ( Amount , Epoch ) , PinnedBalanceError > {
@@ -1249,7 +1246,7 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
12491246 . push ( & ( PIN_KEY_PREFIX . to_owned ( ) + & owner. hash ( ) ) )
12501247 . expect ( "Cannot obtain a storage key" ) ;
12511248 // Obtain the transaction pointer at the key
1252- let txidx = rpc:: query_storage_value :: < U :: C , u64 > ( client, & pin_key)
1249+ let txidx = rpc:: query_storage_value :: < C , u64 > ( client, & pin_key)
12531250 . await
12541251 . ok_or ( PinnedBalanceError :: NoTransactionPinned ) ?;
12551252 // Construct the key for where the pinned transaction is stored
@@ -1259,7 +1256,7 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
12591256 // Obtain the pointed to transaction
12601257 let ( tx_epoch, _tx_height, _tx_index, _tx, shielded) =
12611258 rpc:: query_storage_value :: <
1262- U :: C ,
1259+ C ,
12631260 ( Epoch , BlockHeight , TxIndex , Transfer , Transaction ) ,
12641261 > ( client, & tx_key)
12651262 . await
@@ -1297,9 +1294,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
12971294 /// the epoch of the transaction or even before, so exchange all these
12981295 /// amounts to the epoch of the transaction in order to get the value that
12991296 /// would have been displayed in the epoch of the transaction.
1300- pub async fn compute_exchanged_pinned_balance (
1297+ pub async fn compute_exchanged_pinned_balance < C : Client + Sync > (
13011298 & mut self ,
1302- client : & U :: C ,
1299+ client : & C ,
13031300 owner : PaymentAddress ,
13041301 viewing_key : & ViewingKey ,
13051302 ) -> Result < ( MaspAmount , Epoch ) , PinnedBalanceError > {
@@ -1322,9 +1319,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
13221319 /// Convert an amount whose units are AssetTypes to one whose units are
13231320 /// Addresses that they decode to. All asset types not corresponding to
13241321 /// the given epoch are ignored.
1325- pub async fn decode_amount (
1322+ pub async fn decode_amount < C : Client + Sync > (
13261323 & mut self ,
1327- client : & U :: C ,
1324+ client : & C ,
13281325 amt : Amount ,
13291326 target_epoch : Epoch ,
13301327 ) -> HashMap < TokenAddress , token:: Change > {
@@ -1355,9 +1352,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
13551352
13561353 /// Convert an amount whose units are AssetTypes to one whose units are
13571354 /// Addresses that they decode to.
1358- pub async fn decode_all_amounts (
1355+ pub async fn decode_all_amounts < C : Client + Sync > (
13591356 & mut self ,
1360- client : & U :: C ,
1357+ client : & C ,
13611358 amt : Amount ,
13621359 ) -> MaspAmount {
13631360 let mut res: HashMap < ( Epoch , TokenAddress ) , Change > =
@@ -1394,9 +1391,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
13941391 /// understood that transparent account changes are effected only by the
13951392 /// amounts and signatures specified by the containing Transfer object.
13961393 #[ cfg( feature = "masp-tx-gen" ) ]
1397- pub async fn gen_shielded_transfer (
1394+ pub async fn gen_shielded_transfer < C : Client + Sync > (
13981395 & mut self ,
1399- client : & U :: C ,
1396+ client : & C ,
14001397 args : & args:: TxTransfer ,
14011398 shielded_gas : bool ,
14021399 ) -> Result <
@@ -1611,9 +1608,9 @@ impl<U: ShieldedUtils> ShieldedContext<U> {
16111608 /// transactions. If an owner is specified, then restrict the set to only
16121609 /// transactions crediting/debiting the given owner. If token is specified,
16131610 /// then restrict set to only transactions involving the given token.
1614- pub async fn query_tx_deltas (
1611+ pub async fn query_tx_deltas < C : Client + Sync > (
16151612 & mut self ,
1616- client : & U :: C ,
1613+ client : & C ,
16171614 query_owner : & Either < BalanceOwner , Vec < Address > > ,
16181615 query_token : & Option < Address > ,
16191616 viewing_keys : & HashMap < String , ExtendedViewingKey > ,
0 commit comments