Browse Source

really fix reorgs of Eth

master
Gaëtan Renaudeau 7 years ago
parent
commit
d4c79fefc6
  1. 10
      src/bridge/EthereumJSBridge.js

10
src/bridge/EthereumJSBridge.js

@ -233,10 +233,10 @@ const EthereumBridge: WalletBridge<Transaction> = {
if (block.height === blockHeight) { if (block.height === blockHeight) {
complete() complete()
} else { } else {
operations = operations.filter( const filterConfirmedOperations = o =>
// only keep operations that have enough confirmations o.blockHeight && blockHeight - o.blockHeight > SAFE_REORG_THRESHOLD
o => o.blockHeight && blockHeight - o.blockHeight > SAFE_REORG_THRESHOLD,
) operations = operations.filter(filterConfirmedOperations)
const blockHash = operations.length > 0 ? operations[0].blockHash : undefined const blockHash = operations.length > 0 ? operations[0].blockHash : undefined
const { txs } = await api.getTransactions(freshAddress, blockHash) const { txs } = await api.getTransactions(freshAddress, blockHash)
if (unsubscribed) return if (unsubscribed) return
@ -254,7 +254,7 @@ const EthereumBridge: WalletBridge<Transaction> = {
const nonce = await api.getAccountNonce(freshAddress) const nonce = await api.getAccountNonce(freshAddress)
if (unsubscribed) return if (unsubscribed) return
next(a => { next(a => {
const currentOps = a.operations const currentOps = a.operations.filter(filterConfirmedOperations)
const newOps = flatMap(txs, txToOps(a)) const newOps = flatMap(txs, txToOps(a))
const operations = mergeOps(currentOps, newOps) const operations = mergeOps(currentOps, newOps)
const pendingOperations = a.pendingOperations.filter( const pendingOperations = a.pendingOperations.filter(

Loading…
Cancel
Save