forked from TrueCloudLab/frostfs-node
[#732] neofs-adm: fetch native hashes once
Retrieve list of native contracts during initialization in a single query. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
6a40adcfca
commit
c81008764a
6 changed files with 26 additions and 37 deletions
|
@ -32,6 +32,7 @@ type initializeContext struct {
|
|||
Contracts map[string]*contractState
|
||||
Command *cobra.Command
|
||||
ContractPath string
|
||||
Natives map[string]util.Uint160
|
||||
}
|
||||
|
||||
func initializeSideChainCmd(cmd *cobra.Command, args []string) error {
|
||||
|
@ -129,6 +130,16 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
|
|||
return nil, fmt.Errorf("missing contracts path: %w", err)
|
||||
}
|
||||
|
||||
ns, err := c.GetNativeContracts()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't get native contract hashes: %w", err)
|
||||
}
|
||||
|
||||
nativeHashes := make(map[string]util.Uint160, len(ns))
|
||||
for i := range ns {
|
||||
nativeHashes[ns[i].Manifest.Name] = ns[i].Hash
|
||||
}
|
||||
|
||||
initCtx := &initializeContext{
|
||||
Client: c,
|
||||
ConsensusAcc: consensusAcc,
|
||||
|
@ -139,11 +150,16 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
|
|||
Command: cmd,
|
||||
Contracts: make(map[string]*contractState),
|
||||
ContractPath: ctrPath,
|
||||
Natives: nativeHashes,
|
||||
}
|
||||
|
||||
return initCtx, nil
|
||||
}
|
||||
|
||||
func (c *initializeContext) nativeHash(name string) util.Uint160 {
|
||||
return c.Natives[name]
|
||||
}
|
||||
|
||||
func openAlphabetWallets(walletDir string) ([]*wallet.Wallet, error) {
|
||||
walletFiles, err := ioutil.ReadDir(walletDir)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue