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

Commit

Permalink
Remove expirationwatch package
Browse files Browse the repository at this point in the history
  • Loading branch information
albrow committed May 20, 2020
1 parent 8197b82 commit 82818fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 307 deletions.
96 changes: 29 additions & 67 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/0xProject/0x-mesh/ethereum/blockwatch"
"github.com/0xProject/0x-mesh/ethereum/ethrpcclient"
"github.com/0xProject/0x-mesh/ethereum/ratelimit"
"github.com/0xProject/0x-mesh/expirationwatch"
"github.com/0xProject/0x-mesh/keys"
"github.com/0xProject/0x-mesh/loghooks"
"github.com/0xProject/0x-mesh/orderfilter"
Expand Down Expand Up @@ -188,31 +187,22 @@ type Config struct {
EthereumRPCClient ethclient.RPCClient `envvar:"-"`
}

type snapshotInfo struct {
// Snapshot *db.Snapshot
CreatedAt time.Time
ExpirationTimestamp time.Time
}

type App struct {
config Config
privateConfig privateConfig
peerID peer.ID
privKey p2pcrypto.PrivKey
node *p2p.Node
chainID int
blockWatcher *blockwatch.Watcher
orderWatcher *orderwatch.Watcher
orderValidator *ordervalidator.OrderValidator
orderFilter *orderfilter.Filter
snapshotExpirationWatcher *expirationwatch.Watcher
muIdToSnapshotInfo sync.Mutex
idToSnapshotInfo map[string]snapshotInfo
ethRPCRateLimiter ratelimit.RateLimiter
ethRPCClient ethrpcclient.Client
db *db.DB
ordersyncService *ordersync.Service
contractAddresses *ethereum.ContractAddresses
config Config
privateConfig privateConfig
peerID peer.ID
privKey p2pcrypto.PrivKey
node *p2p.Node
chainID int
blockWatcher *blockwatch.Watcher
orderWatcher *orderwatch.Watcher
orderValidator *ordervalidator.OrderValidator
orderFilter *orderfilter.Filter
ethRPCRateLimiter ratelimit.RateLimiter
ethRPCClient ethrpcclient.Client
db *db.DB
ordersyncService *ordersync.Service
contractAddresses *ethereum.ContractAddresses

// started is closed to signal that the App has been started. Some methods
// will block until after the App is started.
Expand Down Expand Up @@ -376,26 +366,21 @@ func newWithPrivateConfig(config Config, pConfig privateConfig) (*App, error) {
return nil, fmt.Errorf("invalid custom order filter: %s", err.Error())
}

// Initialize remaining fields.
snapshotExpirationWatcher := expirationwatch.New()

app := &App{
started: make(chan struct{}),
config: config,
privateConfig: pConfig,
privKey: privKey,
peerID: peerID,
chainID: config.EthereumChainID,
blockWatcher: blockWatcher,
orderWatcher: orderWatcher,
orderValidator: orderValidator,
orderFilter: orderFilter,
snapshotExpirationWatcher: snapshotExpirationWatcher,
idToSnapshotInfo: map[string]snapshotInfo{},
ethRPCRateLimiter: ethRPCRateLimiter,
ethRPCClient: ethClient,
db: database,
contractAddresses: &contractAddresses,
started: make(chan struct{}),
config: config,
privateConfig: pConfig,
privKey: privKey,
peerID: peerID,
chainID: config.EthereumChainID,
blockWatcher: blockWatcher,
orderWatcher: orderWatcher,
orderValidator: orderValidator,
orderFilter: orderFilter,
ethRPCRateLimiter: ethRPCRateLimiter,
ethRPCClient: ethClient,
db: database,
contractAddresses: &contractAddresses,
}

log.WithFields(map[string]interface{}{
Expand Down Expand Up @@ -525,29 +510,6 @@ func (app *App) Start(ctx context.Context) error {
ethRPCRateLimiterErrChan <- app.ethRPCRateLimiter.Start(innerCtx, rateLimiterCheckpointInterval)
}()

// Set up the snapshot expiration watcher pruning logic
wg.Add(1)
go func() {
defer wg.Done()
defer func() {
log.Debug("closing snapshot expiration watcher")
}()
ticker := time.NewTicker(expirationPollingInterval)
for {
select {
case <-innerCtx.Done():
return
case now := <-ticker.C:
expiredSnapshots := app.snapshotExpirationWatcher.Prune(now)
for _, expiredSnapshot := range expiredSnapshots {
app.muIdToSnapshotInfo.Lock()
delete(app.idToSnapshotInfo, expiredSnapshot.ID)
app.muIdToSnapshotInfo.Unlock()
}
}
}
}()

// Start the order watcher.
orderWatcherErrChan := make(chan error, 1)
wg.Add(1)
Expand Down
103 changes: 0 additions & 103 deletions expirationwatch/expiration_watcher.go

This file was deleted.

137 changes: 0 additions & 137 deletions expirationwatch/expiration_watcher_test.go

This file was deleted.

0 comments on commit 82818fa

Please sign in to comment.