Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
lint:
runs-on: [self-hosted, Linux, Build]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python 3.13
Expand All @@ -28,7 +28,7 @@ jobs:
run: mypy bfxapi/

test:
runs-on: [self-hosted, Linux, Build]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python 3.13
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot-reviewer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ permissions:

jobs:
request:
uses: CloudIngenium/.github/.github/workflows/request-copilot-review.yml@main
uses: CloudIngenium/.github/.github/workflows/request-copilot-review.yml@24fac1de6a37800bae89a7b4f858742c7a455043
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ concurrency:
jobs:
gitleaks:
name: Secret Scan
runs-on: [self-hosted, Linux, Build]
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/socket-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ concurrency:
cancel-in-progress: true
jobs:
socket:
uses: CloudIngenium/.github/.github/workflows/socket-security.yml@main
uses: CloudIngenium/.github/.github/workflows/socket-security.yml@24fac1de6a37800bae89a7b4f858742c7a455043
secrets: inherit
30 changes: 15 additions & 15 deletions bfxapi/rest/_interface/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@
from enum import IntEnum
from typing import TYPE_CHECKING, Any, NoReturn

_NONCE_LOCK = threading.Lock()
_NONCE_LAST = 0


def _next_nonce() -> str:
"""Monotonic microsecond nonce. Guards against duplicates when two calls
hit the same microsecond tick under concurrent use (H8 fix)."""
global _NONCE_LAST
with _NONCE_LOCK:
candidate = time.time_ns() // 1_000
if candidate <= _NONCE_LAST:
candidate = _NONCE_LAST + 1
_NONCE_LAST = candidate
return str(candidate)

import requests

from bfxapi._utils.json_decoder import JSONDecoder
Expand All @@ -39,6 +24,21 @@ def _next_nonce() -> str:
if TYPE_CHECKING:
from requests.sessions import _Params

_NONCE_LOCK = threading.Lock()
_NONCE_LAST = 0


def _next_nonce() -> str:
"""Monotonic microsecond nonce. Guards against duplicates when two calls
hit the same microsecond tick under concurrent use (H8 fix)."""
global _NONCE_LAST
with _NONCE_LOCK:
candidate = time.time_ns() // 1_000
if candidate <= _NONCE_LAST:
candidate = _NONCE_LAST + 1
_NONCE_LAST = candidate
return str(candidate)


@dataclass
class RateLimitInfo:
Expand Down
11 changes: 3 additions & 8 deletions bfxapi/websocket/_handlers/auth_events_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class AuthEventsHandler:
}

__SERIALIZERS: dict[str, _Serializer[Any]] = {
abbr: ser
for abbrs, ser in _GROUPED.items()
for abbr in abbrs
abbr: ser for abbrs, ser in _GROUPED.items() for abbr in abbrs
}

def __init__(self, event_emitter: EventEmitter) -> None:
Expand All @@ -79,12 +77,9 @@ def handle(self, abbrevation: str, stream: Any) -> None:
if serializer is not None:
event = AuthEventsHandler.__ABBREVIATIONS[abbrevation]

if all(
isinstance(sub_stream, list) for sub_stream in stream
):
if all(isinstance(sub_stream, list) for sub_stream in stream):
data: Any = [
serializer.parse(*sub_stream)
for sub_stream in stream
serializer.parse(*sub_stream) for sub_stream in stream
]
else:
data = serializer.parse(*stream)
Expand Down
Loading