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

Refactoring: abstract storage layer and reindexer entity #430

Merged
merged 17 commits into from
Jan 8, 2021
Prev Previous commit
Next Next commit
Merged
aopoltorzhicky committed Jan 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 3748fd694d6fba177bd9d8c97d89af9d4a6aba9f
6 changes: 3 additions & 3 deletions cmd/api/handlers/account.go
Original file line number Diff line number Diff line change
@@ -52,10 +52,10 @@ func (ctx *Context) GetInfo(c *gin.Context) {
LastAction: stats.LastAction,
}

alias, err := ctx.ES.GetAlias(req.Network, req.Address)
alias, err := ctx.TZIP.GetAlias(req.Network, req.Address)
if err != nil {
if !elastic.IsRecordNotFound(err) {
handleError(c, err, 0)
if !ctx.Storage.IsRecordNotFound(err) {
ctx.handleError(c, err, 0)
return
}
} else {
6 changes: 3 additions & 3 deletions cmd/api/handlers/bigmap.go
Original file line number Diff line number Diff line change
@@ -78,10 +78,10 @@ func (ctx *Context) GetBigMap(c *gin.Context) {
}
}

alias, err := ctx.ES.GetAlias(req.Network, res.Address)
alias, err := ctx.TZIP.GetAlias(req.Network, res.Address)
if err != nil {
if !elastic.IsRecordNotFound(err) {
handleError(c, err, 0)
if !ctx.Storage.IsRecordNotFound(err) {
ctx.handleError(c, err, 0)
return
}
} else {
4 changes: 2 additions & 2 deletions cmd/api/handlers/events.go
Original file line number Diff line number Diff line change
@@ -114,9 +114,9 @@ func (ctx *Context) getMempoolEvents(subscriptions []database.Subscription) ([]m
continue
}

aliases, err := ctx.ES.GetAliasesMap(sub.Network)
aliases, err := ctx.TZIP.GetAliasesMap(sub.Network)
if err != nil {
if !elastic.IsRecordNotFound(err) {
if !ctx.Storage.IsRecordNotFound(err) {
return nil, err
}
aliases = make(map[string]string)
5 changes: 2 additions & 3 deletions cmd/api/handlers/mempool.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ import (
"github.com/baking-bad/bcdhub/internal/contractparser/consts"
"github.com/baking-bad/bcdhub/internal/contractparser/meta"
"github.com/baking-bad/bcdhub/internal/contractparser/newmiguel"
"github.com/baking-bad/bcdhub/internal/elastic"
"github.com/baking-bad/bcdhub/internal/helpers"
"github.com/baking-bad/bcdhub/internal/tzkt"
"github.com/gin-gonic/gin"
@@ -59,9 +58,9 @@ func (ctx *Context) prepareMempoolOperations(res []tzkt.MempoolOperation, addres
return ret, nil
}

aliases, err := ctx.ES.GetAliasesMap(network)
aliases, err := ctx.TZIP.GetAliasesMap(network)
if err != nil {
if !elastic.IsRecordNotFound(err) {
if !ctx.Storage.IsRecordNotFound(err) {
return nil, err
}
aliases = make(map[string]string)
4 changes: 2 additions & 2 deletions cmd/api/handlers/operations.go
Original file line number Diff line number Diff line change
@@ -430,9 +430,9 @@ func (ctx *Context) prepareMempoolOperation(item tzkt.MempoolOperation, network
RawMempool: string(item.Raw),
}

aliases, err := ctx.ES.GetAliasesMap(network)
aliases, err := ctx.TZIP.GetAliasesMap(network)
if err != nil {
if !elastic.IsRecordNotFound(err) {
if !ctx.Storage.IsRecordNotFound(err) {
return &op
}
} else {
4 changes: 3 additions & 1 deletion cmd/metrics/operations.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,9 @@ func getOperation(ids []string) error {
}

func parseOperation(h *metrics.Handler, operation operation.Operation) error {
h.SetOperationAliases(&operation)
if _, err := h.SetOperationAliases(&operation); err != nil {
return err
}
h.SetOperationStrings(&operation)

if helpers.IsContract(operation.Destination) || operation.IsOrigination() {
Loading