Example #1
0
 public bool Equals(CommittedBlock other)
 {
     return(BlockHeight.Equals(other.BlockHeight) &&
            Alias.Equals(other.Alias) &&
            Parent.Equals(other.Parent) &&
            BlockId.Equals(other.BlockId));
 }
Example #2
0
    public async Task Rewind(uint height)
    {
        var req = new BlockHeight();

        req.Height = height;
        await client.RewindAsync(req);
    }
Example #3
0
        public string ToFullLine()
        {
            var builder = new StringBuilder();

            builder.Append(BlockHeight.ToString());
            builder.Append(":");
            builder.Append(BlockHash);
            if (Filter != null)             // bech found here
            {
                builder.Append(":");
                builder.Append(Filter);
            }

            return(builder.ToString());
        }
Example #4
0
        public override int GetHashCode()
        {
            unchecked
            {
                var baseHashCode = base.GetHashCode();

                var hashCode = baseHashCode;
                hashCode = (hashCode * 397) ^ Index;
                hashCode = (hashCode * 397) ^ (BlockHash != null ? BlockHash.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ BlockHeight.GetHashCode();
                hashCode = (hashCode * 397) ^ (BlockTime != null ? BlockTime.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Confirmations;
                return(hashCode);
            }
        }
Example #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (BlockHeight != 0L)
            {
                hash ^= BlockHeight.GetHashCode();
            }
            if (tokenHash_ != null)
            {
                hash ^= TokenHash.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #6
0
        public WebsocketClient(Network network)
        {
            var networkEnv = BinanceEnvironment.GetEnvironment(network);

            _ws = new WebSocket(networkEnv.WssApiAddress);
            _ws.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;
            _ws.EmitOnPing = true;

            _ws.OnMessage += _ws_OnMessage;
            _ws.OnError   += _ws_OnError;

            BlockHeight          = new BlockHeight(this);
            AllMiniTicker        = new AllMiniTicker(this);
            IndividualMiniTicker = new IndividualMiniTicker(this);
            AllTicker            = new AllTicker(this);
            IndividualTicker     = new IndividualTicker(this);
            Klines    = new Klines(this);
            BookDepth = new BookDepth(this);
            DiffDepth = new DiffDepth(this);
            Trades    = new Trades(this);
            Transfer  = new Transfer(this);
            Account   = new Account(this);
            Orders    = new Orders(this);
        }
Example #7
0
 public override string ToString()
 => $"{BlockHeight.ToString(CultureInfo.InvariantCulture)}:{BlockIndex.ToString(CultureInfo.InvariantCulture)}:{TxOutIndex.ToString(CultureInfo.InvariantCulture)}";
Example #8
0
 /// <summary>
 /// Performs a comparison and return if compared values are equal, greater or less than the other one
 /// </summary>
 /// <param name="other">The blockheight to compare against.</param>
 /// <returns>0 if this an other are equal, -1 if this is less than other and 1 if this is greater than other.</returns>
 public int CompareTo(BlockState other) => BlockHeight.CompareTo(other.BlockHeight);
Example #9
0
 private void _ws_OnMessage(object sender, MessageEventArgs e)
 {
     //Pre-parsing message. Doesn't fully deserialize now to dynamic to improve performance
     if (e.Data.StartsWith("{\"stream\":\"orders\""))
     {
         Orders.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"trades\""))
     {
         Trades.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"accounts\""))
     {
         Account.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"marketDiff\""))
     {
         DiffDepth.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"marketDepth\""))
     {
         BookDepth.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"blockheight\""))
     {
         BlockHeight.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"allMiniTickers\""))
     {
         AllMiniTicker.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"miniTicker\""))
     {
         IndividualMiniTicker.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"allTickers\""))
     {
         AllTicker.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"ticker\""))
     {
         IndividualTicker.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"kline_"))
     {
         Klines.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"transfers\""))
     {
         Transfer.ProcessRecievedMessage(e.Data);
     }
     else if (e.Data.StartsWith("{\"stream\":\"transfers\""))
     {
         Transfer.ProcessRecievedMessage(e.Data);
     }
     else if (!string.IsNullOrWhiteSpace(e.Data))
     {
         //We might received an error text from backend, have to raise attention if so.
         if (e.Data.Contains("error"))
         {
             throw new WebSocketConnectionException(string.Format("Websocket DEX backend sent error message: {0}", e.Data));
         }
     }
 }