Switch to using primary alias instead as base instead of full chain id

This commit is contained in:
Aaron Buchwald 2020-06-05 14:21:21 -04:00
parent 5847e69e45
commit 6c09e449e0
4 changed files with 16 additions and 19 deletions

View File

@ -75,8 +75,9 @@ func (s *Server) RegisterChain(ctx *snow.Context, vmIntf interface{}) {
}
// all subroutes to a chain begin with "bc/<the chain's ID>"
defaultEndpoint := "bc/" + ctx.ChainID.String()
httpLogger, err := s.factory.MakeChain(ctx.ChainID, "http")
chainID := ctx.ChainID.String()
defaultEndpoint := "bc/" + chainID
httpLogger, err := s.factory.MakeChain(chainID, "http")
if err != nil {
s.log.Error("Failed to create new http logger: %s", err)
return

View File

@ -247,8 +247,13 @@ func (m *manager) ForceCreateChain(chain ChainParameters) {
}
}
primaryAlias, err := m.PrimaryAlias(chain.ID)
if err != nil {
primaryAlias = chain.ID.String()
}
// Create the log and context of the chain
chainLog, err := m.logFactory.MakeChain(chain.ID, "")
chainLog, err := m.logFactory.MakeChain(primaryAlias, "")
if err != nil {
m.log.Error("error while creating chain's log %s", err)
return
@ -266,12 +271,9 @@ func (m *manager) ForceCreateChain(chain ChainParameters) {
SharedMemory: m.sharedMemory.NewBlockchainSharedMemory(chain.ID),
BCLookup: m,
}
consensusParams := m.consensusParams
if alias, err := m.PrimaryAlias(ctx.ChainID); err == nil {
consensusParams.Namespace = fmt.Sprintf("gecko_%s", alias)
} else {
consensusParams.Namespace = fmt.Sprintf("gecko_%s", ctx.ChainID)
}
consensusParams.Namespace = fmt.Sprintf("gecko_%s", primaryAlias)
// The validators of this blockchain
var validators validators.Set // Validators validating this blockchain

View File

@ -5,14 +5,12 @@ package logging
import (
"path"
"github.com/ava-labs/gecko/ids"
)
// Factory ...
type Factory interface {
Make() (Logger, error)
MakeChain(chainID ids.ID, subdir string) (Logger, error)
MakeChain(chainID string, subdir string) (Logger, error)
MakeSubdir(subdir string) (Logger, error)
Close()
}
@ -41,10 +39,10 @@ func (f *factory) Make() (Logger, error) {
}
// MakeChain ...
func (f *factory) MakeChain(chainID ids.ID, subdir string) (Logger, error) {
func (f *factory) MakeChain(chainID string, subdir string) (Logger, error) {
config := f.config
config.MsgPrefix = "chain " + chainID.String()
config.Directory = path.Join(config.Directory, "chain", chainID.String(), subdir)
config.MsgPrefix = chainID + " Chain"
config.Directory = path.Join(config.Directory, "chain", chainID, subdir)
log, err := New(config)
if err == nil {

View File

@ -3,10 +3,6 @@
package logging
import (
"github.com/ava-labs/gecko/ids"
)
// NoFactory ...
type NoFactory struct{}
@ -14,7 +10,7 @@ type NoFactory struct{}
func (NoFactory) Make() (Logger, error) { return NoLog{}, nil }
// MakeChain ...
func (NoFactory) MakeChain(ids.ID, string) (Logger, error) { return NoLog{}, nil }
func (NoFactory) MakeChain(string, string) (Logger, error) { return NoLog{}, nil }
// MakeSubdir ...
func (NoFactory) MakeSubdir(string) (Logger, error) { return NoLog{}, nil }