Skip to content

Commit

Permalink
add per node chain config to local blockchain spec
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Dec 12, 2022
1 parent c298fd6 commit e700f2c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type BlockchainSpec struct {
ChainConfig []byte
NetworkUpgrade []byte
SubnetConfig []byte
PerNodeChainConfig map[string][]byte
}

// Network is an abstraction of an Avalanche network
Expand Down
28 changes: 21 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,31 @@ func getNetworkBlockchainSpec(
return network.BlockchainSpec{}, err
}
}
perNodeChainConfig := map[string][]byte{}
if len(spec.PerNodeChainConfig) != 0 {
for nodeName, chainConfigPath := range spec.PerNodeChainConfig {
b, err := os.ReadFile(chainConfigPath)
if err != nil {
return network.BlockchainSpec{}, err
}
perNodeChainConfig[nodeName] = b
}
}
return network.BlockchainSpec{
VmName: vmName,
Genesis: genesisBytes,
ChainConfig: chainConfigBytes,
NetworkUpgrade: networkUpgradeBytes,
SubnetConfig: subnetConfigBytes,
SubnetId: spec.SubnetId,
VmName: vmName,
Genesis: genesisBytes,
ChainConfig: chainConfigBytes,
NetworkUpgrade: networkUpgradeBytes,
SubnetConfig: subnetConfigBytes,
SubnetId: spec.SubnetId,
PerNodeChainConfig: perNodeChainConfig,
}, nil
}

func (s *server) CreateBlockchains(ctx context.Context, req *rpcpb.CreateBlockchainsRequest) (*rpcpb.CreateBlockchainsResponse, error) {
func (s *server) CreateBlockchains(
ctx context.Context,
req *rpcpb.CreateBlockchainsRequest,
) (*rpcpb.CreateBlockchainsResponse, error) {
// if timeout is too small or not set, default to 5-min
if deadline, ok := ctx.Deadline(); !ok || time.Until(deadline) < defaultStartTimeout {
var cancel context.CancelFunc
Expand Down

0 comments on commit e700f2c

Please sign in to comment.