Tune up generation of the port registry

This commit is contained in:
Martin Boehm 2023-07-02 10:45:41 +02:00
parent d1ffa7bb9e
commit fcd88b3ab4
2 changed files with 20 additions and 19 deletions

View File

@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math"
"os"
"path/filepath"
@ -38,14 +37,17 @@ type Config struct {
Label string `json:"label"`
Alias string `json:"alias"`
}
Ports map[string]uint16 `json:"ports"`
Ports map[string]uint16 `json:"ports"`
Blockbook struct {
PackageName string `json:"package_name"`
}
}
func checkPorts() int {
ports := make(map[uint16][]string)
status := 0
files, err := ioutil.ReadDir(inputDir)
files, err := os.ReadDir(inputDir)
if err != nil {
panic(err)
}
@ -83,8 +85,8 @@ func checkPorts() int {
}
for _, port := range v.Ports {
// ignore duplicities caused by consensus layer configs
if port > 0 && !strings.Contains(v.Coin.Alias, "_consensus") {
// ignore duplicities caused by configs that do not serve blockbook directly (consensus layers)
if port > 0 && v.Blockbook.PackageName == "" {
ports[port] = append(ports[port], v.Coin.Alias)
}
}
@ -134,7 +136,7 @@ func main() {
}
func loadPortInfo(dir string) (PortInfoSlice, error) {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return nil, err
}
@ -160,30 +162,31 @@ func loadPortInfo(dir string) (PortInfoSlice, error) {
return nil, fmt.Errorf("%s: json: %s", path, err)
}
// skip consensus layer configs
if strings.Contains(v.Coin.Alias, "_consensus") {
// skip configs that do not have blockbook (consensus layers)
if v.Blockbook.PackageName == "" {
continue
}
name := v.Coin.Label
if len(name) == 0 || strings.Contains(v.Coin.Name, "Archive") {
// exceptions when to use Name instead of Label so that the table looks good
if len(name) == 0 || strings.Contains(v.Coin.Name, "Ethereum") || strings.Contains(v.Coin.Name, "Archive") {
name = v.Coin.Name
}
item := &PortInfo{CoinName: name, BackendServicePorts: map[string]uint16{}}
for k, v := range v.Ports {
if v == 0 {
for k, p := range v.Ports {
if p == 0 {
continue
}
switch k {
case "blockbook_internal":
item.BlockbookInternalPort = v
item.BlockbookInternalPort = p
case "blockbook_public":
item.BlockbookPublicPort = v
item.BlockbookPublicPort = p
case "backend_rpc":
item.BackendRPCPort = v
item.BackendRPCPort = p
default:
if len(k) > 8 && k[:8] == "backend_" {
item.BackendServicePorts[k[8:]] = v
item.BackendServicePorts[k[8:]] = p
}
}
}

View File

@ -41,9 +41,7 @@
| Flo | 9166 | 9066 | 8066 | 38366 |
| Polis | 9167 | 9067 | 8067 | 38367 |
| Polygon | 9170 | 9070 | 8070 | 38370 p2p, 8170 http |
| Polygon Heimdall | 9171 | 9071 | 8071 | 38371 p2p, 8171 http |
| Polygon Archive | 9172 | 9072 | 8072 | 38372 p2p, 8172 http |
| Polygon Archive Heimdall | 9173 | 9073 | 8073 | 38373 p2p, 8173 http |
| Qtum | 9188 | 9088 | 8088 | 38388 |
| Divi Project | 9189 | 9089 | 8089 | 38389 |
| CPUchain | 9190 | 9090 | 8090 | 38390 |
@ -58,7 +56,7 @@
| Ethereum Testnet Goerli Archive | 19106 | 19006 | 18006 | 18106 http, 18506 authrpc, 48306 p2p |
| Bitcoin Signet | 19120 | 19020 | 18020 | 48320 |
| Bitcoin Regtest | 19121 | 19021 | 18021 | 48321 |
| Ethereum Goerli | 19126 | 19026 | 18026 | 18126 http, 18526 authrpc, 48326 p2p |
| Ethereum Testnet Goerli | 19126 | 19026 | 18026 | 18126 http, 18526 authrpc, 48326 p2p |
| Bitcoin Testnet | 19130 | 19030 | 18030 | 48330 |
| Bitcoin Cash Testnet | 19131 | 19031 | 18031 | 48331 |
| Zcash Testnet | 19132 | 19032 | 18032 | 48332 |
@ -76,7 +74,7 @@
| Koto Testnet | 19151 | 19051 | 18051 | 48351 |
| Decred Testnet | 19161 | 19061 | 18061 | 48361 |
| Flo Testnet | 19166 | 19066 | 18066 | 48366 |
| Ethereum Sepolia | 19176 | 19076 | 18076 | 18176 http, 18576 authrpc, 48376 p2p |
| Ethereum Testnet Sepolia | 19176 | 19076 | 18076 | 18176 http, 18576 authrpc, 48376 p2p |
| Ethereum Testnet Sepolia Archive | 19186 | 19086 | 18086 | 18186 http, 18586 authrpc, 48386 p2p |
| Qtum Testnet | 19188 | 19088 | 18088 | 48388 |
| Omotenashicoin Testnet | 19189 | 19089 | 18089 | 48389 |