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

Commit

Permalink
mark seen
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jan 31, 2024
1 parent fdfada9 commit 7a0f5e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cosmos/runtime/txpool/comet.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
// Comet CheckTX and when.
type CometRemoteCache interface {
IsRemoteTx(txHash common.Hash) bool
MarkRemoteSeen(txHash common.Hash)
MarkRemoteSeen(txHash common.Hash) bool
TimeFirstSeen(txHash common.Hash) int64 // Unix timestamp
}

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

// Record the time the tx was inserted from Comet successfully.
func (crc *cometRemoteCache) MarkRemoteSeen(txHash common.Hash) {
crc.timeInserted.Add(txHash, time.Now().Unix())
func (crc *cometRemoteCache) MarkRemoteSeen(txHash common.Hash) bool {
if !crc.timeInserted.Contains(txHash) {
crc.timeInserted.Add(txHash, time.Now().Unix())
return true
}
return false
}

func (crc *cometRemoteCache) TimeFirstSeen(txHash common.Hash) int64 {
Expand Down
4 changes: 2 additions & 2 deletions cosmos/runtime/txpool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (m *Mempool) Insert(ctx context.Context, sdkTx sdk.Tx) error {
}

// Add the eth tx to the remote cache.
m.crc.MarkRemoteSeen(ethTx.Hash())
_ = m.crc.MarkRemoteSeen(ethTx.Hash())

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

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

0 comments on commit 7a0f5e9

Please sign in to comment.