Skip to content
This repository was archived by the owner on Jun 9, 2024. It is now read-only.

Commit 7a0f5e9

Browse files
author
itsdevbear
committed
mark seen
1 parent fdfada9 commit 7a0f5e9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

cosmos/runtime/txpool/comet.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const (
3535
// Comet CheckTX and when.
3636
type CometRemoteCache interface {
3737
IsRemoteTx(txHash common.Hash) bool
38-
MarkRemoteSeen(txHash common.Hash)
38+
MarkRemoteSeen(txHash common.Hash) bool
3939
TimeFirstSeen(txHash common.Hash) int64 // Unix timestamp
4040
}
4141

@@ -56,8 +56,12 @@ func (crc *cometRemoteCache) IsRemoteTx(txHash common.Hash) bool {
5656
}
5757

5858
// Record the time the tx was inserted from Comet successfully.
59-
func (crc *cometRemoteCache) MarkRemoteSeen(txHash common.Hash) {
60-
crc.timeInserted.Add(txHash, time.Now().Unix())
59+
func (crc *cometRemoteCache) MarkRemoteSeen(txHash common.Hash) bool {
60+
if !crc.timeInserted.Contains(txHash) {
61+
crc.timeInserted.Add(txHash, time.Now().Unix())
62+
return true
63+
}
64+
return false
6165
}
6266

6367
func (crc *cometRemoteCache) TimeFirstSeen(txHash common.Hash) int64 {

cosmos/runtime/txpool/mempool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error {
140140
}
141141

142142
// Add the eth tx to the remote cache.
143-
m.crc.MarkRemoteSeen(ethTx.Hash())
143+
_ = m.crc.MarkRemoteSeen(ethTx.Hash())
144144

145145
return nil
146146
}
@@ -157,6 +157,6 @@ func (m *Mempool) Select(context.Context, [][]byte) mempool.Iterator {
157157
}
158158

159159
// Remove is an intentional no-op as the eth txpool handles removals.
160-
func (m *Mempool) Remove(tx sdk.Tx) error {
160+
func (m *Mempool) Remove(_ sdk.Tx) error {
161161
return nil
162162
}

0 commit comments

Comments
 (0)