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

Commit

Permalink
Merge pull request #78 from cowprotocol/block_range
Browse files Browse the repository at this point in the history
use more optimistic block range for sync
  • Loading branch information
fhenneke authored Feb 5, 2024
2 parents f4e3e5c + 8fdeb14 commit 85611db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/fetch/orderbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from src.models.block_range import BlockRange
from src.utils import open_query

REORG_THRESHOLD = 65
MAX_PROCESSING_DELAY = 10


class OrderbookEnv(Enum):
Expand Down Expand Up @@ -69,7 +69,9 @@ def get_latest_block(cls) -> int:
open_query("orderbook/latest_block.sql"), data_types
)
assert len(barn) == 1 == len(prod), "Expecting single record"
return min(int(barn["latest"][0]), int(prod["latest"][0])) - REORG_THRESHOLD
return (
max(int(barn["latest"][0]), int(prod["latest"][0])) - MAX_PROCESSING_DELAY
)

@classmethod
def get_order_rewards(cls, block_range: BlockRange) -> DataFrame:
Expand Down
3 changes: 2 additions & 1 deletion src/fetch/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from sqlalchemy import create_engine
from sqlalchemy.engine import Engine

from src.fetch.orderbook import REORG_THRESHOLD
from src.models.block_range import BlockRange
from src.utils import open_query

REORG_THRESHOLD = 65


@dataclass
class PostgresFetcher:
Expand Down

0 comments on commit 85611db

Please sign in to comment.