mirror of https://github.com/poanetwork/gecko.git
Merge branch 'improve-apis' into improve-health-service
This commit is contained in:
commit
5d7e62f7c7
|
@ -119,7 +119,7 @@ type manager struct {
|
||||||
|
|
||||||
// Key: Chain's ID
|
// Key: Chain's ID
|
||||||
// Value: The chain
|
// Value: The chain
|
||||||
chains map[[32]byte]common.Engine
|
chains map[[32]byte]*router.Handler
|
||||||
|
|
||||||
unblocked bool
|
unblocked bool
|
||||||
blockedChains []ChainParameters
|
blockedChains []ChainParameters
|
||||||
|
@ -138,7 +138,7 @@ func New(
|
||||||
decisionEvents *triggers.EventDispatcher,
|
decisionEvents *triggers.EventDispatcher,
|
||||||
consensusEvents *triggers.EventDispatcher,
|
consensusEvents *triggers.EventDispatcher,
|
||||||
db database.Database,
|
db database.Database,
|
||||||
router router.Router,
|
rtr router.Router,
|
||||||
net network.Network,
|
net network.Network,
|
||||||
consensusParams avacon.Parameters,
|
consensusParams avacon.Parameters,
|
||||||
validators validators.Manager,
|
validators validators.Manager,
|
||||||
|
@ -152,7 +152,7 @@ func New(
|
||||||
timeoutManager.Initialize(requestTimeout)
|
timeoutManager.Initialize(requestTimeout)
|
||||||
go log.RecoverAndPanic(timeoutManager.Dispatch)
|
go log.RecoverAndPanic(timeoutManager.Dispatch)
|
||||||
|
|
||||||
router.Initialize(log, &timeoutManager, gossipFrequency, shutdownTimeout)
|
rtr.Initialize(log, &timeoutManager, gossipFrequency, shutdownTimeout)
|
||||||
|
|
||||||
m := &manager{
|
m := &manager{
|
||||||
stakingEnabled: stakingEnabled,
|
stakingEnabled: stakingEnabled,
|
||||||
|
@ -162,7 +162,7 @@ func New(
|
||||||
decisionEvents: decisionEvents,
|
decisionEvents: decisionEvents,
|
||||||
consensusEvents: consensusEvents,
|
consensusEvents: consensusEvents,
|
||||||
db: db,
|
db: db,
|
||||||
chainRouter: router,
|
chainRouter: rtr,
|
||||||
net: net,
|
net: net,
|
||||||
timeoutManager: &timeoutManager,
|
timeoutManager: &timeoutManager,
|
||||||
consensusParams: consensusParams,
|
consensusParams: consensusParams,
|
||||||
|
@ -172,7 +172,7 @@ func New(
|
||||||
server: server,
|
server: server,
|
||||||
keystore: keystore,
|
keystore: keystore,
|
||||||
sharedMemory: sharedMemory,
|
sharedMemory: sharedMemory,
|
||||||
chains: make(map[[32]byte]common.Engine),
|
chains: make(map[[32]byte]*router.Handler),
|
||||||
}
|
}
|
||||||
m.Initialize()
|
m.Initialize()
|
||||||
return m
|
return m
|
||||||
|
@ -462,7 +462,7 @@ func (m *manager) createAvalancheChain(
|
||||||
eng: &engine,
|
eng: &engine,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
m.chains[ctx.ChainID.Key()] = &engine
|
m.chains[ctx.ChainID.Key()] = handler
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,15 +554,18 @@ func (m *manager) createSnowmanChain(
|
||||||
eng: &engine,
|
eng: &engine,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
m.chains[ctx.ChainID.Key()] = &engine
|
m.chains[ctx.ChainID.Key()] = handler
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *manager) IsBootstrapped(id ids.ID) bool {
|
func (m *manager) IsBootstrapped(id ids.ID) bool {
|
||||||
if chain, exists := m.chains[id.Key()]; exists && chain.IsBootstrapped() {
|
chain, exists := m.chains[id.Key()]
|
||||||
return true
|
if !exists {
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
|
}
|
||||||
|
chain.Context().Lock.Lock()
|
||||||
|
defer chain.Context().Lock.Unlock()
|
||||||
|
return chain.Engine().IsBootstrapped()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown stops all the chains
|
// Shutdown stops all the chains
|
||||||
|
|
|
@ -35,3 +35,6 @@ func (mm MockManager) Alias(ids.ID, string) error { return nil }
|
||||||
|
|
||||||
// Shutdown ...
|
// Shutdown ...
|
||||||
func (mm MockManager) Shutdown() {}
|
func (mm MockManager) Shutdown() {}
|
||||||
|
|
||||||
|
// IsBootstrapped ...
|
||||||
|
func (mm MockManager) IsBootstrapped(ids.ID) bool { return false }
|
||||||
|
|
Loading…
Reference in New Issue