consensus: don't decrypt the key again and again, cache it
It's cached in dbft for a view anyway, so there is no big difference here from security POV. Lets us squeeze yet another 4% TPS improvement. Make the system fail if unable to decrypt the key along the way, which is a part of #1312.
This commit is contained in:
parent
c7032022f8
commit
0bf2fa915e
1 changed files with 9 additions and 3 deletions
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
|
@ -255,9 +256,14 @@ func (s *service) getKeyPair(pubs []crypto.PublicKey) (int, crypto.PrivateKey, c
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
key, err := keys.NEP2Decrypt(acc.EncryptedWIF, s.Config.Wallet.Password)
|
key := acc.PrivateKey()
|
||||||
|
if acc.PrivateKey() == nil {
|
||||||
|
err := acc.Decrypt(s.Config.Wallet.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
s.log.Fatal("can't unlock account", zap.String("address", address.Uint160ToString(sh)))
|
||||||
|
break
|
||||||
|
}
|
||||||
|
key = acc.PrivateKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
return i, &privateKey{PrivateKey: key}, &publicKey{PublicKey: key.PublicKey()}
|
return i, &privateKey{PrivateKey: key}, &publicKey{PublicKey: key.PublicKey()}
|
||||||
|
|
Loading…
Reference in a new issue