Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orderwatch: Remove null txHashes & fix uninstantiated map issue #280

Merged
merged 3 commits into from Jul 18, 2019
Merged
Changes from 2 commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -226,7 +226,8 @@ func (w *Watcher) startCleanupWorker() {
hashToOrderWithTxHashes := map[common.Hash]*OrderWithTxHashes{}
for _, order := range orders {
hashToOrderWithTxHashes[order.Hash] = &OrderWithTxHashes{
Order: order,
Order: order,
TxHashes: map[common.Hash]interface{}{},
}
}
w.generateOrderEventsIfChanged(hashToOrderWithTxHashes)
@@ -506,7 +507,7 @@ func (w *Watcher) generateOrderEventsIfChanged(hashToOrderWithTxHashes map[commo
orderEvents := []*zeroex.OrderEvent{}
for _, acceptedOrderInfo := range validationResults.Accepted {
orderWithTxHashes := hashToOrderWithTxHashes[acceptedOrderInfo.OrderHash]
txHashes := make([]common.Hash, len(orderWithTxHashes.TxHashes))
txHashes := []common.Hash{}
for txHash := range orderWithTxHashes.TxHashes {
This conversation was marked as resolved by fabioberger

This comment has been minimized.

Copy link
@albrow

albrow Jul 18, 2019

Member

I'd still like to follow the convention of pre-allocating slice lengths when possible. What do you think of this solution?

txHashes := make([]common.Hash, len(orderWithTxHashes.TxHashes))
txHashIndex := 0
for txHash := range orderWithTxHashes.TxHashes {
    txHashes[txHashIndex] = txHash
    txHashIndex += 1
}

This comment has been minimized.

Copy link
@fabioberger

fabioberger Jul 18, 2019

Author Contributor

It's more verbose but I guess I'm fine with it.

txHashes = append(txHashes, txHash)
}
@@ -572,7 +573,7 @@ func (w *Watcher) generateOrderEventsIfChanged(hashToOrderWithTxHashes map[commo
if !ok {
logger.WithField("rejectedOrderStatus", rejectedOrderInfo.Status).Panic("No OrderEventKind corresponding to RejectedOrderStatus")
}
txHashes := make([]common.Hash, len(orderWithTxHashes.TxHashes))
txHashes := []common.Hash{}
for txHash := range orderWithTxHashes.TxHashes {
txHashes = append(txHashes, txHash)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.