Skip to content

Commit

Permalink
Fix: mempool URL (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Sep 5, 2022
1 parent 661561b commit 5c724a4
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.45.2
version: v1.49.0
args: --timeout=2m --go=1.18
test:
name: Tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.45.2
version: v1.49.0
args: --timeout=2m --go=1.18
test:
name: Tests
Expand Down
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ linters:
- govet
- prealloc
- unconvert
- deadcode
- varcheck
- unused
- errcheck
- ineffassign
- containedctx
Expand Down
7 changes: 2 additions & 5 deletions cmd/api/handlers/bigmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func GetBigMapKeys() gin.HandlerFunc {
return
}

var states []bigmapdiff.BigMapState
keys, err := ctx.BigMapDiffs.Keys(bigmapdiff.GetContext{
Ptr: &req.Ptr,
Size: pageReq.Size,
Expand All @@ -201,14 +200,13 @@ func GetBigMapKeys() gin.HandlerFunc {
if handleError(c, ctx.Storage, err, 0) {
return
}
states = keys

symLink, err := getCurrentSymLink(ctx.Blocks)
if handleError(c, ctx.Storage, err, 0) {
return
}

response, err := prepareBigMapKeys(ctx, states, symLink)
response, err := prepareBigMapKeys(ctx, keys, symLink)
if handleError(c, ctx.Storage, err, 0) {
return
}
Expand Down Expand Up @@ -511,11 +509,10 @@ func prepareKey(itemKey types.Bytes, bigMapType *ast.BigMap) (key *ast.MiguelNod
case int64:
keyString = fmt.Sprintf("%d", t)
default:
keyString = fmt.Sprintf("%v", t)
keyString, err = formatter.MichelineToMichelsonInline(string(itemKey))
}
}

keyString, err = formatter.MichelineToMichelsonInline(string(itemKey))
return
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/api/handlers/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package handlers
import (
stdJSON "encoding/json"
"io"
"io/ioutil"
"net/http"

"github.com/baking-bad/bcdhub/internal/bcd/ast"
Expand Down Expand Up @@ -85,7 +84,7 @@ func CodeFromMichelson() gin.HandlerFunc {
return func(c *gin.Context) {
ctx := c.MustGet("contexts").(config.Contexts)

body, err := ioutil.ReadAll(io.LimitReader(c.Request.Body, 1024*1024))
body, err := io.ReadAll(io.LimitReader(c.Request.Body, 1024*1024))
if handleError(c, ctx.Any().Storage, err, http.StatusBadRequest) {
return
}
Expand Down
10 changes: 0 additions & 10 deletions cmd/api/handlers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ func (req getByNetwork) NetworkID() types.Network {
return types.NewNetwork(req.Network)
}

type getTokensByVersion struct {
Network string `uri:"network" binding:"required,network" example:"mainnet"`
Version string `uri:"faversion" binding:"required,faversion" example:"fa2"`
}

// NetworkID -
func (req getTokensByVersion) NetworkID() types.Network {
return types.NewNetwork(req.Network)
}

type bigMapSearchRequest struct {
pageableRequest
MaxLevel *int64 `form:"max_level,omitempty" binding:"omitempty,gt_int64_ptr=MinLevel"`
Expand Down
32 changes: 0 additions & 32 deletions cmd/indexer/indexer/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package indexer

import (
"context"
"time"

"github.com/baking-bad/bcdhub/internal/models"
"github.com/baking-bad/bcdhub/internal/models/account"
"github.com/baking-bad/bcdhub/internal/models/types"
"github.com/baking-bad/bcdhub/internal/tzkt"
"github.com/go-pg/pg/v10"
)

Expand All @@ -32,32 +29,3 @@ func (initializer Initializer) Init(ctx context.Context) error {

return createStartIndices(initializer.db)
}

func (initializer *Initializer) getAliases(ctx context.Context) error {
if initializer.tzktURI == "" {
return nil
}

accounts, err := tzkt.NewTzKT(initializer.tzktURI, 10*time.Second).GetAliases()
if err != nil {
return err
}

return initializer.db.RunInTransaction(ctx, func(tx *pg.Tx) error {
for address, alias := range accounts {
acc := account.Account{
Address: address,
Type: types.NewAccountType(address),
Alias: alias,
}

if _, err := initializer.db.Model(&acc).
OnConflict("(address) DO NOTHING").
Insert(); err != nil {
return err
}
}

return nil
})
}
6 changes: 3 additions & 3 deletions configs/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ services:
mainnet:
mempool: https://mempool.dipdup.net/v1/graphql
ghostnet:
mempool: https://mempool.dipdup.net/v1/graphql
mempool: https://mempool.test.dipdup.net/v1/graphql
jakartanet:
mempool: https://mempool.dipdup.net/v1/graphql
mempool: https://mempool.test.dipdup.net/v1/graphql
kathmandunet:
mempool: https://mempool.dipdup.net/v1/graphql
mempool: https://mempool.test.dipdup.net/v1/graphql

storage:
pg:
Expand Down
6 changes: 3 additions & 3 deletions configs/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ services:
mainnet:
mempool: https://mempool.dipdup.net/v1/graphql
ghostnet:
mempool: https://mempool.dipdup.net/v1/graphql
mempool: https://mempool.test.dipdup.net/v1/graphql
jakartanet:
mempool: https://mempool.dipdup.net/v1/graphql
mempool: https://mempool.test.dipdup.net/v1/graphql
kathmandunet:
mempool: https://mempool.dipdup.net/v1/graphql
mempool: https://mempool.test.dipdup.net/v1/graphql

storage:
pg:
Expand Down
10 changes: 5 additions & 5 deletions internal/bcd/formatter/error/formatter_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package formattererror
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/tidwall/gjson"
Expand All @@ -29,18 +29,18 @@ func TestLocateContractError(t *testing.T) {
t.Run(c, func(t *testing.T) {
dirpath := fmt.Sprintf("formatter_error_tests/%v/", c)

data, err := ioutil.ReadFile(dirpath + "code.json")
data, err := os.ReadFile(dirpath + "code.json")
if err != nil {
t.Errorf("error in ioutil.ReadFile(%v%v): %v", dirpath, "code.json", err)
t.Errorf("error in os.ReadFile(%v%v): %v", dirpath, "code.json", err)
}

if !gjson.Valid(string(data)) {
t.Error("invalid json")
}

results, err := ioutil.ReadFile(dirpath + "results.json")
results, err := os.ReadFile(dirpath + "results.json")
if err != nil {
t.Errorf("error in ioutil.ReadFile(%v%v): %v", dirpath, "results.json", err)
t.Errorf("error in os.ReadFile(%v%v): %v", dirpath, "results.json", err)
}

var res Results
Expand Down
10 changes: 5 additions & 5 deletions internal/bcd/formatter/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package formatter

import (
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
"testing"
Expand Down Expand Up @@ -102,9 +102,9 @@ func TestMichelineToMichelson(t *testing.T) {
t.Run(tt, func(t *testing.T) {
jsonFile := fmt.Sprintf("./formatter_tests/%v/code_%v.json", tt, tt[:6])

data, err := ioutil.ReadFile(jsonFile)
data, err := os.ReadFile(jsonFile)
if err != nil {
t.Error("ioutil.ReadFile code.json error:", err)
t.Error("os.ReadFile code.json error:", err)
}

if !gjson.Valid(string(data)) {
Expand All @@ -118,9 +118,9 @@ func TestMichelineToMichelson(t *testing.T) {
}

tzFile := fmt.Sprintf("./formatter_tests/%v/code_%v.tz", tt, tt[:6])
expected, err := ioutil.ReadFile(tzFile)
expected, err := os.ReadFile(tzFile)
if err != nil {
t.Error("ioutil.ReadFile code.tz error:", err)
t.Error("os.ReadFile code.tz error:", err)
}

re := regexp.MustCompile(`\n\s*`)
Expand Down
4 changes: 2 additions & 2 deletions internal/bcd/translator/converter.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package translator

import (
"io/ioutil"
"os"
"regexp"

"github.com/baking-bad/bcdhub/internal/logger"
Expand Down Expand Up @@ -82,7 +82,7 @@ func (c Converter) trace() {
}

func readFileToString(filename string) (string, error) {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return "", err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/bcd/translator/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package translator

import (
"fmt"
"io/ioutil"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

func TestConverter_FromFile(t *testing.T) {
files, err := ioutil.ReadDir("./tests/")
files, err := os.ReadDir("./tests/")
if err != nil {
t.Errorf("ioutil.ReadDir(./tests/) error = %v", err)
t.Errorf("os.ReadDir(./tests/) error = %v", err)
return
}

Expand All @@ -28,9 +28,9 @@ func TestConverter_FromFile(t *testing.T) {

t.Run(file.Name(), func(t *testing.T) {
resultFilename := fmt.Sprintf("tests/%s/code.json", file.Name())
resultBytes, err := ioutil.ReadFile(resultFilename)
resultBytes, err := os.ReadFile(resultFilename)
if err != nil {
t.Errorf("ioutil.ReadFile() error = %v", err)
t.Errorf("os.ReadFile() error = %v", err)
return
}

Expand Down
3 changes: 1 addition & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
"fmt"
"io/ioutil"
"os"
"regexp"

Expand Down Expand Up @@ -216,7 +215,7 @@ func LoadConfig(filename string) (Config, error) {
return config, fmt.Errorf("you have to provide configuration filename")
}

src, err := ioutil.ReadFile(filename)
src, err := os.ReadFile(filename)
if err != nil {
return config, fmt.Errorf("reading file %s error: %w", filename, err)
}
Expand Down
12 changes: 1 addition & 11 deletions internal/models/types/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@ import "database/sql/driver"

// NullString represents a string that may be null.
// NullString implements the Scanner interface so
// it can be used as a scan destination:
//
// var s NullString
// err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s)
// ...
// if s.Valid {
// // use s.Str
// } else {
// // NULL value
// }
//
// it can be used as a scan destination
type NullString struct {
Str string
Valid bool // Valid is true if Str is not NULL
Expand Down
9 changes: 4 additions & 5 deletions internal/noderpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
stdJSON "encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strconv"
Expand Down Expand Up @@ -38,7 +38,6 @@ type NodeRPC struct {
client *http.Client

timeout time.Duration
cacheDir string
userAgent string
retryCount int
rateLimit *rate.Limiter
Expand Down Expand Up @@ -97,7 +96,7 @@ func (rpc *NodeRPC) checkStatusCode(resp *http.Response, checkStatusCode bool) e
return NewNodeUnavailiableError(rpc.baseURL, resp.StatusCode)
case checkStatusCode:
invalidResponseErr := newInvalidNodeResponse()
data, err := ioutil.ReadAll(resp.Body)
data, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
Expand Down Expand Up @@ -188,10 +187,10 @@ func (rpc *NodeRPC) getRaw(ctx context.Context, uri string) ([]byte, error) {
if err := rpc.checkStatusCode(resp, true); err != nil {
return nil, errors.Wrapf(err, "%s (%s)", ErrNodeRPCError, uri)
}
return ioutil.ReadAll(resp.Body)
return io.ReadAll(resp.Body)
}

//nolint
// nolint
func (rpc *NodeRPC) post(ctx context.Context, uri string, data interface{}, checkStatusCode bool, response interface{}) error {
resp, err := rpc.makePostRequest(ctx, uri, data)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/parsers/operations/operation_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package operations
import (
"context"
"fmt"
"io/ioutil"
"os"
"testing"
"time"

Expand Down Expand Up @@ -2176,7 +2176,7 @@ func TestGroup_Parse(t *testing.T) {
DoAndReturn(
func(_ context.Context, address string, level int64) ([]byte, error) {
storageFile := fmt.Sprintf("./data/rpc/script/storage/%s_%d.json", address, level)
return ioutil.ReadFile(storageFile)
return os.ReadFile(storageFile)
},
).
AnyTimes()
Expand Down
Loading

0 comments on commit 5c724a4

Please sign in to comment.