mirror of https://github.com/poanetwork/gecko.git
fix bug where no chains other than platform created if staking disabled
This commit is contained in:
parent
fb5f6a9d5d
commit
633e72394f
|
@ -361,8 +361,9 @@ func (n *Node) initChains() {
|
||||||
n.vmManager.RegisterVMFactory(
|
n.vmManager.RegisterVMFactory(
|
||||||
/*vmID=*/ platformvm.ID,
|
/*vmID=*/ platformvm.ID,
|
||||||
/*vmFactory=*/ &platformvm.Factory{
|
/*vmFactory=*/ &platformvm.Factory{
|
||||||
ChainManager: n.chainManager,
|
ChainManager: n.chainManager,
|
||||||
Validators: vdrs,
|
Validators: vdrs,
|
||||||
|
StakingEnabled: n.Config.EnableStaking,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,16 @@ var (
|
||||||
|
|
||||||
// Factory can create new instances of the Platform Chain
|
// Factory can create new instances of the Platform Chain
|
||||||
type Factory struct {
|
type Factory struct {
|
||||||
ChainManager chains.Manager
|
ChainManager chains.Manager
|
||||||
Validators validators.Manager
|
Validators validators.Manager
|
||||||
|
StakingEnabled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new instance of the Platform Chain
|
// New returns a new instance of the Platform Chain
|
||||||
func (f *Factory) New() interface{} {
|
func (f *Factory) New() interface{} {
|
||||||
return &VM{
|
return &VM{
|
||||||
ChainManager: f.ChainManager,
|
ChainManager: f.ChainManager,
|
||||||
Validators: f.Validators,
|
Validators: f.Validators,
|
||||||
|
StakingEnabled: f.StakingEnabled,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,8 +136,13 @@ func init() {
|
||||||
type VM struct {
|
type VM struct {
|
||||||
*core.SnowmanVM
|
*core.SnowmanVM
|
||||||
|
|
||||||
|
// Node's validator manager
|
||||||
|
// Maps Subnets --> nodes in the Subnet
|
||||||
Validators validators.Manager
|
Validators validators.Manager
|
||||||
|
|
||||||
|
// true if the node is being run with staking enabled
|
||||||
|
StakingEnabled bool
|
||||||
|
|
||||||
// The node's chain manager
|
// The node's chain manager
|
||||||
ChainManager chains.Manager
|
ChainManager chains.Manager
|
||||||
|
|
||||||
|
@ -327,7 +332,7 @@ func (vm *VM) createChain(tx *CreateChainTx) {
|
||||||
vm.Ctx.Log.Error("blockchain %s validated by Subnet %s but couldn't get that Subnet. Blockchain not created")
|
vm.Ctx.Log.Error("blockchain %s validated by Subnet %s but couldn't get that Subnet. Blockchain not created")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !validators.Contains(vm.Ctx.NodeID) { // This node doesn't validate this blockchain
|
if !validators.Contains(vm.Ctx.NodeID) && vm.StakingEnabled { // This node doesn't validate this blockchain
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue