Skip to content

Commit

Permalink
add lock for new address
Browse files Browse the repository at this point in the history
  • Loading branch information
hunjixin committed Dec 21, 2021
1 parent 876c949 commit f7c167b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/wallet/dsbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ func (backend *DSBackend) HasAddress(addr address.Address) bool {
// NewAddress creates a new address and stores it.
// Safe for concurrent access.
func (backend *DSBackend) NewAddress(protocol address.Protocol) (address.Address, error) {
backend.lk.Lock()
defer backend.lk.Unlock()

switch protocol {
case address.BLS:
return backend.newBLSAddress()
Expand Down Expand Up @@ -166,9 +169,6 @@ func (backend *DSBackend) putKeyInfo(ki *crypto.KeyInfo) error {
KeyInfo: ki,
}

backend.lk.Lock()
defer backend.lk.Unlock()

var keyJSON []byte
err = backend.UsePassword(func(password []byte) error {
var err error
Expand Down

0 comments on commit f7c167b

Please sign in to comment.