forked from TrueCloudLab/frostfs-node
[#1513] node: Encode node's public key into binary format once
Avoid per-iteration key encoding due to the immutability of the key. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
4574ba646d
commit
eb7b8bf7c4
2 changed files with 11 additions and 8 deletions
|
@ -77,6 +77,8 @@ type cfg struct {
|
||||||
|
|
||||||
key *keys.PrivateKey
|
key *keys.PrivateKey
|
||||||
|
|
||||||
|
binPublicKey []byte
|
||||||
|
|
||||||
ownerIDFromKey user.ID // user ID calculated from key
|
ownerIDFromKey user.ID // user ID calculated from key
|
||||||
|
|
||||||
apiVersion version.Version
|
apiVersion version.Version
|
||||||
|
@ -269,13 +271,14 @@ func initCfg(path string) *cfg {
|
||||||
fatalOnErr(err)
|
fatalOnErr(err)
|
||||||
|
|
||||||
c := &cfg{
|
c := &cfg{
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
appCfg: appCfg,
|
appCfg: appCfg,
|
||||||
internalErr: make(chan error),
|
internalErr: make(chan error),
|
||||||
log: log,
|
log: log,
|
||||||
wg: new(sync.WaitGroup),
|
wg: new(sync.WaitGroup),
|
||||||
key: key,
|
key: key,
|
||||||
apiVersion: version.Current(),
|
binPublicKey: key.PublicKey().Bytes(),
|
||||||
|
apiVersion: version.Current(),
|
||||||
cfgAccounting: cfgAccounting{
|
cfgAccounting: cfgAccounting{
|
||||||
scriptHash: contractsconfig.Balance(appCfg),
|
scriptHash: contractsconfig.Balance(appCfg),
|
||||||
},
|
},
|
||||||
|
|
|
@ -288,7 +288,7 @@ func (c *cfg) netmapLocalNodeState(epoch uint64) (*netmapSDK.NodeInfo, error) {
|
||||||
|
|
||||||
nmNodes := nm.Nodes()
|
nmNodes := nm.Nodes()
|
||||||
for i := range nmNodes {
|
for i := range nmNodes {
|
||||||
if bytes.Equal(nmNodes[i].PublicKey(), c.key.PublicKey().Bytes()) {
|
if bytes.Equal(nmNodes[i].PublicKey(), c.binPublicKey) {
|
||||||
return &nmNodes[i], nil
|
return &nmNodes[i], nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue