@leofcoin/chain 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4869,9 +4869,16 @@ class State extends Contract {
4869
4869
  }
4870
4870
  // Fetch all missing transactions in parallel
4871
4871
  if (transactionsToFetch.length > 0) {
4872
- const fetchedTransactions = await Promise.all(transactionsToFetch.map((txHash) => globalThis.peernet.get(txHash, 'transaction')));
4873
- // Batch store all transactions
4874
- await Promise.all(transactionsToFetch.map((txHash, i) => globalThis.transactionStore.put(txHash, fetchedTransactions[i])));
4872
+ const fetchedResults = await Promise.allSettled(transactionsToFetch.map((txHash) => globalThis.peernet.get(txHash, 'transaction')));
4873
+ // Batch store all transactions that were successfully fetched
4874
+ for (let i = 0; i < fetchedResults.length; i++) {
4875
+ if (fetchedResults[i].status === 'fulfilled') {
4876
+ await globalThis.transactionStore.put(transactionsToFetch[i], fetchedResults[i].value);
4877
+ }
4878
+ else {
4879
+ debug$1(`failed to fetch transaction ${transactionsToFetch[i]}: ${fetchedResults[i].reason?.message || fetchedResults[i].reason}`);
4880
+ }
4881
+ }
4875
4882
  }
4876
4883
  // Remove from pool
4877
4884
  await Promise.all(transactionHashes.map(async (txHash) => {
package/exports/chain.js CHANGED
@@ -1010,9 +1010,16 @@ class State extends Contract {
1010
1010
  }
1011
1011
  // Fetch all missing transactions in parallel
1012
1012
  if (transactionsToFetch.length > 0) {
1013
- const fetchedTransactions = await Promise.all(transactionsToFetch.map((txHash) => globalThis.peernet.get(txHash, 'transaction')));
1014
- // Batch store all transactions
1015
- await Promise.all(transactionsToFetch.map((txHash, i) => globalThis.transactionStore.put(txHash, fetchedTransactions[i])));
1013
+ const fetchedResults = await Promise.allSettled(transactionsToFetch.map((txHash) => globalThis.peernet.get(txHash, 'transaction')));
1014
+ // Batch store all transactions that were successfully fetched
1015
+ for (let i = 0; i < fetchedResults.length; i++) {
1016
+ if (fetchedResults[i].status === 'fulfilled') {
1017
+ await globalThis.transactionStore.put(transactionsToFetch[i], fetchedResults[i].value);
1018
+ }
1019
+ else {
1020
+ debug$1(`failed to fetch transaction ${transactionsToFetch[i]}: ${fetchedResults[i].reason?.message || fetchedResults[i].reason}`);
1021
+ }
1022
+ }
1016
1023
  }
1017
1024
  // Remove from pool
1018
1025
  await Promise.all(transactionHashes.map(async (txHash) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {