Skip to content

Commit

Permalink
locode: Update locode DB to the new version
Browse files Browse the repository at this point in the history
With new Go package locodedb there is no need of separate DB file.

 Refs: #100.

Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed Nov 10, 2023
1 parent fc0b6c1 commit 7714e43
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 281 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
12 changes: 5 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ require (
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
)

require (
github.com/google/uuid v1.3.0
github.com/nspcc-dev/locode-db v0.4.1-0.20231109111047-07567f7bb52c
)

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
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
github.com/ipfs/go-cid v0.0.7 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -41,7 +41,6 @@ require (
github.com/multiformats/go-multibase v0.0.3 // indirect
github.com/multiformats/go-multihash v0.0.14 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 // indirect
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20230919154019-f66abd020d6a // indirect
github.com/nspcc-dev/rfc6979 v0.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
Expand All @@ -55,7 +54,6 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b // indirect
golang.org/x/net v0.14.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.20231109111047-07567f7bb52c h1:YOYctsLYN6LniG146qogXx7IPDjIXi3QLfibAC7nWwk=
github.com/nspcc-dev/locode-db v0.4.1-0.20231109111047-07567f7bb52c/go.mod h1:DXkhJM1Wrh2JY5sAv9gI1G8XneGYS8zjlEhwU4f6KPw=
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 7714e43

Please sign in to comment.