Skip to content

Commit b18e0df

Browse files
committed
Merge remote-tracking branch 'zingolabs/dev' into dev_poc_tests
2 parents 8719fad + f599da8 commit b18e0df

File tree

25 files changed

+321
-200
lines changed

25 files changed

+321
-200
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: CI
22

33
on:
44
pull_request:
5+
types: [ready_for_review]
56
push:
67
branches: [stable, dev]
78
workflow_dispatch:

integration-tests/tests/integrations.rs

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,14 @@ mod slow {
747747
.await
748748
.unwrap();
749749

750-
for txid_known in recipient.wallet.transactions().read().await.current.keys() {
750+
for txid_known in recipient
751+
.wallet
752+
.transactions()
753+
.read()
754+
.await
755+
.transaction_records_by_id
756+
.keys()
757+
{
751758
dbg!(txid_known);
752759
}
753760

@@ -757,7 +764,7 @@ mod slow {
757764
.transactions()
758765
.read()
759766
.await
760-
.current
767+
.transaction_records_by_id
761768
.get(&txid)
762769
.unwrap()
763770
.orchard_notes
@@ -771,8 +778,7 @@ mod slow {
771778
.transaction_metadata_set
772779
.read()
773780
.await
774-
.witness_trees
775-
.as_ref()
781+
.witness_trees()
776782
.unwrap()
777783
.witness_tree_orchard
778784
.marked_positions()
@@ -790,7 +796,7 @@ mod slow {
790796
.transactions()
791797
.read()
792798
.await
793-
.current
799+
.transaction_records_by_id
794800
.get(&txid)
795801
.unwrap()
796802
.orchard_notes
@@ -804,8 +810,7 @@ mod slow {
804810
.transaction_metadata_set
805811
.read()
806812
.await
807-
.witness_trees
808-
.as_ref()
813+
.witness_trees()
809814
.unwrap()
810815
.witness_tree_orchard
811816
.marked_positions()
@@ -818,8 +823,7 @@ mod slow {
818823
.transaction_metadata_set
819824
.read()
820825
.await
821-
.witness_trees
822-
.as_ref()
826+
.witness_trees()
823827
.unwrap()
824828
.witness_tree_orchard
825829
);
@@ -833,7 +837,7 @@ mod slow {
833837
.transactions()
834838
.read()
835839
.await
836-
.current
840+
.transaction_records_by_id
837841
.get(&txid)
838842
.unwrap()
839843
.orchard_notes
@@ -847,8 +851,7 @@ mod slow {
847851
.transaction_metadata_set
848852
.read()
849853
.await
850-
.witness_trees
851-
.as_ref()
854+
.witness_trees()
852855
.unwrap()
853856
.witness_tree_orchard
854857
.marked_positions()
@@ -864,7 +867,7 @@ mod slow {
864867
.transactions()
865868
.read()
866869
.await
867-
.current
870+
.transaction_records_by_id
868871
.get(&txid)
869872
.unwrap()
870873
.orchard_notes
@@ -880,8 +883,7 @@ mod slow {
880883
.transaction_metadata_set
881884
.read()
882885
.await
883-
.witness_trees
884-
.as_ref()
886+
.witness_trees()
885887
.unwrap()
886888
.witness_tree_orchard
887889
);
@@ -891,8 +893,7 @@ mod slow {
891893
.transaction_metadata_set
892894
.read()
893895
.await
894-
.witness_trees
895-
.as_ref()
896+
.witness_trees()
896897
.unwrap()
897898
.witness_tree_orchard
898899
.marked_positions()
@@ -2121,8 +2122,7 @@ mod slow {
21212122
.transaction_metadata_set
21222123
.read()
21232124
.await
2124-
.witness_trees
2125-
.as_ref()
2125+
.witness_trees()
21262126
.unwrap()
21272127
.witness_tree_orchard
21282128
.max_leaf_position(0),
@@ -2132,8 +2132,7 @@ mod slow {
21322132
.transaction_metadata_set
21332133
.read()
21342134
.await
2135-
.witness_trees
2136-
.as_ref()
2135+
.witness_trees()
21372136
.unwrap()
21382137
.witness_tree_orchard
21392138
.max_leaf_position(0)
@@ -2470,8 +2469,7 @@ mod slow {
24702469
.transaction_metadata_set
24712470
.read()
24722471
.await
2473-
.witness_trees
2474-
.as_ref()
2472+
.witness_trees()
24752473
.unwrap()
24762474
.witness_tree_orchard
24772475
);
@@ -2588,7 +2586,7 @@ mod slow {
25882586
.transaction_metadata_set
25892587
.read()
25902588
.await;
2591-
let wallet_trees = read_lock.witness_trees.as_ref().unwrap();
2589+
let wallet_trees = read_lock.witness_trees().unwrap();
25922590
let last_leaf = wallet_trees
25932591
.witness_tree_orchard
25942592
.max_leaf_position(0)
@@ -3293,8 +3291,7 @@ mod slow {
32933291
.transaction_metadata_set
32943292
.read()
32953293
.await
3296-
.witness_trees
3297-
.as_ref()
3294+
.witness_trees()
32983295
.unwrap()
32993296
.witness_tree_orchard
33003297
.witness_at_checkpoint_depth(
@@ -3304,7 +3301,7 @@ mod slow {
33043301
.transaction_metadata_set
33053302
.read()
33063303
.await
3307-
.current
3304+
.transaction_records_by_id
33083305
.get(requested_txid)
33093306
.unwrap()
33103307
.orchard_notes
@@ -3333,8 +3330,7 @@ mod slow {
33333330
.transaction_metadata_set
33343331
.read()
33353332
.await
3336-
.witness_trees
3337-
.as_ref()
3333+
.witness_trees()
33383334
.unwrap()
33393335
.witness_tree_orchard
33403336
.witness_at_checkpoint_depth(
@@ -3344,7 +3340,7 @@ mod slow {
33443340
.transaction_metadata_set
33453341
.read()
33463342
.await
3347-
.current
3343+
.transaction_records_by_id
33483344
.get(requested_txid)
33493345
.unwrap()
33503346
.orchard_notes
@@ -3449,7 +3445,7 @@ mod slow {
34493445
.transaction_metadata_set
34503446
.read()
34513447
.await
3452-
.current
3448+
.transaction_records_by_id
34533449
);
34543450

34553451
assert_eq!(bala_sim, bala_syn);

zingolib/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- LightClient pub fn get_wallet_dir_location
2020
- `wallet::keys`:
2121
- `is_transparent_address`
22+
- pub struct crate::wallet::notes::NoteRecordIdentifier
2223

2324
### Changed
2425

2526
- load_client_config fn moves from zingolib to zingoconfig
2627
- `wallet::keys`:
2728
- `is_shielded_address` takes a `&ChainType` instead of a `&ZingoConfig`
29+
- zingolib/src/wallet/transaction_record_map.rs -> zingolib/src/wallet/transaction_records_by_id.rs
30+
- TransactionRecordMap -> TransactionRecordsById
2831

2932
### Removed
3033

zingolib/src/blaze/update_notes.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::error::ZingoLibResult;
12
use crate::wallet::MemoDownloadOption;
23
use crate::wallet::{
34
data::PoolNullifier, transactions::TxMapAndMaybeTrees, utils::txid_from_slice,
@@ -88,7 +89,8 @@ impl UpdateNotes {
8889

8990
let wallet_transactions = self.transaction_metadata_set.clone();
9091
let h1 = tokio::spawn(async move {
91-
let mut workers = FuturesUnordered::new();
92+
let mut workers: FuturesUnordered<JoinHandle<ZingoLibResult<()>>> =
93+
FuturesUnordered::new();
9294

9395
// Receive Txns that are sent to the wallet. We need to update the notes for this.
9496
while let Some((
@@ -132,14 +134,14 @@ impl UpdateNotes {
132134

133135
// Record the future transaction, the one that has spent the nullifiers received in this transaction in the wallet
134136
let status = ConfirmationStatus::Confirmed(spent_at_height);
135-
let _ = wallet_transactions_write_unlocked.found_spent_nullifier(
137+
wallet_transactions_write_unlocked.found_spent_nullifier(
136138
transaction_id_spent_in,
137139
status,
138140
ts,
139141
maybe_spend_nullifier,
140142
transaction_id_spent_from,
141143
output_index,
142-
);
144+
)?;
143145

144146
drop(wallet_transactions_write_unlocked);
145147

@@ -156,21 +158,23 @@ impl UpdateNotes {
156158
.send((transaction_id_spent_from, at_height))
157159
.unwrap();
158160
}
161+
Ok(())
159162
}));
160163
}
161164

162165
// Wait for all the workers
163166
while let Some(r) = workers.next().await {
164-
r.unwrap();
167+
r.unwrap()?;
165168
}
166169

167170
//info!("Finished Note Update processing");
171+
Ok(())
168172
});
169173

170174
let h = tokio::spawn(async move {
171175
let (r0, r1) = join!(h0, h1);
172176
r0.map_err(|e| format!("{}", e))??;
173-
r1.map_err(|e| format!("{}", e))
177+
r1.map_err(|e| format!("{}", e))?
174178
});
175179

176180
(h, blocks_done_transmitter, transmitter)

zingolib/src/lightclient/deprecated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl LightClient {
115115
.transaction_context.transaction_metadata_set
116116
.read()
117117
.await
118-
.current
118+
.transaction_records_by_id
119119
.iter()
120120
.flat_map(|(txid, wallet_transaction)| {
121121
let mut consumer_notes_by_tx: Vec<JsonValue> = vec![];

zingolib/src/lightclient/describe.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl LightClient {
9696
.transactions()
9797
.read()
9898
.await
99-
.current
99+
.transaction_records_by_id
100100
.iter()
101101
.for_each(|(_, tx)| {
102102
let mature = tx
@@ -240,7 +240,7 @@ impl LightClient {
240240
.transaction_metadata_set
241241
.read()
242242
.await
243-
.current
243+
.transaction_records_by_id
244244
.iter()
245245
{
246246
LightClient::tx_summary_matcher(&mut summaries, *txid, transaction_md);
@@ -482,7 +482,7 @@ impl LightClient {
482482
let mut pending_sapling_notes: Vec<JsonValue> = vec![];
483483
let mut spent_sapling_notes: Vec<JsonValue> = vec![];
484484
// Collect Sapling notes
485-
self.wallet.transaction_context.transaction_metadata_set.read().await.current.iter()
485+
self.wallet.transaction_context.transaction_metadata_set.read().await.transaction_records_by_id.iter()
486486
.flat_map( |(transaction_id, transaction_metadata)| {
487487
transaction_metadata.sapling_notes.iter().filter_map(move |note_metadata|
488488
if !all_notes && note_metadata.spent.is_some() {
@@ -525,7 +525,7 @@ impl LightClient {
525525
let mut unspent_orchard_notes: Vec<JsonValue> = vec![];
526526
let mut pending_orchard_notes: Vec<JsonValue> = vec![];
527527
let mut spent_orchard_notes: Vec<JsonValue> = vec![];
528-
self.wallet.transaction_context.transaction_metadata_set.read().await.current.iter()
528+
self.wallet.transaction_context.transaction_metadata_set.read().await.transaction_records_by_id.iter()
529529
.flat_map( |(transaction_id, transaction_metadata)| {
530530
transaction_metadata.orchard_notes.iter().filter_map(move |orch_note_metadata|
531531
if !all_notes && orch_note_metadata.is_spent() {
@@ -568,7 +568,7 @@ impl LightClient {
568568
let mut pending_transparent_notes: Vec<JsonValue> = vec![];
569569
let mut spent_transparent_notes: Vec<JsonValue> = vec![];
570570

571-
self.wallet.transaction_context.transaction_metadata_set.read().await.current.iter()
571+
self.wallet.transaction_context.transaction_metadata_set.read().await.transaction_records_by_id.iter()
572572
.flat_map( |(transaction_id, wtx)| {
573573
wtx.transparent_notes.iter().filter_map(move |utxo|
574574
if !all_notes && utxo.is_spent() {

0 commit comments

Comments
 (0)