Skip to content

Commit

Permalink
cleaned up packages
Browse files Browse the repository at this point in the history
  • Loading branch information
AmineAfia committed Sep 17, 2024
1 parent 903dd8d commit 16b77f4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 22 deletions.
10 changes: 5 additions & 5 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package main

import (
"fmt"
"net/http"
"fmt"
"net/http"

"github.com/go-chi/chi/v5"
log "github.com/sirupsen/logrus"
"github.com/thirdweb-dev/data-layer/internal/handlers"
"github.com/go-chi/chi/v5"
log "github.com/sirupsen/logrus"
"github.com/thirdweb-dev/indexer/internal/handlers"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"log"
"os"

"github.com/thirdweb-dev/data-layer/internal/orchestrator"
"github.com/thirdweb-dev/indexer/internal/orchestrator"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/thirdweb-dev/data-layer
module github.com/thirdweb-dev/indexer

go 1.22.0

Expand All @@ -8,6 +8,7 @@ require (
github.com/go-chi/chi v1.5.4
github.com/go-chi/chi/v5 v5.1.0
github.com/gorilla/schema v1.2.0
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/joho/godotenv v1.5.1
github.com/sirupsen/logrus v1.9.3
)
Expand All @@ -29,7 +30,6 @@ require (
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/holiman/uint256 v1.3.1 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handlers
import (
chimiddle "github.com/go-chi/chi/middleware"
"github.com/go-chi/chi/v5"
"github.com/thirdweb-dev/data-layer/internal/middleware"
"github.com/thirdweb-dev/indexer/internal/middleware"
)

func Handler(r *chi.Mux) {
Expand Down
17 changes: 8 additions & 9 deletions internal/handlers/get_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/gorilla/schema"
log "github.com/sirupsen/logrus"
"github.com/thirdweb-dev/data-layer/api"
"github.com/thirdweb-dev/data-layer/internal/tools"
"github.com/thirdweb-dev/indexer/api"
"github.com/thirdweb-dev/indexer/internal/tools"
)

func GetBlocks(w http.ResponseWriter, r *http.Request) {
Expand All @@ -31,20 +31,19 @@ func GetBlocks(w http.ResponseWriter, r *http.Request) {
api.InternalErrorHandler(w)
return
}
// defer conn.Close()

row := conn.QueryRow(context.Background(), "SELECT block_hash FROM chainsaw.blocks LIMIT 1")
var blockHash string
err = row.Scan(&blockHash)
fmt.Printf("valoue %v\n", blockHash)
var blockNumber uint64
err = row.Scan(&blockNumber)
fmt.Printf("valoue %v\n", blockNumber)
if err != nil {
log.Error(err)
api.InternalErrorHandler(w)
api.RequestErrorHandler(w, err)
return
}

var response = api.QueryResponse{
Result: blockHash,
Result: fmt.Sprintf("%d", blockNumber),
Code: http.StatusOK,
}

Expand All @@ -55,6 +54,6 @@ func GetBlocks(w http.ResponseWriter, r *http.Request) {
api.InternalErrorHandler(w)
return
}

defer conn.Close()
}
2 changes: 1 addition & 1 deletion internal/middleware/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"

"github.com/ethereum/go-ethereum/log"
"github.com/thirdweb-dev/data-layer/api"
"github.com/thirdweb-dev/indexer/api"
)

var ErrUnauthorized = fmt.Errorf("invalid username or password")
Expand Down
2 changes: 1 addition & 1 deletion internal/orchestrator/failure_recoverer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/thirdweb-dev/data-layer/internal/worker"
"github.com/thirdweb-dev/indexer/internal/worker"
)

const DEFAULT_FAILURES_PER_POLL = 10
Expand Down
2 changes: 1 addition & 1 deletion internal/orchestrator/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/thirdweb-dev/data-layer/internal/worker"
"github.com/thirdweb-dev/indexer/internal/worker"
)

const DEFAULT_BLOCKS_PER_POLL = 10
Expand Down
2 changes: 1 addition & 1 deletion internal/orchestrator/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"time"

"github.com/thirdweb-dev/data-layer/internal/storage"
"github.com/thirdweb-dev/indexer/internal/storage"
)

type OrchestratorStorageConfig struct {
Expand Down

0 comments on commit 16b77f4

Please sign in to comment.