Skip to content

Commit 98f00b6

Browse files
committed
Update example
1 parent 3fb69e9 commit 98f00b6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pyth-sdk-solana/examples/get_accounts.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ fn main() {
5151

5252
// iget and print each Product in Mapping directory
5353
let mut i = 0;
54-
for prod_akey in &map_acct.products {
55-
let prod_pkey = Pubkey::new(&prod_akey.val);
54+
for prod_pkey in &map_acct.products {
5655
let prod_data = clnt.get_account_data(&prod_pkey).unwrap();
5756
let prod_acct = load_product_account(&prod_data).unwrap();
5857

@@ -65,8 +64,8 @@ fn main() {
6564
}
6665

6766
// print all Prices that correspond to this Product
68-
if prod_acct.px_acc.is_valid() {
69-
let mut px_pkey = Pubkey::new(&prod_acct.px_acc.val);
67+
if prod_acct.px_acc != Pubkey::default() {
68+
let mut px_pkey = prod_acct.px_acc;
7069
loop {
7170
let price_data = clnt.get_account_data(&px_pkey).unwrap();
7271
let price_account = load_price_account(&price_data).unwrap();
@@ -120,8 +119,8 @@ fn main() {
120119
}
121120

122121
// go to next price account in list
123-
if price_account.next.is_valid() {
124-
px_pkey = Pubkey::new(&price_account.next.val);
122+
if price_account.next != Pubkey::default() {
123+
px_pkey = price_account.next;
125124
} else {
126125
break;
127126
}
@@ -135,9 +134,9 @@ fn main() {
135134
}
136135

137136
// go to next Mapping account in list
138-
if !map_acct.next.is_valid() {
137+
if map_acct.next == Pubkey::default() {
139138
break;
140139
}
141-
akey = Pubkey::new(&map_acct.next.val);
140+
akey = map_acct.next;
142141
}
143142
}

0 commit comments

Comments
 (0)