<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bearle on Medium]]></title>
        <description><![CDATA[Stories by Bearle on Medium]]></description>
        <link>https://medium.com/@bearle?source=rss-daabf1955576------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uKYvjXA_GHDEP0TawvV_rQ.jpeg</url>
            <title>Stories by Bearle on Medium</title>
            <link>https://medium.com/@bearle?source=rss-daabf1955576------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 21:36:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bearle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why IDEX is centralized and why should you care]]></title>
            <link>https://medium.com/@bearle/why-idex-is-centralized-and-why-should-you-care-193180fc5a87?source=rss-daabf1955576------2</link>
            <guid isPermaLink="false">https://medium.com/p/193180fc5a87</guid>
            <category><![CDATA[decentralized-exchange]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Bearle]]></dc:creator>
            <pubDate>Sat, 05 May 2018 09:13:30 GMT</pubDate>
            <atom:updated>2018-05-05T09:13:30.890Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I’ve tried to trade on IDEX ‘decentralized’ exchange (<a href="https://idex.market/">https://idex.market</a>). I’ve discovered that although it appears to be decentralized, it is in fact almost entirely centralized — and with currently ‘always in maintenance’ website, it really became a problem.</p><blockquote>Note: in this story i’ll refer to different functions of IDEX smart contract, which you can read on etherscan (<a href="https://etherscan.io/address/0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208#code">https://etherscan.io/address/0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208#code</a>) and which is described in IDEX API docs (<a href="https://github.com/AuroraDAO/idex-api-docs">https://github.com/AuroraDAO/idex-api-docs</a>).</blockquote><p>What am I talking about? Well, first of all, you have to <strong>deposit tokens or ether </strong>to begin trading — that means, using one of ‘deposit’ or ‘deposit token’ functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NP3fr41VpQxiyV0PO0mA-g.jpeg" /><figcaption>depositToken &amp; deposit function of IDEX smart contract</figcaption></figure><p>Note the <strong>lastActiveTransaction</strong> variable here. What it does is it saves the block number that <strong>deposit</strong> occured on.</p><p>The very same variable is assigned the block number in the <strong>trade</strong> function as well.</p><p>What happens next is you want to withdraw your tokens or ether from the exchange, and that’s what leads us to the interesting part. You see, the contract actually has two different function for withdrawing: <strong>withdraw</strong> and <strong>adminWithdraw. </strong>The one actually used when you click ‘withdraw’ on the website is adminWithdraw, and there’s a reason for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPA3uJEM3MzNp6coSTcOjQ.jpeg" /><figcaption>Withdraw transaction, executed using the website.</figcaption></figure><p>Let’s first look at the <strong>withdraw</strong> function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BHH4NuR2sINkRNuASKe2A.jpeg" /><figcaption>Withdraw function from the IDEX smart contract</figcaption></figure><p>Let’s look at the very first line: it’s a condition which check that current block number minus <strong>lastActiveTransaction</strong> block is <strong>SMALLER</strong> than <strong>inactivityReleasePeriod</strong> (which is set by admin using <strong>setInactivityReleasePeriod</strong> function) and is currently set to 100 000 blocks.</p><p>I.e. i deposited the tokens at 5557079, and i want to withdraw them at block 5557179. That means 5557179–5557079=100 which is &lt; than 100 000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*A6NG750KTHL22FpNjoJtYQ.jpeg" /><figcaption>inactivityReleasePeriod</figcaption></figure><p>If that condition is not met, the transaction fails. What that means is the following:</p><h3><strong>If you have executed any of the </strong><em>deposit, depositToken, trade</em><strong> functions in the last 100 000 blocks, you can’t withdraw your funds yourself!</strong></h3><p>How long does it take to mine 100 000 blocks, you ask? Well, according to average block time as of may 2018 (<a href="https://etherscan.io/chart/blocktime">https://etherscan.io/chart/blocktime</a>) is roughly 15 seconds. 15 seconds is 0.25 of a minute, that means <strong>4 blocks a minute</strong>, and that means <strong>25 000 minutes</strong> or nearly <strong>416.6 hours</strong> or <strong>17.361 </strong>days! Well, that’s a lot of time for a cryptocurrency prices to change.</p><p>‘But why can i withdraw then?’ — you could ask. It’s pretty simple: everything is handled using <strong>adminWithdraw</strong> function without such a restriction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WTWE9exfTIQNEQeb4WwECg.jpeg" /><figcaption>adminWithdraw function from the IDEX smart contract</figcaption></figure><p>What actually happens is when you press the withdraw button on the website and sign the transaction, a request is fired to some backend, which signs your transaction with the admin’s private key (because of the <strong>onlyAdmin</strong> modifier) and sends it out to the blockchain.</p><h3>Is that decentralized? I don’t think so.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=193180fc5a87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django Chat app — 2017 approach]]></title>
            <link>https://medium.com/@bearle/django-chat-app-2017-approach-6be1ff17ad6a?source=rss-daabf1955576------2</link>
            <guid isPermaLink="false">https://medium.com/p/6be1ff17ad6a</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[asyncio]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Bearle]]></dc:creator>
            <pubDate>Sun, 12 Feb 2017 16:27:43 GMT</pubDate>
            <atom:updated>2017-02-12T16:27:43.069Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QB47U8w7lv5e0qIj3aTxsw.jpeg" /><figcaption>Chat windows next to each other</figcaption></figure><p>App itself — <a href="https://github.com/Bearle/django-private-chat">https://github.com/Bearle/django-private-chat</a></p><p>Recently, me and my team came across a problem of lacking django chat applications. There are several good examples, but they are either intended for chatroom-like use or are outdated. So we decided to create our own chat.<br>First off, we thought about server-client communications — basically, there are websockets and there is jquery-ajax approach. <br>Of course, we chose websockets, because we could use the new python3.4 + async stuff and we didn’t want our app to make tons of useless state-check requests to the server. Also, websockets work instantly — opposing to ajax approach, which can only pull data every N milliseconds.<br>That said, we went searching for an example — and we found <a href="https://github.com/SimplyAhmazing/chat-app">https://github.com/SimplyAhmazing/chat-app</a></p><p>It looked almost like what we were going to implement, and it even had some code that was later used to do online/offline status and ‘is-typing’ feature.<br>We began with writing some code for our models — Dialog and Message.<br>Two users are having a chat (Dialog) and they are sending each other Messages. Dialog has .messages field, an owner field (the user who started the chat) and opponent field (the user who the owner is chatting with).</p><p>Then, we wrote our views — in fact, only a single one. The design is similar to Telegram on desktop, that said — we had only DialogListView with messages of the current dialog popping from active_dialog variable.<br>Also, we wrote two urls — one for displaying dialog list on the left and a dialog with specific user on the right, and the other — for general dialog list overview as well as top-most dialog.</p><p>Due to the fact that our solution relies heavily on Django’s users system and session particularly, we added the LoginRequiredMixin from excellent django-braces.</p><p>The template is pretty straightforward — get dialog list, display it, get active_dialog, display it too. Although in the example app we have also UserList view, we decided not to include it in the actual app because the developer might want to display users differently.</p><p>Our app’s development has just started and we, developers of Django Private Chat, hope that it will be enhanced in the future and used by others.<br>Thanks for your attention!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6be1ff17ad6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>