libs: wrap mutexes for build flag with godeadlock (#5126)

## Description

This PR wraps the stdlib sync.(RW)Mutex & godeadlock.(RW)Mutex. This enables using go-deadlock via a build flag instead of using sed to replace sync with godeadlock in all files

Closes: #3242
This commit is contained in:
Marko
2020-07-20 09:55:09 +02:00
committed by GitHub
parent 8cdb53c811
commit 2ac5a559b4
61 changed files with 182 additions and 145 deletions

View File

@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"strings"
"sync"
"time"
"github.com/gogo/protobuf/proto"
@@ -17,6 +16,7 @@ import (
"github.com/tendermint/tendermint/libs/bits"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
tmmath "github.com/tendermint/tendermint/libs/math"
tmsync "github.com/tendermint/tendermint/libs/sync"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
)
@@ -38,7 +38,7 @@ const (
// Block defines the atomic unit of a Tendermint blockchain.
type Block struct {
mtx sync.Mutex
mtx tmsync.Mutex
Header `json:"header"`
Data `json:"data"`

View File

@@ -5,13 +5,13 @@ import (
"errors"
"fmt"
"io"
"sync"
"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/libs/bits"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
tmjson "github.com/tendermint/tendermint/libs/json"
tmmath "github.com/tendermint/tendermint/libs/math"
tmsync "github.com/tendermint/tendermint/libs/sync"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
@@ -141,7 +141,7 @@ type PartSet struct {
total uint32
hash []byte
mtx sync.Mutex
mtx tmsync.Mutex
parts []*Part
partsBitArray *bits.BitArray
count uint32

View File

@@ -4,10 +4,10 @@ import (
"bytes"
"fmt"
"strings"
"sync"
"github.com/tendermint/tendermint/libs/bits"
tmjson "github.com/tendermint/tendermint/libs/json"
tmsync "github.com/tendermint/tendermint/libs/sync"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
@@ -65,7 +65,7 @@ type VoteSet struct {
signedMsgType tmproto.SignedMsgType
valSet *ValidatorSet
mtx sync.Mutex
mtx tmsync.Mutex
votesBitArray *bits.BitArray
votes []*Vote // Primary votes to share
sum int64 // Sum of voting power for seen votes, discounting conflicts