client/rpc: fix panic in sendAcceptBatch

In this commit, we fix a panic in `sendAcceptBatch` due to the fact that
the method as is, creates a slice with enough _capacity_ but a zero
length. In this case, trying to access an index will result in a panic.
In this commit, we shift things over to use append instead of index into
the slice.
This commit is contained in:
Olaoluwa Osuntokun 2020-05-17 17:08:52 -07:00
parent 20a5085017
commit 50a9a3e447

View file

@ -1044,10 +1044,8 @@ func (s *rpcServer) sendAcceptBatch(batch *order.Batch) error {
// Prepare the list of nonces we accept by serializing them to a slice
// of byte slices.
nonces := make([][]byte, 0, len(batch.MatchedOrders))
idx := 0
for nonce := range batch.MatchedOrders {
nonces[idx] = nonce[:]
idx++
nonces = append(nonces, nonce[:])
}
// Send the message to the server.