Skip to content

Commit 6f7372e

Browse files
committed
more cleanup
1 parent cca6048 commit 6f7372e

File tree

8 files changed

+13
-25
lines changed

8 files changed

+13
-25
lines changed

internal/consensus/state.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@ func (cs *State) buildProposalBlock(height int64, header types.Header, lastCommi
24212421
txs := cs.blockExec.GetTxsForKeys(txKeys)
24222422
block.Version = header.Version
24232423
block.Data.Txs = txs
2424-
block.DataHash = block.Data.Hash()
2424+
block.DataHash = block.Data.Hash(true)
24252425
block.Header.Time = header.Time
24262426
block.Header.ProposerAddress = header.ProposerAddress
24272427
return block

internal/mempool/reactor.go

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ func (r *Reactor) handleMempoolMessage(ctx context.Context, envelope *p2p.Envelo
120120
switch msg := envelope.Message.(type) {
121121
case *protomem.Txs:
122122
protoTxs := msg.GetTxs()
123-
//logger.Info("PSULOG - handling mempool message", "peer", envelope.From, "txs", protoTxs)
124123
if len(protoTxs) == 0 {
125124
return errors.New("empty txs received from peer")
126125
}

internal/state/execution.go

-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
143143
}
144144

145145
func (blockExec *BlockExecutor) GetTxsForKeys(txKeys []types.TxKey) types.Txs {
146-
//blockExec.logger.Info("PSULOG getting txs for keys", "txKeys", txKeys)
147146
return blockExec.mempool.GetTxsForKeys(txKeys)
148147
}
149148

@@ -420,7 +419,6 @@ func (blockExec *BlockExecutor) Commit(
420419
func (blockExec *BlockExecutor) GetMissingTxs(txKeys []types.TxKey) []types.TxKey {
421420
var missingTxKeys []types.TxKey
422421
for _, txKey := range txKeys {
423-
//blockExec.logger.Info("PSULOG - GetMissingTxs", "txKey", txKey, "hasTx", blockExec.mempool.HasTx(txKey))
424422
if !blockExec.mempool.HasTx(txKey) {
425423
missingTxKeys = append(missingTxKeys, txKey)
426424
}

rpc/client/http/http.go

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package http
33
import (
44
"context"
55
"errors"
6-
"fmt"
76
"net/http"
87
"time"
98

@@ -429,7 +428,6 @@ func (c *baseRPCClient) Commit(ctx context.Context, height *int64) (*coretypes.R
429428

430429
func (c *baseRPCClient) Tx(ctx context.Context, hash bytes.HexBytes, prove bool) (*coretypes.ResultTx, error) {
431430
result := new(coretypes.ResultTx)
432-
fmt.Println("Calling tx search")
433431
if err := c.caller.Call(ctx, "tx", &coretypes.RequestTx{Hash: hash, Prove: prove}, result); err != nil {
434432
return nil, err
435433
}

types/block.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (b *Block) ValidateBasic() error {
7575
}
7676

7777
// NOTE: b.Data.Txs may be nil, but b.Data.Hash() still works fine.
78-
if w, g := b.Data.Hash(), b.DataHash; !bytes.Equal(w, g) {
78+
if w, g := b.Data.Hash(false), b.DataHash; !bytes.Equal(w, g) {
7979
return fmt.Errorf("wrong Header.DataHash. Expected %X, got %X. Len of txs %d", w, g, len(b.Data.Txs))
8080
}
8181

@@ -99,7 +99,7 @@ func (b *Block) fillHeader() {
9999
b.LastCommitHash = b.LastCommit.Hash()
100100
}
101101
if b.DataHash == nil {
102-
b.DataHash = b.Data.Hash()
102+
b.DataHash = b.Data.Hash(false)
103103
}
104104
if b.EvidenceHash == nil {
105105
b.EvidenceHash = b.Evidence.Hash()
@@ -1298,13 +1298,16 @@ type Data struct {
12981298
}
12991299

13001300
// Hash returns the hash of the data
1301-
func (data *Data) Hash() tmbytes.HexBytes {
1301+
func (data *Data) Hash(overwrite bool) tmbytes.HexBytes {
13021302
if data == nil {
13031303
return (Txs{}).Hash()
13041304
}
1305-
//if data.hash == nil {
1306-
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
1307-
//}
1305+
if data.hash != nil && overwrite {
1306+
data.hash = data.Txs.Hash()
1307+
}
1308+
if data.hash == nil {
1309+
data.hash = data.Txs.Hash() // NOTE: leaves of merkle tree are TxIDs
1310+
}
13081311
return data.hash
13091312
}
13101313

types/events.go

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const (
3939
EventTimeoutWaitValue = "TimeoutWait"
4040
EventValidBlockValue = "ValidBlock"
4141
EventVoteValue = "Vote"
42-
EventNewProposal = "NewProposal"
4342

4443
// Events emitted by the evidence reactor when evidence is validated
4544
// and before it is committed

types/mempool.go

-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@ func (txKey *TxKey) ToProto() *tmproto.TxKey {
2828
return tp
2929
}
3030

31-
func TxKeysListToProto(txKeys []*TxKey) []*tmproto.TxKey {
32-
var tps []*tmproto.TxKey
33-
for _, txKey := range txKeys {
34-
tps = append(tps, txKey.ToProto())
35-
}
36-
return tps
37-
}
38-
3931
// TxKeyFromProto takes a protobuf representation of TxKey &
4032
// returns the native type.
4133
func TxKeyFromProto(dp *tmproto.TxKey) (TxKey, error) {

types/proposal.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,9 @@ func ProposalFromProto(pp *tmproto.Proposal) (*Proposal, error) {
217217
p.POLRound = pp.PolRound
218218
p.Timestamp = pp.Timestamp
219219
p.Signature = pp.Signature
220-
var txKeys []TxKey
221-
for _, txKey := range pp.TxKeys {
222-
key, _ := TxKeyFromProto(txKey)
223-
txKeys = append(txKeys, key)
220+
txKeys, err := TxKeysListFromProto(pp.TxKeys)
221+
if err != nil {
222+
return nil, err
224223
}
225224
p.TxKeys = txKeys
226225
header, err := HeaderFromProto(&pp.Header)

0 commit comments

Comments
 (0)