Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: temporarily disable registry writting on chunks #160

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/domain/polling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const API_ERRORS_DROP: DropApiErrorsArray = [
// ApiErrors.IncompatibleSigningScheme - we control this in the watch-tower
// ApiErrors.AppDataHashMismatch - we never submit full appData

const CHUNK_SIZE = 20; // How many orders to process before saving
const CHUNK_SIZE = 50; // How many orders to process before saving

/**
* Watch for new blocks and check for orders to place
Expand All @@ -115,6 +115,7 @@ export async function checkForAndPlaceOrder(
let hasErrors = false;
let ownerCounter = 0;
let orderCounter = 0;
let updatedCount = 0;

const log = getLogger(
"checkForAndPlaceOrder:checkForAndPlaceOrder",
Expand All @@ -140,13 +141,13 @@ export async function checkForAndPlaceOrder(
orderCounter++;

// Check if we reached the chunk size
if (orderCounter % CHUNK_SIZE === 1 && orderCounter > 1) {
if (updatedCount % CHUNK_SIZE === 1 && updatedCount > 1) {
// Delete orders pending delete, if any
_deleteOrders(ordersPendingDelete, conditionalOrders, log, chainId);
// Reset tracker
ordersPendingDelete = [];

log.debug(`Processed ${orderCounter}, saving registry`);
log.debug(`Processed ${updatedCount}, saving registry`);

// Save the registry after processing each chunk
await registry.write();
Expand Down Expand Up @@ -231,6 +232,8 @@ export async function checkForAndPlaceOrder(
blockNumber: blockNumber,
result: pollResult,
};
// Order needs saving!
updatedCount++;

// Log the result
const unexpectedError =
Expand Down Expand Up @@ -290,6 +293,8 @@ function _deleteOrders(
log: LoggerWithMethods,
chainId: SupportedChainId
) {
log.debug(`${ordersPendingDelete.length} to delete`);

for (const conditionalOrder of ordersPendingDelete) {
const deleted = conditionalOrders.delete(conditionalOrder);
const action = deleted ? "Stop Watching" : "Failed to stop watching";
Expand Down
Loading