Files
zeekayandHanzo Dev 1f16fb24f3 chain routes: /v1/bc -> /v1/chain
luxd serves chain routes under /v1/chain, and the node, cli and sdk releases
already ship it. The deployed gateways still answer the old prefix, so remote
reads break until they are redeployed; the estate moves together rather than
sitting half converted.

Lines that record an observation - a probe, a status code, a past release -
keep the prefix they were written against, as do URLs on hosts that are not
ours. Avalanche endpoints move to /ext/bc, which is the path that host serves.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-01 08:16:34 -07:00

48 lines
1.2 KiB
Go

// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package utils
import (
"fmt"
"path/filepath"
"strings"
"sync"
)
type ChainSuite struct {
blockchainIDs map[string]string
lock sync.RWMutex
}
func (s *ChainSuite) GetBlockchainID(alias string) string {
s.lock.RLock()
defer s.lock.RUnlock()
return s.blockchainIDs[alias]
}
func (s *ChainSuite) SetBlockchainIDs(blockchainIDs map[string]string) {
s.lock.Lock()
defer s.lock.Unlock()
s.blockchainIDs = blockchainIDs
}
// GetDefaultChainURI returns the default chain URI for a given blockchainID
func GetDefaultChainURI(blockchainID string) string {
return fmt.Sprintf("%s/v1/chain/%s/rpc", DefaultLocalNodeURI, blockchainID)
}
// GetFilesAndAliases returns a map of aliases to file paths in given [dir].
func GetFilesAndAliases(dir string) (map[string]string, error) {
files, err := filepath.Glob(dir)
if err != nil {
return nil, err
}
aliasesToFiles := make(map[string]string)
for _, file := range files {
alias := strings.TrimSuffix(filepath.Base(file), filepath.Ext(file))
aliasesToFiles[alias] = file
}
return aliasesToFiles, nil
}