Skip to content

Commit

Permalink
Fixed: error if operation not found in mempool
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanSerikov committed Mar 2, 2021
1 parent 3360275 commit 0e2c021
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions cmd/api/handlers/search.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package handlers

import (
"fmt"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -122,14 +123,16 @@ func (ctx *Context) searchInMempool(q string) (models.Item, error) {
return models.Item{}, err
}

operation := ctx.getOperationFromMempool(q)
if operation := ctx.getOperationFromMempool(q); operation != nil {
return models.Item{
Type: models.DocOperations,
Value: operation.Hash,
Body: operation,
Highlights: map[string][]string{
"hash": {operation.Hash},
},
}, nil
}

return models.Item{
Type: models.DocOperations,
Value: operation.Hash,
Body: operation,
Highlights: map[string][]string{
"hash": {operation.Hash},
},
}, nil
return models.Item{}, fmt.Errorf("Operation not found")
}

0 comments on commit 0e2c021

Please sign in to comment.