2023-07-12 12:23:52 -07: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-06 15:08:09 -07:00
|
|
|
|
|
|
|
// Last time a transaction was sent
|
|
|
|
LastSend time.Time
|
2023-09-06 15:15:19 -07:00
|
|
|
// Prevents concurrent transaction send
|
|
|
|
ExclusiveSend sync.Mutex
|
2023-07-12 12:23:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
type TransactionState struct {
|
|
|
|
// Transaction hash
|
|
|
|
Hash common.Hash
|
|
|
|
|
|
|
|
// Mutex
|
|
|
|
M sync.Mutex
|
|
|
|
|
2023-07-13 16:09:56 -07:00
|
|
|
SentAt time.Time
|
2023-07-18 10:21:19 -07:00
|
|
|
ProviderSource string
|
2023-07-12 12:23:52 -07: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
|
|
|
|
}
|