Browse Source
Merge pull request #456 from gre/eth-reorgs
really fix reorgs of Eth
master
Meriadec Pillet
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
5 deletions
-
src/bridge/EthereumJSBridge.js
|
|
@ -233,10 +233,10 @@ const EthereumBridge: WalletBridge<Transaction> = { |
|
|
|
if (block.height === blockHeight) { |
|
|
|
complete() |
|
|
|
} else { |
|
|
|
operations = operations.filter( |
|
|
|
// only keep operations that have enough confirmations
|
|
|
|
o => o.blockHeight && blockHeight - o.blockHeight > SAFE_REORG_THRESHOLD, |
|
|
|
) |
|
|
|
const filterConfirmedOperations = o => |
|
|
|
o.blockHeight && blockHeight - o.blockHeight > SAFE_REORG_THRESHOLD |
|
|
|
|
|
|
|
operations = operations.filter(filterConfirmedOperations) |
|
|
|
const blockHash = operations.length > 0 ? operations[0].blockHash : undefined |
|
|
|
const { txs } = await api.getTransactions(freshAddress, blockHash) |
|
|
|
if (unsubscribed) return |
|
|
@ -254,7 +254,7 @@ const EthereumBridge: WalletBridge<Transaction> = { |
|
|
|
const nonce = await api.getAccountNonce(freshAddress) |
|
|
|
if (unsubscribed) return |
|
|
|
next(a => { |
|
|
|
const currentOps = a.operations |
|
|
|
const currentOps = a.operations.filter(filterConfirmedOperations) |
|
|
|
const newOps = flatMap(txs, txToOps(a)) |
|
|
|
const operations = mergeOps(currentOps, newOps) |
|
|
|
const pendingOperations = a.pendingOperations.filter( |
|
|
|