broadcast is using refreshUTXOs, so it should be protected by lock (#2061)

This commit is contained in:
Ori Newman 2022-05-25 01:16:54 +03:00 committed by GitHub
parent 24c94b38be
commit b84d6fed2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,6 @@ 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
@ -25,6 +22,8 @@ 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