Skip to content

Commit

Permalink
Merge pull request #102 from nspcc-dev/locodedb-update
Browse files Browse the repository at this point in the history
locode: Update locode DB to the new version
  • Loading branch information
roman-khimov authored Nov 10, 2023
2 parents fc0b6c1 + c67dd47 commit 2b03087
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 276 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bin/
/locode/
tmp/
.idea
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changelog for NeoFS Monitor

## [Unreleased]

### Changed
- Usage of Locode DB Go package (#100)

### Removed
- Locode DB configuration options (#100)

## [0.9.5] - 2022-12-29

### Changed
Expand Down
21 changes: 4 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ APP = neofs-net-monitor
BINARY = ./bin/${APP}
SRC = ./cmd/${APP}/

LOCODE_DIR = ./locode
LOCODE_FILE = locode_db.gz
LOCODE_DB_URL = https://github.com/nspcc-dev/neofs-locode-db/releases/download/v0.2.1/locode_db.gz

.PHONY: bin image up up-testnet up-devenv down down-testnet down-devenv clean locode lint test cover
.PHONY: bin image up up-testnet up-devenv down down-testnet down-devenv clean lint test cover

bin:
@echo "Build neofs-net-monitor binary"
Expand All @@ -31,21 +27,13 @@ image:
--build-arg VERSION=$(VERSION) \
-t ${REPO}/${APP}:$(HUB_TAG) .

locode:
@mkdir -p ${LOCODE_DIR}
@echo "⇒ Download NeoFS LOCODE database from ${LOCODE_DB_URL}"
@curl \
-sSL "${LOCODE_DB_URL}" \
-o ${LOCODE_DIR}/${LOCODE_FILE}
gzip -dfk ${LOCODE_DIR}/${LOCODE_FILE}

up: locode
up:
@docker-compose -f docker/docker-compose.yml --env-file docker/mainnet.env up -d

up-testnet: locode
up-testnet:
@docker-compose -f docker/docker-compose.yml --env-file docker/testnet.env up -d

up-devenv: locode
up-devenv:
@docker-compose -f docker/docker-compose.devenv.yml up -d

down:
Expand All @@ -59,7 +47,6 @@ down-devenv:

clean:
rm -f ${BINARY}
rm -rf ${LOCODE_DIR}

version:
@echo ${VERSION}
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ $ neofs-net-monitor --config config.yaml

Also, you can provide all options using env variables.

To download actual LOCODE database run `$ make locode`.
Visit LOCODE [repository](https://github.com/nspcc-dev/neofs-locode-db) for more information.

```
// Optional path to NeoFS LOCODE database.
NEOFS_NET_MONITOR_LOCODE_DB_PATH=path/to/database
```

## Connect to neofs-dev-env

After `Jebudo` release monitor can be attached to
Expand Down
5 changes: 0 additions & 5 deletions cmd/neofs-net-monitor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const (
cfgMetricsEndpoint = "metrics.endpoint"
cfgMetricsInterval = "metrics.interval"

// path to the NeoFS locode database
cfgLocodeDB = "locode.db.path"

// level of logging
cfgLoggerLevel = "logger.level"
)
Expand All @@ -43,8 +40,6 @@ func DefaultConfiguration(cfg *viper.Viper) {
cfg.SetDefault(cfgMetricsEndpoint, ":16512")
cfg.SetDefault(cfgMetricsInterval, 15*time.Minute)

cfg.SetDefault(cfgLocodeDB, "./locode/db")

cfg.SetDefault(cfgLoggerLevel, "info")
}

Expand Down
8 changes: 0 additions & 8 deletions cmd/neofs-net-monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/nspcc-dev/neo-go/pkg/util"
rpcnns "github.com/nspcc-dev/neofs-contract/rpc/nns"
"github.com/nspcc-dev/neofs-net-monitor/pkg/locode"
"github.com/nspcc-dev/neofs-net-monitor/pkg/monitor"
"github.com/nspcc-dev/neofs-net-monitor/pkg/morphchain"
"github.com/nspcc-dev/neofs-net-monitor/pkg/morphchain/contracts"
Expand Down Expand Up @@ -124,20 +123,13 @@ func New(ctx context.Context, cfg *viper.Viper) (*monitor.Monitor, error) {
logger.Info("neofs contract ignored")
}

geoFetcher := locode.New(
locode.Prm{
Path: cfg.GetString(cfgLocodeDB),
},
)

return monitor.New(monitor.Args{
Balance: balance,
Proxy: proxy,
Neofs: neofs,
Logger: logger,
Sleep: cfg.GetDuration(cfgMetricsInterval),
MetricsAddress: cfg.GetString(cfgMetricsEndpoint),
GeoFetcher: geoFetcher,
AlpFetcher: alphabetFetcher,
NmFetcher: nmFetcher,
IRFetcher: nmFetcher,
Expand Down
2 changes: 0 additions & 2 deletions config/config.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ NEOFS_NET_MONITOR_METRICS_INTERVAL=15m
# NeoFS contract from main chain. Required for asset supply metric.
NEOFS_NET_MONITOR_CONTRACTS_NEOFS=3c3f4b84773ef0141576e48c3ff60e5078235891

# Optional path to NeoFS LOCODE database.
NEOFS_NET_MONITOR_LOCODE_DB_PATH=path/to/database
5 changes: 0 additions & 5 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ metrics:
interval: 15s
endpoint: ":16512"

# Optional path to NeoFS LOCODE database.
locode:
db:
path: locode/db

contracts:
# NeoFS contract from main chain. Required for asset supply metric.
neofs: 3c3f4b84773ef0141576e48c3ff60e5078235891
Expand Down
3 changes: 0 additions & 3 deletions docker/docker-compose.devenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ services:
- prometheus
environment:
- NEOFS_NET_MONITOR_METRICS_INTERVAL=15s
- NEOFS_NET_MONITOR_LOCODE_DB_PATH=locode/db
- NEOFS_NET_MONITOR_MAINNET_RPC_ENDPOINT=http://192.168.130.50:30333
- NEOFS_NET_MONITOR_MORPH_RPC_ENDPOINT=http://192.168.130.90:30333
volumes:
- ./../locode/locode_db:/locode/db
networks:
- internet
restart: on-failure
3 changes: 0 additions & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ services:
- prometheus
environment:
- NEOFS_NET_MONITOR_METRICS_INTERVAL=15s
- NEOFS_NET_MONITOR_LOCODE_DB_PATH=locode/db
- NEOFS_NET_MONITOR_MAINNET_RPC_ENDPOINT=${NEOFS_NET_MONITOR_MAINNET_RPC_ENDPOINT}
- NEOFS_NET_MONITOR_MORPH_RPC_ENDPOINT=${NEOFS_NET_MONITOR_MORPH_RPC_ENDPOINT}
- NEOFS_NET_MONITOR_CONTRACTS_NEOFS=${NEOFS_NET_MONITOR_CONTRACTS_NEOFS}
volumes:
- ./../locode/locode_db:/locode/db
networks:
- monitor-net
restart: on-failure
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ module github.com/nspcc-dev/neofs-net-monitor
go 1.19

require (
github.com/google/uuid v1.3.0
github.com/multiformats/go-multiaddr v0.4.0
github.com/nspcc-dev/hrw v1.0.9
github.com/nspcc-dev/locode-db v0.4.1-0.20231110164540-a21ea2774f2e
github.com/nspcc-dev/neo-go v0.102.0
github.com/nspcc-dev/neofs-api-go/v2 v2.14.0
github.com/nspcc-dev/neofs-contract v0.18.0
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.11
github.com/prometheus/client_golang v1.17.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
go.etcd.io/bbolt v1.3.7
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.12.0 // indirect
)
Expand All @@ -25,7 +26,6 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaF
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
github.com/nspcc-dev/locode-db v0.4.1-0.20231110164540-a21ea2774f2e h1:mcL78g9av0/CYVrgMgGqRJLwZAfvLdIaoaPnEDLC6n8=
github.com/nspcc-dev/locode-db v0.4.1-0.20231110164540-a21ea2774f2e/go.mod h1:M+v8C+t9vwYbIVEdTPX/0w2LFRY+FJnYbVUdrzq7iWQ=
github.com/nspcc-dev/neo-go v0.102.0 h1:O2Gt4JPOWmp0c+PnPWwd2wPI74BKSwkaNCEyvyQTWJw=
github.com/nspcc-dev/neo-go v0.102.0/go.mod h1:QXxpZxJT2KedwM0Nlj8UO0/fZN2WIe4h/i03uBHKbnc=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20230919154019-f66abd020d6a h1:ZF1T2PfRJh0LbQcMQAPMmp94B27o/6DKZV+zcMIUNHM=
Expand Down Expand Up @@ -259,7 +261,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
135 changes: 0 additions & 135 deletions pkg/locode/calls.go

This file was deleted.

Loading

0 comments on commit 2b03087

Please sign in to comment.