Wrap the entire wallet send operation with a lock (#2063)

This commit is contained in:
Michael Sutton 2022-05-25 08:55:35 +03:00 committed by GitHub
parent b84d6fed2c
commit cd5fd86ad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -13,6 +13,9 @@ import (
)
func (s *server) Broadcast(_ context.Context, request *pb.BroadcastRequest) (*pb.BroadcastResponse, error) {
s.lock.Lock()
defer s.lock.Unlock()
txIDs, err := s.broadcast(request.Transactions, request.IsDomain)
if err != nil {
return nil, err
@ -22,8 +25,6 @@ func (s *server) Broadcast(_ context.Context, request *pb.BroadcastRequest) (*pb
}
func (s *server) broadcast(transactions [][]byte, isDomain bool) ([]string, error) {
s.lock.Lock()
defer s.lock.Unlock()
txIDs := make([]string, len(transactions))
var tx *externalapi.DomainTransaction

View File

@ -7,10 +7,14 @@ import (
)
func (s *server) Send(_ context.Context, request *pb.SendRequest) (*pb.SendResponse, error) {
s.lock.Lock()
defer s.lock.Unlock()
unsignedTransactions, err := s.createUnsignedTransactions(request.ToAddress, request.Amount, request.From)
if err != nil {
return nil, err
}
signedTransactions, err := s.signTransactions(unsignedTransactions, request.Password)
if err != nil {
return nil, err