Skip to content

Commit

Permalink
apply PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
p4u committed Oct 10, 2023
1 parent 1ebc33e commit b072fdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tree/arbo/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var (

// Tree defines the struct that implements the MerkleTree functionalities
type Tree struct {
sync.RWMutex
sync.Mutex

db db.Database
maxLevels int
Expand Down Expand Up @@ -521,8 +521,8 @@ func (t *Tree) Get(k []byte) ([]byte, []byte, error) {
// ErrKeyNotFound, and in the leafK & leafV parameters will be placed the data
// found in the tree in the leaf that was on the path going to the input key.
func (t *Tree) GetWithTx(rTx db.Reader, k []byte) ([]byte, []byte, error) {
t.RLock()
defer t.RUnlock()
t.Lock()
defer t.Unlock()

keyPath, err := keyPathFromKey(t.maxLevels, k)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions vochain/cometbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ func (app *BaseApplication) PrepareProposal(ctx context.Context,
Nonce uint32
DecodedTx *vochaintx.Tx
}
// Rollback the state to discard previous non saved changes
// Rollback the state to discard previous non saved changes.
// It might happen if ProcessProposal fails and then this node is selected for preparing the next proposal.
app.State.Rollback()

// Get and execute transactions from the mempool
Expand Down Expand Up @@ -324,10 +325,10 @@ func (app *BaseApplication) PrepareProposal(ctx context.Context,
return false
}
if validTxInfos[i].Addr != nil && validTxInfos[j].Addr != nil {
if validTxInfos[i].Addr.String() == validTxInfos[j].Addr.String() {
if bytes.Equal(validTxInfos[i].Addr.Bytes(), validTxInfos[j].Addr.Bytes()) {
return validTxInfos[i].Nonce < validTxInfos[j].Nonce
}
return validTxInfos[i].Addr.String() < validTxInfos[j].Addr.String()
return bytes.Compare(validTxInfos[i].Addr.Bytes(), validTxInfos[j].Addr.Bytes()) == -1
}
return false
})
Expand Down

0 comments on commit b072fdb

Please sign in to comment.