mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-02-16 14:13:46 +00:00
wip
This commit is contained in:
parent
d7ca1b69de
commit
4accb0daab
@ -10,6 +10,8 @@ namespace CryptoExchange.Net.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISymbolOrderBook
|
public interface ISymbolOrderBook
|
||||||
{
|
{
|
||||||
|
Task ReconnectAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The exchange the book is for
|
/// The exchange the book is for
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -39,6 +39,7 @@ namespace CryptoExchange.Net.OrderBook
|
|||||||
private readonly AsyncResetEvent _queueEvent;
|
private readonly AsyncResetEvent _queueEvent;
|
||||||
private readonly ConcurrentQueue<object> _processQueue;
|
private readonly ConcurrentQueue<object> _processQueue;
|
||||||
private bool _validateChecksum;
|
private bool _validateChecksum;
|
||||||
|
private bool _firstUpdateAfterSnapshotDone;
|
||||||
|
|
||||||
private class EmptySymbolOrderBookEntry : ISymbolOrderBookEntry
|
private class EmptySymbolOrderBookEntry : ISymbolOrderBookEntry
|
||||||
{
|
{
|
||||||
@ -85,8 +86,10 @@ namespace CryptoExchange.Net.OrderBook
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool _sequencesAreConsecutive;
|
protected bool _sequencesAreConsecutive;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the first update message after a snapshot may have overlapping sequence numbers instead of the snapshot sequence number + 1
|
||||||
|
/// </summary>
|
||||||
protected bool _skipSequenceCheckFirstUpdateAfterSnapshotSet;
|
protected bool _skipSequenceCheckFirstUpdateAfterSnapshotSet;
|
||||||
private bool _firstUpdateAfterSnapshotDone;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether levels should be strictly enforced. For example, when an order book has 25 levels and a new update comes in which pushes
|
/// Whether levels should be strictly enforced. For example, when an order book has 25 levels and a new update comes in which pushes
|
||||||
@ -325,6 +328,11 @@ namespace CryptoExchange.Net.OrderBook
|
|||||||
await ResyncAsync().ConfigureAwait(false);
|
await ResyncAsync().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task ReconnectAsync()
|
||||||
|
{
|
||||||
|
_subscription.ReconnectAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task StopAsync()
|
public async Task StopAsync()
|
||||||
{
|
{
|
||||||
@ -989,7 +997,7 @@ namespace CryptoExchange.Net.OrderBook
|
|||||||
if (_sequencesAreConsecutive && startSequenceNumber != LastSequenceNumber + 1)
|
if (_sequencesAreConsecutive && startSequenceNumber != LastSequenceNumber + 1)
|
||||||
{
|
{
|
||||||
if (_firstUpdateAfterSnapshotDone || !_skipSequenceCheckFirstUpdateAfterSnapshotSet)
|
if (_firstUpdateAfterSnapshotDone || !_skipSequenceCheckFirstUpdateAfterSnapshotSet)
|
||||||
// Buffered update is not the next sequence number when it was expected
|
// Buffered update is not the next sequence number when it was expected to be
|
||||||
return SequenceNumberResult.OutOfSync;
|
return SequenceNumberResult.OutOfSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1000,6 +1008,7 @@ namespace CryptoExchange.Net.OrderBook
|
|||||||
private SequenceNumberResult ValidateLiveSequenceNumber(long sequenceNumber)
|
private SequenceNumberResult ValidateLiveSequenceNumber(long sequenceNumber)
|
||||||
{
|
{
|
||||||
if (sequenceNumber < LastSequenceNumber)
|
if (sequenceNumber < LastSequenceNumber)
|
||||||
|
// Update is somehow from before the current state
|
||||||
return SequenceNumberResult.OutOfSync;
|
return SequenceNumberResult.OutOfSync;
|
||||||
|
|
||||||
if (_sequencesAreConsecutive
|
if (_sequencesAreConsecutive
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user