infra/op-ufm/pkg/provider/tx_pool.go

41 lines
936 B
Go
Raw Normal View History

2023-07-12 22:23:52 +03:00
package provider
import (
"sync"
"time"
"github.com/ethereum/go-ethereum/common"
)
// TransactionPool is used locally to share transactions between providers under the same pool
type TransactionPool map[string]*NetworkTransactionPool
// NetworkTransactionPool is used locally to share transactions between providers under the same network
type NetworkTransactionPool struct {
M sync.Mutex
Transactions map[string]*TransactionState
Expected int
2023-09-07 01:08:09 +03:00
// Last time a transaction was sent
LastSend time.Time
2023-09-07 01:15:19 +03:00
// Prevents concurrent transaction send
ExclusiveSend sync.Mutex
2023-07-12 22:23:52 +03:00
}
type TransactionState struct {
// Transaction hash
Hash common.Hash
// Mutex
M sync.Mutex
SentAt time.Time
2023-07-18 20:21:19 +03:00
ProviderSource string
2023-07-12 22:23:52 +03:00
FirstSeen time.Time
// Map of providers that have seen this transaction, and when
// Once all providers have seen the transaction it is removed from the pool
SeenBy map[string]time.Time
}