Skip to content

Commit

Permalink
dcr: Remove tx history wait.
Browse files Browse the repository at this point in the history
SyncStatus has a chance to hold the tipMtx so run it in a goroutine and
do not wait.
  • Loading branch information
JoeGruffins committed Oct 3, 2024
1 parent 8db3d84 commit cf6665c
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5936,7 +5936,7 @@ func isMixTx(tx *wire.MsgTx) (isMix bool, mixDenom int64) {
}

// idUnknownTx identifies the type and details of a transaction either made
// or recieved by the wallet.
// or received by the wallet.
func (dcr *ExchangeWallet) idUnknownTx(ctx context.Context, tx *ListTransactionsResult) (*asset.WalletTransaction, error) {
txHash, err := chainhash.NewHashFromStr(tx.TxID)
if err != nil {
Expand Down Expand Up @@ -6252,7 +6252,7 @@ func (dcr *ExchangeWallet) idUnknownTx(ctx context.Context, tx *ListTransactions
}

// addUnknownTransactionsToHistory checks for any transactions the wallet has
// made or recieved that are not part of the transaction history. It scans
// made or received that are not part of the transaction history. It scans
// from the last point to which it had previously scanned to the current tip.
func (dcr *ExchangeWallet) addUnknownTransactionsToHistory(tip uint64) {
txHistoryDB := dcr.txDB()
Expand Down Expand Up @@ -6320,7 +6320,7 @@ func (dcr *ExchangeWallet) addUnknownTransactionsToHistory(tip uint64) {
}

// syncTxHistory checks to see if there are any transactions which the wallet
// has made or recieved that are not part of the transaction history, then
// has made or received that are not part of the transaction history, then
// identifies and adds them. It also checks all the pending transactions to see
// if they have been mined into a block, and if so, updates the transaction
// history to reflect the block height.
Expand Down Expand Up @@ -6699,12 +6699,7 @@ func (dcr *ExchangeWallet) handleTipChange(ctx context.Context, newTipHash *chai
dcr.cycleMixer()
}

var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
dcr.syncTxHistory(ctx, uint64(newTipHeight))
}()
go dcr.syncTxHistory(ctx, uint64(newTipHeight))

// Search for contract redemption in new blocks if there
// are contracts pending redemption.
Expand Down Expand Up @@ -6759,13 +6754,7 @@ func (dcr *ExchangeWallet) handleTipChange(ctx context.Context, newTipHash *chai

// Run the redemption search from the startHeight determined above up
// till the current tip height.
wg.Add(1)
go func() {
defer wg.Done()
dcr.findRedemptionsInBlockRange(startHeight, newTipHeight, contractOutpoints)
}()

wg.Wait()
dcr.findRedemptionsInBlockRange(startHeight, newTipHeight, contractOutpoints)
}

func (dcr *ExchangeWallet) getBestBlock(ctx context.Context) (*block, error) {
Expand Down

0 comments on commit cf6665c

Please sign in to comment.