forked from TrueCloudLab/frostfs-node
[#733] neofs-adm: read contracts on start
Fail early and reduce disk operations when reading from archive. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
0b6350d463
commit
088c894f44
6 changed files with 105 additions and 107 deletions
|
@ -122,18 +122,12 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
|
|||
return nil, fmt.Errorf("max object size must be positive")
|
||||
}
|
||||
}
|
||||
if cmd.Name() == "update-contracts" || cmd.Name() == "init" {
|
||||
|
||||
needContracts := cmd.Name() == "update-contracts" || cmd.Name() == "init"
|
||||
if needContracts {
|
||||
ctrPath, err = cmd.Flags().GetString(contractsInitFlag)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("missing contracts path: %w", err)
|
||||
}
|
||||
if ctrPath == "" {
|
||||
cmd.Println("Contracts flag is missing, latest release will be fetched from Github.")
|
||||
ctrPath, err = downloadContractsFromGithub(cmd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd.Printf("Saved to %s\n", ctrPath)
|
||||
return nil, fmt.Errorf("invalid contracts path: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,6 +171,13 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
|
|||
Natives: nativeHashes,
|
||||
}
|
||||
|
||||
if needContracts {
|
||||
err := initCtx.readContracts(fullContractList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return initCtx, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue