<?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"><channel><title><![CDATA[E-Space]]></title><description><![CDATA[IS IT POSSIBLE TO LEARN THIS POWER ¿?]]></description><link>https://blog.ebode.dev</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1674093325605/FxxBV9C2x.png</url><title>E-Space</title><link>https://blog.ebode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 08:39:39 GMT</lastBuildDate><atom:link href="https://blog.ebode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to improve your whatsapp status quality]]></title><description><![CDATA[Let's keep this simple and straight to the point. You want to know what I found, I also want to share this. But hey, I would not only tell you just that though, I like to geek about the technicals, you would have to hear that as well. So, it's a 2-fo...]]></description><link>https://blog.ebode.dev/improve-whatsapp-status-upload-quality</link><guid isPermaLink="true">https://blog.ebode.dev/improve-whatsapp-status-upload-quality</guid><category><![CDATA[whatsapp]]></category><category><![CDATA[WhatsApp Tips]]></category><category><![CDATA[Computer Science]]></category><category><![CDATA[Technical writing ]]></category><category><![CDATA[software architecture]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Thu, 22 Feb 2024 03:07:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1708571457974/73c1417e-e801-4367-9626-36940f2d8248.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's keep this simple and straight to the point. You want to know what I found, I also want to share this. But hey, I would not only tell you just that though, I like to geek about the technicals, you would have to hear that as well. So, it's a 2-for-1 treat tonight. Let's get right into it.</p>
<h3 id="heading-why-is-this-possible-now">Why is this possible now?</h3>
<p>One primary reason why this is now possible and wasn't before, is because Whatsapp introduced the HD media file-transfer feature.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708510500922/5cff10b0-c6ec-4ad9-8c16-87c63e6a9241.png" alt class="image--center mx-auto" /></p>
<p>Around mid to late last year, Whatsapp introduced the HD transfer feature allowing users send images, videos or any other files at a higher quality by enabling the HD option when sending.</p>
<p>The <a target="_blank" href="https://www.theverge.com/2023/8/17/23835641/whatsapp-hd-photo-video-compression">Verge</a> and <a target="_blank" href="https://techcrunch.com/2023/08/17/whatsapp-adds-support-for-hd-photos-says-hd-video-coming-soon/">Techcrunch</a> provided more information about that update when it was released. You can check it out if you are interested in that.</p>
<p>HD stands for High Definition, this means the media(image or picture) is at a higher resolution as compared to SD(Standard Definition) or other lesser media resolution/quality. This makes it look better. It is not the best quality there is, but it is an improvement to what has always been offered by Whatsapp.</p>
<p>In a previous <a target="_blank" href="https://ebode.hashnode.dev/whatsapp-quality-reduction">article</a>, I explained why Whatsapp reduces the quality of files you transfer, and how it saves them into the millions, of dollars in running costs annually. Reading that should help you understand that this new feature comes at some cost to Whatsapp and why they can't just give the highest and best file transfer quality.</p>
<p>The higher quality status update workaround involves using this HD feature provided by Whatsapp for sending files.This improves quality by around x2 to x5 depending on the file type.</p>
<h3 id="heading-the-workaround">The workaround</h3>
<p><strong>- First Approach (Failed)</strong></p>
<p>I tried two different approach to achieve this, the first failed. It seemed like Whatsapp figured what I was trying to do, and ignored the fact that I had set the image to HD, it compressed the hell out of the file as usual and posted it to my status without any improvement in the quality.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708512078111/d1facb54-fb64-4b98-9c1a-61af2f9c34d6.png" alt class="image--center mx-auto" /></p>
<p>The image above shows the approach to the first failed attempt to improve status quality.</p>
<p><strong>- Second Approach (Passed)</strong></p>
<p>I know Whatsapp does some message and media management, and tries to be efficient with those, by not letting you upload the exact same file over and over to their server, therefore using up unnecessary storage space, which can quickly add up.</p>
<p>They do a type of file caching(I would get into that later), to avoid storing duplicate file on their server. This caching approach is what made this approach work.</p>
<p>Let's get into that. The steps to recreate this is shown below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708520918450/7700d75f-e856-46ea-9112-38ed5eca700f.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>Click the "add a contact to text" (button), you can actually send a message to yourself which is the least disruptive option.</p>
</li>
<li><p>The first option in there is to "message yourself", which is what we would use. This was officially introduced last year also.</p>
</li>
<li><p>You click the "add media" button, which is how you select the HD version of the file you want to send, and send it to yourself.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708615754807/f12da442-bf9b-48f3-b59b-377ca56aab8b.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>I have selected an image and clicked the HD icon, to give it the best quality available.</p>
</li>
<li><p>I send this image to myself in the DM, a lot happens behind the scene with just this action, but we would get to that later.</p>
</li>
<li><p>This shows the HD image tag on the image to show the quality is HD.</p>
</li>
<li><p>I click on the forward button for that same picture I just sent internally.</p>
</li>
<li><p>On the forward option, I select to my status.</p>
</li>
<li><p>This provides a box where I can add a "caption" for that image.</p>
</li>
</ol>
<p>The last slide shows that the image has been successfully uploaded to my status at the HD resolution quality, as opposed to just sharing the image without this option.</p>
<p>Posting this way to your status can be done for any media type allowed by Whatsapp.</p>
<h3 id="heading-how-do-you-know-this-works"><strong>How do you know this works?</strong></h3>
<p>Ahhh yes! This is a very valid question. The image above is assumed to be of better quality, but how can this be proven?</p>
<p>To prove that this approach to updating media on Whatsapp actually improves the quality, there are two tests involved, the visual and size test.</p>
<p><strong>Visual Test</strong></p>
<ul>
<li><p>For the visual test, all I have to do is post the same images side by side, with the first using the HD upload method, and the other,the regular status upload method we are all used to.</p>
</li>
<li><p>Unfortunately, I would not be able to highlight the differences on here, this is due to the fact that, this platform(hashnode) performs its image compression when uploaded here, this would tamper with the quality of the images being compared and make it very hard to make out any difference. But you can do this yourself and find the difference.</p>
</li>
</ul>
<p><strong>Size Test</strong></p>
<p>This is where we can correctly confirm and prove there is difference in quality. Getting to this, you first need to know that the higher the quality of a media, the larger its size. For example, a regular quality picture may be around 1Megabyte(1 MB) in size, while that same image looking sharper and with higher resolution would "<strong>most likely"</strong> be larger in size, around 1.5 to 3Megabytes(1.5-3MB).</p>
<p>Take note of the fact I said most likely, not always, there are compression algorithms out there that could reduce the size of a media file and leave the quality as good as it orignally was, this is called a lossless compression, those defy this logic.</p>
<p>To show the size differences in the images and videos I uploaded images and videos to my Whatsapp status with the two different approach and pointed out the size differences.</p>
<blockquote>
<p>This section was powered by <strong>Adunni's</strong> device.</p>
</blockquote>
<p>To get the sizes of the files, you need to know that every Whatsapp status you ever view has to be downloaded off Whatsapp's server and saved on your device for 24hrs or for as long as the poster keeps it up.</p>
<p>To achieve this, I posted this to my status and investigated the size of the files.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708559056050/5c66379f-b06e-47b1-91d0-6ef513d5fe25.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p><strong>Arrow 1</strong> points to the size of the first image posted to Whatsapp status without the HD approach. This is how we mostly post status everyday, the regular way. The size of the image is around <strong>93.61 KiloBytes</strong>, with its size and quality reduced by Whatsapp's in-app compression algorithm.</p>
</li>
<li><p><strong>Arrow 2</strong> points to the size of the second image posted to status using the HD method. The size is around <strong>548 Kilobytes</strong>, which is about 6times the size of the first image, showing a meaningful improvement in the size and quality of the image with this approach.</p>
</li>
<li><p><strong>Arrow 3</strong> points to the size of a video posted using the same HD approach, the size of the video is around <strong>4.87 MegaByte</strong>. This was done to show this method also works fine for vides as well and improves their quality.</p>
</li>
<li><p><strong>Arrow 4</strong> point to the size of that same video, but this time posted without the HD approach. Its size on device is around <strong>1.93 Megabyte</strong>, about 2 and a half times lesser in size to the video in the HD approach. This shows how much lesser in size and quality it is in comparison to the first video.</p>
</li>
</ol>
<p>I think at this point, I have been able to point out the difference in posting normally, and using the HD approach for your Whatsapp status post. This improves the quality of the media files being posted.</p>
<h3 id="heading-why-and-how-does-this-work">Why and How does this Work?</h3>
<p>Earlier in this article, I mentioned something something about caching. To explain caching, lets start on a familiar note.</p>
<p>Have you ever noticed, that whenever you send a large file to a friend on whatsapp the first time, it takes quite a while to process and eventually send. When you either forward or send that same file to someone else on your contact list, it sends almost instantly this time.</p>
<p>If you have never noticed this, go try this out. Send a file around 10MB in size to friend A, then either forward or send that same file to another friend B and see how fast/instantly the file is sent the second time.</p>
<p>So, initially when I found out, I just assumed what was happening and left it at that, but knowing that this would be a public article, and people would want to know what my statements are based on, I decided to dig around and find official information to back this assumption up.</p>
<p><strong>So what is happening?</strong> The first time you send a message or file or just about anything on Whatsapp, most people think it goes straight to the device of whoever they are sending it to, nope, first it goes from your device straight to whatsapp's server, where it first stored before getting sent to the receiver's device it was sent to.</p>
<p>Why would they do this you ask next. Okay, okay, I'll answer that too. There are some pretty good reasons for this, the first being that, there are a lot of cases where the user you are sending a message or file to isn't online due to any number of reasons. If those messages are not first stored on Whatsapp servers and then sent to such user, the messages would never get delivered and just "fall off the internet", but after being saved on their server, it keeps trying to send the message from their server to the recipient device, till it succesfully does.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708567284055/cc45b075-ebc7-47b8-b0d6-6b4e949772b2.png" alt class="image--center mx-auto" /></p>
<p>A snippet officially from Whatsapp on what I just explained. You can read it <a target="_blank" href="https://www.whatsapp.com/legal/privacy-policy-eea#:~:text=We%20temporarily%20store%20your%20messages,we%20try%20to%20deliver%20it.">here</a></p>
<p>The second other reason why messages(texts/files) are also sent to their server, is to serve as a type of cache, now let's talk caching.</p>
<p>I earlier mentioned that the first time you send a message, it is not sent to the user directly, it is first stored on Whatsapp's server. This same thing happens when you send a picture, video or any file type. This is first sent and stored on a Whatsapp server, then a link to that file is sent to the user(recipient), with a download option, when they click download, the file is downloaded from the server over to their device.</p>
<p>In the snippet above, Whatsapp says they keep files/messages for a while. That file you sent to another user still stays on their server for a period of time determined by their server. If you then decide to send that exact file to another person while the file is still held on the server, rather than having you send that file up again to their server, they tell your device, "Hey we still have that file(picture, video, audio, etc)”, and then your phone ticks “sent” almost instantly without having to re-upload the file.</p>
<p>The same link sent to the first user for that same file is then sent to this new person you're sending the file to, and they can download it, if they want to. This saves you from wasting data to send(re-upload) the same file again to their server and also saves Whatsapp from having to give up unnecessary space to store duplicate files.</p>
<p>The moment Whatsapp deletes a file from their server, you get an error message on Whatsapp when you try to download, telling you to "Ask whoever sent the file to resend it". You most likely have seen this.</p>
<p>This whole process is one definition to caching, "temporarily saving data copies somewhere, so it can be accessed and retrieved faster and more efficiently".</p>
<p>You might then think, but don't Meta have big and bad enough servers with enough space on their servers for all these? Yes, but also, the moment you realize that they have around a billion daily active users and a large percentage of these persons including you and I, send different files every now and then in Kilobytes, Megabytes and Gigabytes, you'll know that this save them Terabytes on Terabytes of server space per second with just this approach and it's very very reasonable to.</p>
<h3 id="heading-so-how-does-this-and-the-hd-whatsapp-status-thing-relate"><strong>So how does this and the HD Whatsapp Status thing relate?</strong></h3>
<p>If you haven't made the connection yet, here it is. So the first time you send that HD media to yourself, it gets sent to Whatsapp's servers like every other message or file.</p>
<p>The next step you take, is to forward that message to your status right?</p>
<p>So Whatsapp asks the server, do we have that picture on our server? The server responds, "yes yes, we do, better still, it’s in HD quality". Whatsapp rather than letting you resend another copy of that same file, creates a download link to the same HD file on their server, and lets all of your contacts have access to the file, but this time on your status.</p>
<p>This, my friend, is how and why this HD status upload approach works.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1708569404224/1c008be1-6434-4198-a136-9fdf9f9c8bb1.gif" alt class="image--center mx-auto" /></p>
<p>It's a long write-up, but if you got here, I am guessing it was a good read. If you actually found this to be a good and useful read, Please share with others who you think might also find it useful and interesting as well.</p>
<blockquote>
<p><strong>Thank you.</strong></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[How Network Masts work]]></title><description><![CDATA[Any sufficiently advanced technology is indistinguishable from magic.- Arthur C. Clarke

I have always been very fascinated with how the internet feels so abstract and is yet so real. How do network providers like MTN, Airtel, GLO, etcetera (in Niger...]]></description><link>https://blog.ebode.dev/how-network-masts-work</link><guid isPermaLink="true">https://blog.ebode.dev/how-network-masts-work</guid><category><![CDATA[networking]]></category><category><![CDATA[network]]></category><category><![CDATA[wireless internet service providers in Nigeria]]></category><category><![CDATA[radio]]></category><category><![CDATA[network-mast]]></category><category><![CDATA[computer networking]]></category><category><![CDATA[#computernetwork ]]></category><category><![CDATA[Computer Science]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Fri, 07 Apr 2023 14:35:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1680880197082/6f9a0ca3-b2bf-4ac1-a533-d8b4f1c6e37b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><strong>Any sufficiently advanced technology is indistinguishable from magic.</strong><br />- Arthur C. Clarke</p>
</blockquote>
<p>I have always been very fascinated with how the internet feels so abstract and is yet so real. How do network providers like MTN, Airtel, GLO, etcetera (in Nigeria), give me access to the Internet over thin air? How do my calls and SMS texts reach the intended person? And more importantly why couldn't all of these be free? These were questions I asked growing up.</p>
<p>I eventually decided to find out these answers myself, and in doing so, I realized things were bigger and not as simple as they seemed on the surface.</p>
<p>At the end of this article, you should have an idea why internet access can't be free, at least at the moment, and the roles those tall giant masts we often see around play in giving us access to mobile internet, sending+receiving SMSes and making cellular voice calls.</p>
<p>Sit tight and stare closely as I unravel this <strong>MAGIC.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680879370068/ab179b3c-0d63-4e7f-a7eb-c9e34db8acb2.gif" alt class="image--center mx-auto" /></p>
<h2 id="heading-a-trip-into-connection">A TRIP INTO CONNECTION</h2>
<p>The very first question that popped into my mind back then, was how exactly were calls able to correctly go from one phone to another? These were the days I had fun playing Bounce and Snake Xenxia on these old phones. Unfortunately, Google wasn't easily accessible back then and even when I did get some access to the search engine, I had more sinister(😈) things to do and almost usually had forgotten. Fast forward to some years back and I intentionally began to find answers to these questions. This article shares those answers.</p>
<h3 id="heading-lets-dissect-a-network-mast">Let's dissect a network mast</h3>
<p>A network mast is a tall structure, sometimes standing alone, and in some cases it might be part of a tall tree, a tall building or just anything strong enough to carry communication components like a radio unit, antenna, or any other equipment used in telecommunications.</p>
<p>It also it has to be tall enough to have very minimal obstruction from buildings, all these so it can easily transmit and receive wireless signals from and to devices over long range.</p>
<p>While searching, one of the articles I came across was a detailed page from <a target="_blank" href="https://www.vodafone.co.uk/network/network-improvements">Vodafone</a> on network mast components and what each did. Rather than re-invent any wheel, I would give a simpler summary of what those components are and what they did here. A reference to the article would also be referenced below.</p>
<h3 id="heading-what-makes-up-a-network-mast">What makes up a network mast</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680810953962/40ef78dc-aa74-4c28-9d9d-067059c6035e.jpeg" alt class="image--center mx-auto" /></p>
<ol>
<li><h4 id="heading-antenna">Antenna</h4>
<p> The antennas send calls, texts and internet data to your smartphone or just any device that can talk to a mast, like Mifi's, Routers, laptops and sim enabled IoT devices, using radio waves. The antenna can in turn receive radio waves from containing data payload as well. The higher up an antenna is, the further signal can go. Most masts will have at least three antennas to provide coverage in different directions.</p>
</li>
<li><h4 id="heading-radio-unit">Radio unit</h4>
<p> The radio unit generates the radio waves transmitted by the antennas. It is responsible for converting signals between the wireless devices and the network, amplifying the signal, and transmitting it to the base station. Similarly, it receives signals from the <strong>base station</strong> and converts them into a form that can be transmitted wirelessly to devices.</p>
<p> A <strong>base station</strong> is an equipment typically located within or near a network mast, serving as a central hub that manages communication between wireless devices and the mast network. Additionally, it provides authentication and security for wireless connections.</p>
</li>
<li><h4 id="heading-transmissionbackhaul">Transmission/backhaul</h4>
<p> Cables, traditionally copper but now far more likely to be fiber optic, are used to connect one mast with other masts within the network. They are usually buried in the ground, and a few of us have likely seen cables being laid close to public roads, mostly in multiple colored pipes. In a few cases where it is not feasible to use cables laid in the ground, a microwave dish is used instead, more on that below.</p>
</li>
<li><h4 id="heading-cabincabinets">Cabin/cabinets</h4>
<p> At the ground level, these contain computers that co-ordinate communication with other masts in the network. Additional equipments, such as a battery backup in case of a power failure and connectors for the transmission/backhaul, are also stored here.</p>
</li>
<li><h4 id="heading-power">Power</h4>
<p> Most masts will draw their power from the National Grid (unfortunately, in Nigeria, our power grid collapses every market Friday); In this case, there is provision for a more reliable power source on-site, mostly diesel generators.</p>
</li>
<li><h4 id="heading-microwave-dish">Microwave dish</h4>
<p> In some locations, such as remote rural areas, a microwave satellite dish is used instead of fiber optic cables to act as a transmission to connect the mast to the rest of the masts on the network. These dishes transmit data wirelessly over the air using microwaves. To do so, the dish must be within line of sight of a dish on another mast, this means, there can not be any obstructions like houses, trees, poles or anything between the communicating masts. This is the primary reason they are always very tall.</p>
</li>
</ol>
<p>The article from Vodafone can be found <a target="_blank" href="https://www.vodafone.co.uk/newscentre/smart-living/everything-you-need-to-know-about/mobile-phone-masts-everything-you-need-to-know/">here</a>.</p>
<hr />
<h3 id="heading-how-are-phone-calls-connected"><strong>How are Phone Calls Connected</strong>?</h3>
<p>To answer this, first, you should know that your phone is almost always connected to the nearest network mast with the strongest network signal close to you/it. This also depends on the network provider. It is why you have those small network bar(s) at the top of your phone, it shows how close you are to the mast and how strong the connection signal is. If you are in an area where your phone or device can't reach a network mast from your Telco, you get the <strong>'No Signal'</strong> or <strong>'No Network'</strong> network status.</p>
<p>Also, as earlier stated, every network mast out there is connected to another mast, either via cables or micro waves(wirelessly). You might not see it, but they are all connected and talking to each other over very large distances.</p>
<p>Another crucial part of all this is the Mobile Switching Center(MSC), this is a central control point in the network, it manages call routings, connections between masts, billing, authentication, and overall network management tasks.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680809951556/587cc6e8-e269-452e-aef1-3d83710256ad.jpeg" alt class="image--center mx-auto" /></p>
<p>Back to the main question, how do calls go from one edge of the country to the other side and get to who we call correctly?</p>
<p>When you call a number, your device(smart-or-not phone) sends a request to the mast it is connected to as we mentioned earlier. That mast forwards that call to the nearest base station which checks that you have the correct permissions and requirements to make the call. When this is confirmed, the base station assigns the caller a frequency channel and then forwards that call to the Mobile Switching Center (MSC). The MSC does its own integrity checks as well and if it passes, it goes ahead to determine the routing path for the call.</p>
<p>A route is all the masts a call needs to pass through to get from your phone to the mast where the number you're calling is connected to. Upon finding this route, it directs the call through it. Once the call request reaches the mast connected to the number called, the mast sends the call notification to the device that has the number being called, prompting it to ring and alert the user of the incoming call.</p>
<p>For a little more technical on how the calls move, let's highlight the main processes:</p>
<ul>
<li><p><strong>Initiating the Call:</strong> When you start a call, your phone sends a radio signal to the nearest network mast it is connected to. The mast picks up the signal and sends it to the nearest base station via wires or wirelessly with microwaves.</p>
</li>
<li><p><strong>Authentication:</strong> The base station ensures your phone is allowed on the network, by asking for credentials from your sim card, it then assigns it a frequency channel and a time slot.</p>
</li>
<li><p><strong>Call Routing:</strong> The base station sends the call to the mobile switching center (MSC), which is responsible for routing the call to its destination.</p>
<p>  For example, MTN has numerous Mobile Switching Centers across the country, these control centers receive calls from the base station, find where the person the call is meant to get to is in the country, and how many masts to get to that person, it then sends the call in that direction.</p>
</li>
<li><p><strong>Mast Routing:</strong> In this case, there are two main scenarios, one is if the individual being called is within the same mast range as the caller, then the call doesn't have to leave that mast, if not, the call hops from one mast to another as the MSC directs.</p>
</li>
<li><p><strong>Call Termination:</strong> When the call is over, your phone sends a signal to the network indicating that the call has ended. The network releases the frequency channel and time slot assigned to your phone.</p>
</li>
</ul>
<p>The quality of a call is dependent on factors like signal strength(the distance between a phone and the closest mast), interference, and the length of the route it takes. If the signal is weak, the voice quality may be poor or the call may get dropped.</p>
<p>All of the above is what happens when you make a call from one phone number to another, it's also almost the same thing that happens when a SMS(Short Message Service) is sent, with some underlying protocol difference, such as sim cards not requiring real time connection and that there is a holding area for sms, where messages are kept if the recipient is offline(maybe their phone is dead, or they are in an area with bad network coverage).</p>
<p>For Internet connection, it's also almost the same, but with some interesting extra touch of complexities and changes, let's check that out.</p>
<hr />
<h3 id="heading-how-you-access-the-internet-with-just-a-sim-and-network-masts">How you access the Internet with just a SIM and Network Masts</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680845784600/7c4883da-060d-4443-b82b-ce548e9d3578.png" alt class="image--center mx-auto" /></p>
<p>Every time we use <strong>mobile data</strong>, that's internet access to your mobile phone via the SIM(Subscriber Identity Module) provided by Telcos like MTN, Airtel and the likes in Nigeria. Here, some radio magic and really complex engineering happens.</p>
<p>When you or anybody access the internet, it simply means you have access to files on the <strong>INTER</strong>connected <strong>NET</strong>work, a connection of millions of computers around the world. For example, this means you can reach and talk to computers owned by Google, allowing you access to their applications as well. Examples of those are: Google's search engine, Youtube, GMail, Google Cloud, and many more.</p>
<p>On the internet you can access not just Google's computers though, you have access to Wikipedia, Zoom, TikTok, Linkedin, Facebook, Amazon, Jumia, Bolt, Uber and millions of other websites.</p>
<p>You can get access to these applications on their powerful computers(servers) because they are publicly available on the internet. You also have the ability to send files to those computers (<strong>UPLOAD</strong>) or pull down files from them(<strong>DOWNLOAD</strong>), which is mostly what we all do. You download when you watch, reels, shorts, stream movies etcetera, and you upload data when you change your profile picture, post to your Whatsapp status, post reels, youtube, videos and share memes.</p>
<p>The internet is not some magic, but rather a well thought through connections of fibre cables between continents laid on the sea floor. These cables are the backbone of the internet, managed by ISPs, data centers or service providers within each countries on the continents they land.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680858690329/b51dfd8b-080c-4989-bfeb-3d2c0d284bd3.png" alt class="image--center mx-auto" /></p>
<p>⬆️ | <a target="_blank" href="https://www.submarinecablemap.com/">Image</a> showing the Fiber cables under the sea, powering the internet.</p>
<p>How your device reach those servers over the available number of cables, via the mast, is in itself a networking topic deserving a write up of its own. It is a beautiful and very well executed feat of network engineering handled by large companies around the world.</p>
<p>For now, we'll just talk discuss the role the network masts deployed by telcos to extend their network, play in the whole process.</p>
<ul>
<li><p>When you access the internet(assuming you still have an active data <strong>subscription</strong>), the data allows you to speak to the mast which passes on that request to other masts.</p>
</li>
<li><p>The data is then processed by the radio unit(I talked about radio units earlier up) on the network mast, which converts the data from digital to analog signals that can be transmitted over airwaves.</p>
</li>
<li><p>The data is then transmitted to other network masts and base stations which serve as a gateway to the ISP's core network.</p>
<p>  The core network is typically made up of multiple interconnected data centers and high-performance equipment and infrastructures designed to handle large volumes of data traffic, responsible for managing the routing of data traffic within and between networks.</p>
</li>
<li><p>The data is routed through the ISP's core network to an internet gateway( a component that connects the ISP's network to the internet).</p>
</li>
<li><p>The internet gateway sends the data out onto the internet, where it reaches the destination server for the requested data, most often across the world.</p>
</li>
<li><p>The data travels back through the ISP's core network and is routed to the appropriate base station and network mast to reach the user's device.</p>
</li>
<li><p>Your phone receives the requested data.</p>
</li>
</ul>
<p>All of these happen within seconds.</p>
<p>To make this quite relatable and practical, we'd use Whatsapp. Let's try a scenario where we download a voice message(an audio file) from a friend using MTN's network</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680864492972/23e870af-4f7b-4068-803f-07b3d982b1db.png" alt class="image--center mx-auto" /></p>
<p>➡️ | You open Whatsapp, where you received a voice message from a friend.</p>
<p>➡️ | You tap the download icon, and then WhatsApp sends a data request from the application through your phone, to the network mast your phone is connected to, managed by either MTN, Airtel, GLO or any other Telco. This request is transmitted as radio waves over the air from your phone to the network mast.</p>
<p>➡️ | The network mast receives the request and forwards it to the nearest base station, which serves as a gateway to MTN's core network.</p>
<p>➡️ | The request is then transmitted across the MTN core network to an internet gateway, which connects the MTN network to the internet.</p>
<p>➡️ | The internet gateway sends the request out onto the internet, where it reaches a WhatsApp server, these servers are located in data centers across the world, in places like the United States, Europe, and Asia. So depending on which continent the server the voice message is on, the request would pass through fiber cables connecting our continent to the source continent to fetch it.</p>
<p>➡️ | WhatsApp server finds the voice message you asked for and sends it back through the internet to MTN's network.</p>
<p>➡️ | The voice message travels back through the MTN's core network and is routed to the appropriate base station and network mast to reach your phone.</p>
<p>➡️ | Your phone receives the voice message and stores it in storage so you have it permanently, and then move it to memory allowing you to listen to it.</p>
<p>This happens for everything you download on your phone, image, video, audio, sticker, voice message, even when you make voice and video calls on WhatsApp or on any other application on your device.</p>
<p>The best part about all of this is that it happens so fast, you don't even know what just happened. The under-sea fibre cables move data around at the speed of light.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680862622916/2caeff0c-3047-4ab2-817d-c01461e4df12.jpeg" alt class="image--center mx-auto" /></p>
<p>Without network masts, the majority of all of us wouldn't be able to efficiently do the everyday things we do. Things like making calls, sending texts or using the internet. This is slowly changing though, as there are already things like FTTH(Fiber-To-The-Home) where you have a wired connection to your house to access the internet instead, there is also now a growing battle of satellite internet projects with the likes of <a target="_blank" href="https://www.hughesnet.com/">HughesNet</a>, <a target="_blank" href="https://www.viasat.com/">Viasat</a>, <a target="_blank" href="https://www.starlink.com/">Starlink</a>, <a target="_blank" href="https://oneweb.net/">Oneweb</a>, <a target="_blank" href="https://www.telesat.com/">Telesat</a>, <a target="_blank" href="https://www.aboutamazon.com/what-we-do/devices-services/project-kuiper">Project-Kuiper</a> etcetera. Also, we have our popular easy to use Wifi/Hotspot network too that we could quickly use to share files with a friend.</p>
<h3 id="heading-then-why-do-we-pay-for-internet-i-still-hear-you-ask"><strong>Then why do we pay for internet I still hear you ask?</strong></h3>
<p>If you didn't figure that out yet, yeah, let's talk about it. Earlier on we talked about network masts, first, those things are expensive to set up, getting a piece of land to set them on, the structure and the work to get them up, the cost of the antennas, radio unit, the cost of a backhaul if used(having to dig the ground and lay cables to connect one mast to another), cost of cables, costs of generators, the cost of fueling, there is a need to put someone on salary to constantly monitor the premise and maintain the system.</p>
<p>While writing this article, I came across a news write-up where thieves walked into a network mast premise to steal diesel meant to power the backup generators, and that's just the light side of the vandalism, it gets worse.</p>
<p>They also have to pay engineers to manage the hardware and software sides of everything.</p>
<p>It also cost an awful lot for Telcos to purchase spectrum licenses, I mean (1G, 2G, 3G, 4g and currently 5G), the most recent 5G spectrum license MTN had to buy from NCC, cost over 200 Million dollars, Airtel bought as well, and they have had to buy licenses all through the spectrum band to 5G.</p>
<p>When you add all of these things up and multiply it across all the network masts you see around and you can very quickly see a large startup and running cost emerge.</p>
<p>One other thing, companies like MTN, Airtel, GLO, etc might not also connect directly to the internet, they also connect to other ISPs for service, it's a hierarchical order of connection, and there are tiers to it, if they do not connect directly, they have to pay for connections.</p>
<p>Also we mentioned sub sea cables earlier. Running and maintaining these types of cables connecting one continent to another, cost millions of dollars.</p>
<p>A clearer image should have appeared by now, as to how much it costs to start and run a Telecommunication or Internet Service providing company. It is both capital-intensive and also running-cost-intensive, to stay sustainable and run at a profit, we the users have to pay to use the service.</p>
<p>This is why we pay to use the internet, pay for airtime to make calls and send SMS.</p>
<p><strong>FunFact:</strong> It is called <strong>airtime</strong> because when you make a voice call, use the internet or take a call, your phone uses radio waves to communicate with the cellular network over the <strong>'air'</strong>. How long you can do that, the <strong>'time'</strong> is based on how much you pay.</p>
<p>If you read it all to this point, thank you..</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1680864966845/442d0907-38b9-4537-8071-ba6084828b46.gif" alt class="image--center mx-auto" /></p>
<p>It feels like a very long one, but it was fun writing this, I hope you picked something.</p>
<blockquote>
<p>And you, yeah you, if you're seeing this, hmmm. It's .......</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Automating file re-organization on Windows with NodeJS]]></title><description><![CDATA[I dual boot, which means I run two operating systems on my personal computer. I use Microsoft Windows operating system as my personal use OS and Linux Mint, an Ubuntu-based Linux distribution as my code-writing environment, which also allows me to ti...]]></description><link>https://blog.ebode.dev/automating-file-reorg-with-nodejs</link><guid isPermaLink="true">https://blog.ebode.dev/automating-file-reorg-with-nodejs</guid><category><![CDATA[Node.js]]></category><category><![CDATA[Windows]]></category><category><![CDATA[Scripting]]></category><category><![CDATA[automation]]></category><category><![CDATA[operating system]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 12 Mar 2023 22:55:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678459732167/4ab48d91-fb5e-40cd-a4f0-a544ea81165e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I dual boot, which means I run two operating systems on my personal computer. I use Microsoft Windows operating system as my personal use OS and Linux Mint, an Ubuntu-based Linux distribution as my code-writing environment, which also allows me to tinker around with anything and everything on the OS, without fear of losing personal files.</p>
<p>On Windows, I tend to take a lot of screenshots using the (🪟 + PrtSc) command, I do this for very different reasons. Over time, I realized I now had an issue with how Windows labeled each screenshot image file in the folder where they were saved.</p>
<p>Each screenshot captured on Windows is named in the format &gt;&gt; ( Screenshot + (Number) + .png ).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678463863528/b63f7a87-3011-4bb5-956d-ccb47ba8c761.png" alt class="image--center mx-auto" /></p>
<p>'<strong>Screenshot</strong>' describes how the image is taken, '<strong>.png</strong>' is the file format the image is saved in, and '<strong>number</strong>' is a variable that gets incremented with every new screenshot. The very first time you take a screenshot on windows, that first picture is stored as 'screenshot (1).png', and that number (1) is stored in Window's registry. The next time you take another screenshot, it pulls the last value saved in the registry, adds one(1) to it and names the new screenshot with that value. That would mean the next screenshot saved after the first image would be saved as 'screenshot (2).png'.</p>
<p>Now herein lies the issue. The numbering process by Windows for naming the file only goes up and never adjusts to take account of deleted images or a change in the file numbering/number of files in the screenshot folder. It continuously increments the last saved number in the screenshot counter registry and names new files with that value forever!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678465854077/0621d7cf-935c-415d-92ca-c77833371e21.png" alt class="image--center mx-auto" /></p>
<p>Taking a look at the image above in the screenshot folder, you would find examples of my earlier complaints regarding discrepancies with the file naming/numbering. We'll be fixing that with our NodeJS script later in this article. The script would be to rename and rearrange the screenshot files in numerical descending order and thereafter update Windows' registry with the new screenshot file numbers.</p>
<p>You might say, but that's not a big deal, and you could live with just how Windows handles naming your screenshot files, and you'll be very right. Millions of Windows users do these and it in no way hinders how they use their machine. But unfortunately, I have been bestowed the power to write codes and make things conform, and I would love to use this power at this junction.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678466885239/3b8f39b6-8f3c-4bec-945f-2fb6f204518e.gif" alt class="image--center mx-auto" /></p>
<p>Also, another angle to this is that it's a fun way of telling your machine what to do, when to, and just exactly how to do what you want. Now let's get to business.</p>
<h2 id="heading-the-power-in-code">THE POWER IN CODE</h2>
<p><strong>- GOAL</strong><br />The script I'll be writing would do three main things:</p>
<ul>
<li><p>Take a count of all the files(pictures) in the Screenshot Folder.</p>
</li>
<li><p>Start from the top and then re-order and rename the files in descending order.</p>
</li>
<li><p>Lastly, talk to Windows' registry to update the screenshot counter index with the new numbers of files in the screenshot folder.</p>
</li>
</ul>
<p>To make things easily accessible, the javascript file would be in the same directory as the screenshot folder, and to also speed up execution time, there would be a 'sleight-of-hand' approach to run commands from Windows' search bar, shown later in the article.</p>
<p><strong>- REQUIREMENTS</strong><br />In this article, I'll be using Node.js on a Windows machine. Node.js is a popular tool for building server-side applications and also provides several useful modules for working with the file system. To follow along, you would need :</p>
<ul>
<li><p>A computer</p>
</li>
<li><p>Windows Operating System (Win-11 or Win-10 or Win-8 or Win-7)</p>
</li>
<li><p>NodeJS</p>
</li>
</ul>
<p>To Install nodeJS on your windows machine:</p>
<ul>
<li><p>Download the NodeJS installer from the official website (<a target="_blank" href="https://nodejs.org/"><strong>https://nodejs.org/</strong></a>).</p>
</li>
<li><p>Choose the appropriate installer based on your operating system, here we're using <strong>Windows</strong>.</p>
</li>
<li><p>Run the installer and follow the instructions.</p>
</li>
<li><p>Once the installation is complete, you can verify it by opening a terminal (or command prompt) and running the command <code>node -v</code>. This should display the version of Node.js that you just installed.</p>
</li>
</ul>
<h2 id="heading-lets-get-started">Let's get Started</h2>
<p>Navigate into the Screenshot folder to create a new folder to house the nodeJS project. For mine, I created a folder and named it 're-order' in the Screenshots directory.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678617074984/2c729387-3f84-4eba-bb91-4adf57019006.png" alt class="image--center mx-auto" /></p>
<p>Use the context menu on the folder to open it in your preferable code editor, I use <strong>Windows VS Code.</strong> Within VS Code, you can use a terminal, the terminal is where I would perform all nodeJS-required executions..⬇️..</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678618026684/42b117d3-6d8f-4a03-adec-5b77ba98e9f2.png" alt class="image--center mx-auto" /></p>
<p>To start a new NodeJS project, we need to initialize the project with the first set of files required to function properly. To do that we use the command below</p>
<pre><code class="lang-plaintext">npm init -y
</code></pre>
<p>the '<strong>-y'</strong> flag is to fill in every requirement with default values, so we don't have to manually do that. If you want to, you can simply drop the -y flag and fill it in yourself. Once you're done, this process creates a 'package.json' file.</p>
<p>The next thing would be to install the required external dependencies using npm. In this project, we would be mainly using the 'fs' and 'path' modules, both of which are built-in to nodeJS and don't need an install, but to talk to Windows registry, we need an external package, '<strong>regedit</strong>'.</p>
<p>To install 'regedit'.</p>
<pre><code class="lang-plaintext">npm install regedit
</code></pre>
<p>Before we get into writing the code fully, we can make some changes to the file structure and the 'package.json', file to speed the code execution process and add some level of organization.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678717746641/96e9be51-3959-4af0-af41-257fec8e0bbc.png" alt class="image--center mx-auto" /></p>
<p>Three main changes were done to :</p>
<ul>
<li><p>Create the javascript file where all the code would be written in, its named 're-order.js'.</p>
</li>
<li><p>Create a folder('src') to put the JS file into, for a level of organization.</p>
</li>
<li><p>Update the 'scripts' object in the package.json file, to point npm at the javascript file just created. This makes it easier to run the code, rather than having to always type '<strong>node re-order.js</strong>' and having to keep track of the name and the folder you're in, you could just use '<strong>npm start</strong>' and let npm handle the rest.</p>
</li>
</ul>
<p>We're good to commence writing the code now. As you observed, there is also a <strong>node_modules</strong> folder in the structure now, that's where the 'regedit' module we downloaded earlier is stored and also where any future module installed would be saved.</p>
<h3 id="heading-writing-the-code">Writing the Code</h3>
<p>We can now head over to our r<strong>e-order.js</strong> file and make things happen in there. Earlier, we made three goals, the first being to '<strong>take a count of all the files in the screenshot folder'</strong>. Let's start there.</p>
<p><strong>The imports and constants</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> fs        = <span class="hljs-built_in">require</span>(<span class="hljs-string">'fs'</span>);
<span class="hljs-keyword">const</span> path      = <span class="hljs-built_in">require</span>(<span class="hljs-string">'path'</span>);
<span class="hljs-keyword">const</span> regedit   = <span class="hljs-built_in">require</span>(<span class="hljs-string">'regedit'</span>);

<span class="hljs-comment">//Path to screenshot folder</span>
<span class="hljs-keyword">const</span> screenshotFolder = <span class="hljs-string">'C:\\Users\\Peter Ebode\\Pictures\\Screenshots'</span>;

<span class="hljs-comment">//Registry key for screenshot counter</span>
<span class="hljs-keyword">const</span> keyPath = <span class="hljs-string">'HKCU\\SOFTWARE\\MICROSOFT\\Windows\\CurrentVersion\\Explorer'</span>;
</code></pre>
<p>In the code body above, two main things are happening, first, is the import of modules that the program would later require to run. The modules used are :</p>
<ul>
<li><p><code>'fs'</code> : The 'fs' module short for fileSystem, is a built-in module in Node.js that provides an interface for working with the file system. It allows you to read, write, and manipulate files and directories on your computer or server.</p>
</li>
<li><p><code>'path'</code> : The 'path' module in Node.js is a built-in module that provides utilities for working with file and directory paths.</p>
</li>
<li><p><code>'regedit'</code> : The 'regedit' npm module is a third-party package that provides a simple interface for working with the Windows registry in Node.js. The <strong>Windows registry</strong> is a database that stores configuration settings and options for the Windows operating system and other software applications.</p>
</li>
</ul>
<p>The next two lines are for constants that hold the path to the screenshot folders('remember to update yours to point to your screenshot folder') and also the keypath to the screenshot counter variable in Windows registry.</p>
<p>⚠️ | At this stage, I would like to point out that it is a bad idea to play around with the files and configurations in Windows registry, but I have taken my time to ensure we are only reading and writing to the right files, and if you are uncomfortable doing that, you could just comment out the section in the code doing that. I would leave a comment in the code for that.</p>
<p><strong>Reading files in the directory and filtering</strong></p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Read all files in screenshot folder</span>
fs.readdir(screenshotFolder, <span class="hljs-function">(<span class="hljs-params">err, files</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span> (err) {
      <span class="hljs-built_in">console</span>.error(err);
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// Filter only image files (png, jpg, jpeg)</span>
    <span class="hljs-keyword">const</span> imageFiles = files.filter(<span class="hljs-function"><span class="hljs-params">file</span> =&gt;</span> {
      <span class="hljs-keyword">const</span> ext = path.extname(file).toLowerCase();
      <span class="hljs-keyword">return</span> ext === <span class="hljs-string">'.png'</span> || ext === <span class="hljs-string">'.jpg'</span> || ext === <span class="hljs-string">'.jpeg'</span>;
    });

});
</code></pre>
<p>This section of the code uses the <code>fs</code> module to read all the files in the screenshot directory specified by the <code>screenshotFolder</code> variable. It then filters the list of files to only include image files with the extensions ".png", ".jpg", or ".jpeg". In a normal scenario, we should only have '.png' files in the screenshot folder, but just in case, there is an imported image or something changes, to handle those cases, we're making room for possible jpg, png and jpeg files. This also stops the code from picking up the re-order folder we created for the code in the same screenshot folder.</p>
<p>A more detailed breakdown of the code :</p>
<ul>
<li><p><code>fs.readdir(screenshotFolder, (err, files) =&gt; {...})</code>: This line reads the contents of the screenshot directory specified by the <code>screenshotFolder</code> variable and passes the result as an array of filenames to the callback function. If there is an error, the <code>err</code> argument will be set, and the error will be logged to the console.</p>
</li>
<li><p><code>const imageFiles = files.filter(file =&gt; {...})</code>: This line filters and returns the list of image files by creating a new array (<code>imageFiles</code>) that includes only the files that meet the condition that the file extension (determined using the <code>path.extname</code> function) must either be ".png", ".jpg", or ".jpeg".</p>
</li>
</ul>
<p><strong>Sorting screenshot image files in order</strong></p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Sort image files by filename (numeric order)</span>
imageFiles.sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> aFile = <span class="hljs-built_in">parseInt</span>(path.basename(a, path.extname(a)).match(<span class="hljs-regexp">/\d+/</span>)[<span class="hljs-number">0</span>]);
  <span class="hljs-keyword">const</span> bFile = <span class="hljs-built_in">parseInt</span>(path.basename(b, path.extname(b)).match(<span class="hljs-regexp">/\d+/</span>)[<span class="hljs-number">0</span>]);
  <span class="hljs-keyword">return</span> aFile - bFile;
});
</code></pre>
<p>This is a continuation of the previous code, here it sorts the list of image files obtained in the previous step (<code>imageFiles</code>) in numerical order based on their filenames.</p>
<p>A breakdown of the code:</p>
<ul>
<li><p><code>imageFiles.sort((a, b) =&gt; {...})</code>: This line calls the <code>sort()</code> method on the <code>imageFiles</code> array and passes a callback function as an argument. The callback function is used to compare two elements in the array and determine their sort order.</p>
</li>
<li><p><code>const aFile = parseInt(path.basename(a, path.extname(a)).match(/\d+/)[0]);</code>: An example of what this section does is that it would pull out the number <strong>33</strong> in the word 'Screenshot (33).png' and save it in the variable <code>aFile</code> . This is done by first using the <code>path.basename()</code> function to extract the filename without the extension, then using a regular expression (<code>/\d+/</code>) to match the first sequence of digits in the filename, and finally using <code>parseInt()</code> to convert the matched digits into an integer.</p>
</li>
<li><p><code>const bFile = parseInt(path.basename(b, path.extname(b)).match(/\d+/)[0]);</code>: This line does the same thing as the previous line but for the second file being compared (<code>b</code>). The numeric part of the filename is extracted and stored in the <code>bFile</code> variable.</p>
</li>
<li><p><code>return aFile - bFile;</code>: This line is the comparison function used by <code>sort()</code>. It returns a negative value if <code>a</code> should be sorted before <code>b</code>, a positive value if <code>b</code> should be sorted before <code>a</code>, and zero if their order doesn't matter. In this case, it compares <code>aFile</code> and <code>bFile</code> variables (which hold the numeric parts of the filenames) and returns the difference between them. This has the effect of sorting the array in ascending order based on the numeric part of the filenames, hence the screenshot file names are sorted in descending order based on their number value.</p>
</li>
</ul>
<p><strong>Renaming the files to have sequential file names in the order from the previous sort</strong></p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Rename image files to have sequential filenames (starting from 1)</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Screenshots file Re-organization started...'</span>)
imageFiles.forEach(<span class="hljs-function">(<span class="hljs-params">file, i</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> oldPath = path.join(screenshotFolder, file);
  <span class="hljs-keyword">const</span> newPath = path.join(screenshotFolder, <span class="hljs-string">`Screenshot (<span class="hljs-subst">${i + <span class="hljs-number">1</span>}</span>)<span class="hljs-subst">${path.extname(file)}</span>`</span>);

    fs.rename(oldPath, newPath, <span class="hljs-function"><span class="hljs-params">err</span> =&gt;</span> {
        <span class="hljs-keyword">if</span> (err) {
            <span class="hljs-built_in">console</span>.error(err);
            <span class="hljs-keyword">return</span>;
        }
    });

});

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Screenshots file(<span class="hljs-subst">${imageFiles.length}</span>) Re-organization complete.`</span>)
</code></pre>
<p>This also continues on the previous code, the file renaming happens here.</p>
<p>The code breakdown:</p>
<ul>
<li><p><code>console.log('Screenshots file Re-organization started...')</code>: This line logs a message to the console to indicate that the file renaming process has started.</p>
</li>
<li><p><code>imageFiles.forEach((file, i) =&gt; {...})</code>: This line loops through each file in the <code>imageFiles</code> array and passes it to a callback function. This callback function also receives the index of the current file (<code>i</code>) as an argument.</p>
</li>
<li><p><code>const oldPath = path.join(screenshotFolder, file);</code>: This line constructs the path of the original file by joining the <code>screenshotFolder</code> variable (which holds the path to the directory containing the files) with the current filename (<code>file</code>).</p>
</li>
<li><p><code>const newPath = path.join(screenshotFolder,</code> Screenshot (${i + 1})${path.extname(file)}<code>);</code> : This line constructs the path of the new file by joining the <code>screenshotFolder</code> variable with a new filename that includes the index (<code>i</code>) plus 1, and the original file extension. The new filename is enclosed in backticks (<code>`` </code>) to allow for string interpolation.</p>
</li>
<li><p><code>fs.rename(oldPath, newPath, err =&gt; {...});</code>: This line renames the original file to the new filename using the <code>fs.rename()</code> method. If there is an error, it is logged to the console.</p>
</li>
<li><p><code>console.log(</code>Screenshots file(${imageFiles.length}) Re-organization complete.<code>)</code>: This line logs a message to the console to show that the file renaming process is complete, along with the total number of files that were renamed.</p>
</li>
</ul>
<p>That's all for the screenshot file counting, sorting and renaming process, the first two set goals have been achieved. The last one to talk to the registry to update it with the files we counted in the screenshot folder is all that's left.</p>
<p><strong>Talking to Windows registry to read and update windows screenshot counter value</strong></p>
<pre><code class="lang-javascript"><span class="hljs-comment">//STOP HERE IF YOU DO NOT WANT TO TOUCH WINDOWS REGISTRY</span>
<span class="hljs-comment">//REGISTRY UPDATE</span>
<span class="hljs-comment">// Get the previous screenshot counter value from the registry</span>
regedit.list([keyPath], <span class="hljs-function">(<span class="hljs-params">err, result</span>) =&gt;</span> {
  <span class="hljs-keyword">if</span> (err) {
     <span class="hljs-built_in">console</span>.error(err);
     <span class="hljs-keyword">return</span>;
 }

    <span class="hljs-comment">//Previous Screenshot Value</span>
    <span class="hljs-keyword">const</span> previousValue = result[keyPath].values[<span class="hljs-string">'ScreenshotIndex'</span>].value;
    <span class="hljs-comment">//New Value from Directory scan </span>
    <span class="hljs-keyword">const</span> newValue      = imageFiles.length;

    <span class="hljs-comment">// Update the screenshot counter value in Windows' registry</span>
    regedit.putValue({
        [keyPath]: {
            <span class="hljs-string">'ScreenShotIndex'</span>: {
                <span class="hljs-attr">value</span>: newValue,
                <span class="hljs-attr">type</span>: <span class="hljs-string">'REG_DWORD'</span>
             }
         }
        },<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
            <span class="hljs-keyword">if</span> (err) {
                <span class="hljs-built_in">console</span>.error(err);
                <span class="hljs-keyword">return</span>;
            }

    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`\nRegistry Screenshot counter value updated from <span class="hljs-subst">${previousValue}</span>, to a New value of <span class="hljs-subst">${newValue}</span>.\n`</span>);
    });

});
</code></pre>
<p>This final section of the code updates the Windows registry with the latest screenshot index(Gotten from counting the screenshot files).</p>
<p>Here's a breakdown of the code:</p>
<ul>
<li><p><code>regedit.list([keyPath], (err, result) =&gt; {...})</code>: This line uses the <code>regedit</code> package to list the values in the Windows registry key specified by the <code>keyPath</code> variable defined earlier in the code. The callback function receives an error object and the result object.</p>
</li>
<li><p><code>const previousValue = result[keyPath].values['ScreenshotIndex'].value;</code> : This line extracts the previous screenshot index value in Windows registry from the <code>result</code> object. It does this by accessing the <code>value</code> property of the <code>ScreenshotIndex</code> value under the specified <code>keyPath</code>.</p>
</li>
<li><p><code>const newValue = imageFiles.length;</code>: This line sets the new screenshot index value to the length of the <code>imageFiles</code> array (that's the number of files in the screenshot directory).</p>
</li>
<li><p><code>regedit.putValue({...},(err) =&gt; {...})</code>: This line uses the <code>regedit</code> package to update the <code>ScreenshotIndex</code> value in the Windows registry with the new screenshot index value. It does this by calling the <code>putValue()</code> method with an object containing the new value, type, and registry key path. The callback function receives an error object.</p>
</li>
<li><p><code>console.log(</code>\nRegistry Screenshot counter value updated from ${previousValue}, to a New value of ${newValue}.\n<code>);</code>: This line logs a message to the console to indicate that the registry update is complete and to display the previous and new screenshot index values.</p>
</li>
</ul>
<p><strong>ALL THE CODE</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> fs        = <span class="hljs-built_in">require</span>(<span class="hljs-string">'fs'</span>);
<span class="hljs-keyword">const</span> path      = <span class="hljs-built_in">require</span>(<span class="hljs-string">'path'</span>);
<span class="hljs-keyword">const</span> regedit   = <span class="hljs-built_in">require</span>(<span class="hljs-string">'regedit'</span>);

<span class="hljs-keyword">const</span> screenshotFolder = <span class="hljs-string">'C:\\Users\\Peter Ebode\\Pictures\\Screenshots'</span>; <span class="hljs-comment">//Path to screenshot folder</span>
<span class="hljs-keyword">const</span> keyPath = <span class="hljs-string">'HKCU\\SOFTWARE\\MICROSOFT\\Windows\\CurrentVersion\\Explorer'</span>; <span class="hljs-comment">//Registry key for screenshot counter</span>

<span class="hljs-comment">// Read all files in screenshot folder</span>
fs.readdir(screenshotFolder, <span class="hljs-function">(<span class="hljs-params">err, files</span>) =&gt;</span> {
    <span class="hljs-keyword">if</span> (err) {
      <span class="hljs-built_in">console</span>.error(err);
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// Filter only image files (png, jpg, jpeg)</span>
    <span class="hljs-keyword">const</span> imageFiles = files.filter(<span class="hljs-function"><span class="hljs-params">file</span> =&gt;</span> {
      <span class="hljs-keyword">const</span> ext = path.extname(file).toLowerCase();
      <span class="hljs-keyword">return</span> ext === <span class="hljs-string">'.png'</span> || ext === <span class="hljs-string">'.jpg'</span> || ext === <span class="hljs-string">'.jpeg'</span>;
    });

    <span class="hljs-comment">// Sort image files by filename (numeric order)</span>
    imageFiles.sort(<span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> {
        <span class="hljs-keyword">const</span> aFile = <span class="hljs-built_in">parseInt</span>(path.basename(a, path.extname(a)).match(<span class="hljs-regexp">/\d+/</span>)[<span class="hljs-number">0</span>]);
        <span class="hljs-keyword">const</span> bFile = <span class="hljs-built_in">parseInt</span>(path.basename(b, path.extname(b)).match(<span class="hljs-regexp">/\d+/</span>)[<span class="hljs-number">0</span>]);
        <span class="hljs-keyword">return</span> aFile - bFile;
    });

    <span class="hljs-comment">// Rename image files to have sequential filenames (starting from 1)</span>
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Screenshots file Re-organization started...'</span>)
    imageFiles.forEach(<span class="hljs-function">(<span class="hljs-params">file, i</span>) =&gt;</span> {
        <span class="hljs-keyword">const</span> oldPath = path.join(screenshotFolder, file);
        <span class="hljs-keyword">const</span> newPath = path.join(screenshotFolder, <span class="hljs-string">`Screenshot (<span class="hljs-subst">${i + <span class="hljs-number">1</span>}</span>)<span class="hljs-subst">${path.extname(file)}</span>`</span>);
        fs.rename(oldPath, newPath, <span class="hljs-function"><span class="hljs-params">err</span> =&gt;</span> {
            <span class="hljs-keyword">if</span> (err) {
                <span class="hljs-built_in">console</span>.error(err);
                <span class="hljs-keyword">return</span>;
            }
        });
    });
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Screenshots file(<span class="hljs-subst">${imageFiles.length}</span>) Re-organization complete.`</span>)

    <span class="hljs-comment">//STOP HERE IF YOU DO NOT WANT TO TOUCH WINDOWS REGISTRY</span>
    <span class="hljs-comment">//REGISTRY UPDATE</span>
    <span class="hljs-comment">// Get the previous screenshot counter value from the registry</span>
    regedit.list([keyPath], <span class="hljs-function">(<span class="hljs-params">err, result</span>) =&gt;</span> {
        <span class="hljs-keyword">if</span> (err) {
        <span class="hljs-built_in">console</span>.error(err);
        <span class="hljs-keyword">return</span>;
        }

        <span class="hljs-keyword">const</span> previousValue = result[keyPath].values[<span class="hljs-string">'ScreenshotIndex'</span>].value; <span class="hljs-comment">//Previous Screenshot Value</span>
        <span class="hljs-keyword">const</span> newValue      = imageFiles.length; <span class="hljs-comment">//New Value from Directory scan</span>


        <span class="hljs-comment">// Update the screenshot counter value in Windows' registry</span>
        regedit.putValue({
                [keyPath]: {
                    <span class="hljs-string">'ScreenShotIndex'</span>: {
                        <span class="hljs-attr">value</span>: newValue,
                        <span class="hljs-attr">type</span>: <span class="hljs-string">'REG_DWORD'</span>
                    }
                }
            },<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
            <span class="hljs-keyword">if</span> (err) {
            <span class="hljs-built_in">console</span>.error(err);
            <span class="hljs-keyword">return</span>;
        }

            <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`\nRegistry Screenshot counter value updated from <span class="hljs-subst">${previousValue}</span>, to a New value of <span class="hljs-subst">${newValue}</span>.\n`</span>);
        });

    });

  });
</code></pre>
<p>For access to the full code, you can check out the repo <a target="_blank" href="https://github.com/eebod/Article-Repo-House/tree/main/%5B1%5D%20re-order">here</a> on GitHub.</p>
<p>If you find any bug or have an improvement, you can fork the code on the repo and make a Pull Request with your changes, I would follow up.</p>
<p><strong>THE EXECUTION</strong><br />To execute the code, if you followed the file structuring used earlier, you can use the command :</p>
<pre><code class="lang-plaintext">npm start
</code></pre>
<p>Or if not, but you're in the directory with the re-order.js file, you can use the command :</p>
<pre><code class="lang-plaintext">node re-order.js
</code></pre>
<p><strong>5,4,3,2,1, execute...</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678667384388/b6a969e8-ec90-47c4-8dcd-87512afe1e2a.png" alt class="image--center mx-auto" /></p>
<p>This shows the code executed from within Microsoft VS Code(Terminal).</p>
<h3 id="heading-the-code-effect">The Code Effect</h3>
<p><strong>- BEFORE : ⤵️</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678667569705/8f740ac2-3de0-439f-b824-4615a64d5b8a.png" alt class="image--center mx-auto" /></p>
<p>This shows the screenshot folder is quite disorganized and badly labeled.</p>
<p><strong>- AFTER : ⤵️</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678667666298/5ec29c43-4541-4f1f-a60a-fb4f143188fc.png" alt class="image--center mx-auto" /></p>
<p>We now have a well-organized folder. Also, because we updated the registry, the next screenshot we take would be named in continuation from where the last file numbering stopped. In the case of the image above, the next screenshot file would be named 'Screenshot (91).png'</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678668075415/32041831-28d2-4517-b290-2e8eb73ee6be.gif" alt class="image--center mx-auto" /></p>
<p>Yep!! The mission is complete, but sure, we can still spice things up a little.</p>
<h3 id="heading-the-spicing">The SPICING</h3>
<ul>
<li><strong>Speed up Execution</strong></li>
</ul>
<p>To speed up how we execute the code, rather than having to always open VS code or a terminal to run the program from there, we could instead and very simply execute it from our search bar context.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678668617489/5434ce47-8d6f-49da-b44f-cf9f35fdb8a5.png" alt class="image--center mx-auto" /></p>
<p>If you remember how we structured our folder for the code, once you have nodeJS installed and set to path, all you just have to do is pretend like you want to search, but in this case, do a 'node' command followed by the relative path to the Javascript code, and that code would get executed. A search for <code>'node re-order/src/re-order.js'</code> followed by an enter does the trick in this case.</p>
<ul>
<li><strong>Extra Effect(Folder hiding)</strong></li>
</ul>
<p>To make the folder not get in the way of your pictures, we can use the Windows folder context menu to hide the folder. To do that, you can follow the Image directions below :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678669065449/376cb5d0-4bfd-44d9-b27f-a1c442fdccf5.png" alt class="image--center mx-auto" /></p>
<p>(⬆️) Right Click on the folder to open the context menu and click on <strong>'</strong><code>Properties'</code> .</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678669154940/49e9d363-6941-4bf2-8c74-7d7594651ba1.png" alt class="image--center mx-auto" /></p>
<p>(⬆️) Tick the '<code>Hidden</code>' box option and click '<code>Apply</code>', to make the folder hidden.</p>
<p>Select the option to hide folders and files in the folder.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678669249695/2a60fbdc-479f-4615-9fa5-ce69dfefa36a.png" alt class="image--center mx-auto" /></p>
<p>(⬆️) The folder becomes <strong>INVISIBLE</strong>..<br />To see the folder, use the <strong>view</strong> option in windows to see hidden items, and you can follow the process backward to unhide the folder.</p>
<hr />
<p>This brings us to the end of the article, thanks for your time. If you tried it out on your machine and have any questions, issues or an improvement to the code, feel free to throw them over in the comments section.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1678669579432/ef00e04a-bac9-4f4c-8415-3b36049a93b2.gif" alt class="image--center mx-auto" /></p>
<p>Thank You..</p>
]]></content:encoded></item><item><title><![CDATA[Why Whatsapp reduces Image and Video quality]]></title><description><![CDATA[Getting frustrated with why a picture or video looks 'beaten' on your Whatsapp status? It's a common experience.

We've probably all asked one question after sending a picture or video to a friend, or while updating our status, why does Whatsapp make...]]></description><link>https://blog.ebode.dev/whatsapp-quality-reduction</link><guid isPermaLink="true">https://blog.ebode.dev/whatsapp-quality-reduction</guid><category><![CDATA[internet]]></category><category><![CDATA[whatsapp]]></category><category><![CDATA[Explain like I am five]]></category><category><![CDATA[compression]]></category><category><![CDATA[knowledge sharing]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Wed, 25 Jan 2023 16:45:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674627393995/6662dd4e-e81c-488b-b84b-b3a1aae58077.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Getting frustrated with why a picture or video looks '<em>beaten</em>' on your Whatsapp status? It's a common experience.</p>
</blockquote>
<p>We've probably all asked one question after sending a picture or video to a friend, or while updating our status, why does Whatsapp make my file not look as good as it was on my phone? If you never have, it's a complaint I have heard pretty often. Before going into the article, let me point out certain things about WhatsApp;</p>
<ul>
<li><p>Whatsapp has over 1 billion users every day.</p>
</li>
<li><p>Whatsapp is free for all its users, although it used to charge $1 annually. <a target="_blank" href="https://blog.whatsapp.com/making-whats-app-free-and-more-useful">blog</a></p>
</li>
<li><p>Whatsapp spends Millions in USD($) on its operational costs.</p>
</li>
<li><p>Whatsapp's supposed business model is that eventually, users would communicate with other businesses through their platform and those businesses would pay for Whatsapp's service.</p>
</li>
</ul>
<p>Before we go into the Why, let's talk about the how. How does Whatsapp reduce the size and quality of your files(pictures, videos and songs)? This process of reducing file size is called file compression.</p>
<h3 id="heading-how">HOW</h3>
<p><strong>FILE COMPRESSION</strong><br />When a file is compressed, software or a piece of code reduces the size of that file by removing unimportant information from it. This file takes up less space on a storage device like a phone's internal memory, a memory card, a flash drive, etcetera, and can be transferred more quickly over the internet. There are two types of compressions;</p>
<ul>
<li><p><strong>Lossless Compression:</strong> This type of compression makes it possible to get the same quality of the file as before it was compressed. It means the size of the file has reduced, but the quality is still the same as the original.</p>
</li>
<li><p><strong>Lossy Compression:</strong> If a file is lossy compressed, it means some of the original data is lost during the compression process, which makes the file size smaller. The compressed file can still be used, but the quality of the image or sound is reduced. This is similar to what Whatsapp does.</p>
</li>
</ul>
<p>Below, there are two pictures, the picture on the left is an original picture that's 4 Megabytes(4MB) in size, while the picture on the right is the same as the original, but it has been lossy compressed. The new size is 227 kilobytes(227KB), which is a size reduction of about 94.45%. You would almost not notice a drop in quality though, but it's there, especially if viewed with a larger screen.</p>
<div class="hn-embed-widget" id="ninja-1-nokali"></div><p> </p>
<h3 id="heading-why">WHY</h3>
<p>One very simple answer to why Whatsapp reduces image or video quality is to save 'data usage'. When you send an image or video through Whatsapp, the app compresses the file to reduce its size, making it quicker to send and also reducing the amount of data required to send the file.</p>
<p>A good number of people, I asked, think they pay for Whatsapp services with their mobile data subscription, this is quite wrong. Internet Service Providing(ISPs) companies, like MTN and Airtel in Nigeria, AT&amp;T, Verizon, and T-Mobile, in other countries, make a profit off your data purchase. These ISPs only connect you to other companies or services, like Whatsapp, Google or Twitter, but they don't pay them. The larger a file you transfer or share on Whatsapp, the more mobile data it would consume, Whatsapp, therefore, reduces the cost of your data purchase, by compressing your files.</p>
<p>Whatsapp wants its users around the world to enjoy a similar app usage experience, but due to the possible limitations of mobile networks in different places across the world, not everyone has access to high-speed internet, and even those who do, may have limited data plans. By compressing images and videos, WhatsApp is making sure that everyone can use the app, even if they have a slow or limited internet connection. I am sure you have had to, at one point wait for a picture or video on a Whatsapp status to load, or for a file to get downloaded, it didn't feel so good waiting. Imagine people with 10x slower internet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674516794469/4dc85aa9-1a26-495b-bcda-4221381419b0.png" alt="character depicting slow internet" class="image--center mx-auto" /></p>
<h3 id="heading-more-reasons-why">More Reasons Why</h3>
<p><strong>Saving Storage Space on Device</strong><br />Anytime you send a picture, video or document to another contact on Whatsapp, It saves a copy of that file on your device for reference, so it can be shown inside the app. If you didn't know this earlier, to check for yourself, you could open your phone's file manager to check, by following the folder structure below. (for pictures)</p>
<pre><code class="lang-plaintext">Storage Device &gt;&gt; Whatsapp &gt;&gt; Media &gt;&gt; Whatsapp Images &gt;&gt; Sent
</code></pre>
<p>You would find a copy of all the pictures you've sent using Whatsapp on your phone. WhatsApp compresses those images to save storage space on your device. When images and videos are compressed, they take up less space. This can be particularly important for users who have limited storage. The same applies to every status update you view, it gets stored on your device. The bigger the files, the more space they would take on the device.</p>
<p><strong>Reduced Server load and Costs Saving</strong><br />For every picture, document, song or video file you send to a contact on Whatsapp, into a group, or that you upload on your status, they are first sent to Whatsapp's servers(a bigger, better and more expensive type of computer) for processing and storage. Anytime someone tries to download that file or view your status, their phone asks Whatsapp servers for that file, which it then sends to them. It does the same thing for every of your contact that views your status or downloads a file you send to them. Now, imagine Whatsapp with over a billion active users every day, and the number of people that share files and upload files on their status. The data the servers have to handle become very very large, very quickly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674518657807/230b5b25-8cf6-4190-b6d7-cef860b0fbb3.jpeg" alt="server room with workers in it" class="image--center mx-auto" /></p>
<p>The image above is what a server room might look like. The rows of machines in there are racks of very powerful computers(servers), as mentioned earlier. These things run on electricity, they also get very hot and need cooling(more electricity), they also all have to be connected to the internet, they need to have very large storage(in Terabytes) to save your files, and finally, they need engineers to make sure everything is working correctly. All of these costs millions of <strong>$$$(💵)</strong> to set up and maintain.</p>
<p>When a file is compressed and its size is reduced, it makes a significant difference to the amount of data that needs to be sent to and processed by the servers. This helps Whatsapp's server handle more data sent to it, without the company having to invest in more server capacity.</p>
<p><strong>- An Imaginary Scenario</strong><br />Let's imagine that every day, thirty percent(30%) of Whatsapp's daily active users post a 2 Megabytes file size on their status. Let's try to estimate how much in storage alone it would save Whatsapp in 24 hours if they can compress the file size by 60%.</p>
<pre><code class="lang-plaintext">30% of daily active users posts 2 Megabytes of data(video or picture);
30% of 1 billion users = 300 Million users.

300 Million users post 2 Megabytes of data;
-&gt; 600 Million Megabytes of data 

Whatsapp compresses the file and shaves off 60% of its size;
600 Million Megabytes is reduced to 240 Million Megabytes
(40% of 600 Million Megabytes)

1024 Megabytes = 1 Gigabyte (data)
1024 Gigabytes = 1 Terabyte (data)

240 Million Megabytes = 228 Terabytes
600 Million Megabytes = 572 Terabytes

Instead of storing:
572 Terabytes for 24 Hours 
They would only need to store:
228 Terabytes for 24 Hours

Hypothetically;
This saves Whatsapp 343 Terabytes in storage every 24hours
</code></pre>
<p>All of the calculation above is done with assumed data and estimates. I only tried to create a scenario to give a clearer picture of what we're talking about.</p>
<p>If we say storage and electricity cost money, that little data they scrape off your file before sending them to the server, saves them a good deal of money when you add it all up from all of their users around the world. It also makes the servers 'smile in relief' and lets me view your status a bit faster. (😌)</p>
<hr />
<p><strong>Extra Details:</strong><br /><strong>- Where does the Compression happen?</strong><br />All of the compression and file size reduction happens on your device. Whatsapp's application on your phone takes your file and does the compression before sending it off to its servers.</p>
<p><strong>- Is there a way around the file reduction?</strong><br />A way to stop your pictures and videos from being compressed when you send them is to send the file as a document.</p>
<p>Inside the Whatsapp file selector, when you plan to send a file, there are options to send an image, audio, video, or document. Use the document option and find the file you want to send on your device. This way, Whatsapp leaves the file size as is, without compression.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674575779641/bab7b1ba-f0c6-4c0b-ba9a-d4e8773e2f89.png" alt class="image--center mx-auto" /></p>
<p>To increase the upload quality of Photos in Whatsapp, which I think also applies to Whatsapp status updates, there's an option inside Whatsapp settings to select between upload qualities. An image showing how to improve your photo upload quality is placed below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674553071008/563e336f-942a-4346-b519-2e9b758fdd18.png" alt class="image--center mx-auto" /></p>
<p>Whatsapp isn't the only platform or service that reduces file size with compression, platforms like Twitter, Facebook, Instagram, Youtube, Spotify, Netflix, and others do too. They do this to benefit from the reduced storage use and server processing power we earlier mentioned.</p>
<p>So, the next time you send an image or video, or you update your status using WhatsApp and it looks a little less sharp than you'd like, remember that the app is just trying to make sure that everyone can use it, even on slow or limited internet, and to help reduce the load on their servers, which saves them money and improve the performance of their app.</p>
<blockquote>
<p>It's been a lengthy write, if you enjoyed the article and found it useful, you could help this series gain traction by sharing it with others you think would also find it useful.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[What does it mean to mine cryptocurrencies?]]></title><description><![CDATA[At the most basic level, cryptocurrency miners are playing a game of guesses.

At this point, talking about mining or a miner is almost always synonymous with cryptocurrency mining or miners. They are both across different fields, but in certain ways...]]></description><link>https://blog.ebode.dev/what-does-it-mean-to-mine-cryptocurrencies</link><guid isPermaLink="true">https://blog.ebode.dev/what-does-it-mean-to-mine-cryptocurrencies</guid><category><![CDATA[Bitcoin]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Blockchain technology]]></category><category><![CDATA[decentralization]]></category><category><![CDATA[Cryptocurrency]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Mon, 22 Aug 2022 03:49:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1661056411010/cFBynQCpY.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>At the most basic level, cryptocurrency miners are playing a game of guesses.</p>
</blockquote>
<p>At this point, talking about mining or a miner is almost always synonymous with cryptocurrency mining or miners. They are both across different fields, but in certain ways share some similarities. A cryptocurrency miner and an actual miner(someone who obtains mineral resources), both bring into existence or make usable something that wasn't. They both create value from labor, one being physical and the other computational.</p>
<p>For a cryptocurrency like Bitcoin, it is only created by mining(a computational process). People transfer Bitcoins, cryptocurrency exchanges sell you Bitcoins, and the government seizes bitcoins, but the only way it got into anyone's hands was after it was mined. Therefore, <strong>what is mining?</strong> Unlike physical mining, there are no diggers, tractors or persons wearing hard hats at a mining site. Instead, mining is a virtual process that happens within computers. The bigger and better the computer, the higher the chances of mining and finding Bitcoins.</p>
<p><strong>WHY MINING?</strong><br />The first question anyone might ask would be why would I want to mine a cryptocurrency? There are two big answers to that, the first being that, you are incentivized to do so. This simply means you make some money(in the form of the cryptocurrency you are mining) for yourself, I think that's pretty obvious already. The second reason is that while you engage in the mining process, you increase the security of the network and increase its decentralization.</p>
<p><strong>HOW DOES MINING WORK?</strong><br />In previous articles, I talked about a blockchain network operating on a peer-to-peer architecture, with armies of computers or servers(bigger and better computers) that all talk to each other over the network, and abide by the rules and protocols defined in the software they all run.</p>
<p>On a decentralized network (a network where no one/computer has special rights), an acceptable number of participants on the network needs to agree before any decision is made on the network. How an agreement is reached, was one of the problems Satoshi Nakomoto's Proof-of-Work used for bitcoin solved. Simply put, the proof-of-work fairly picks a participant on the network to rule the network for ten minutes every ten minutes. This ten-minute leader is accountable to both the software it is running on and every other participant on the network. The leader has to show everyone that what he did went according to the laid down rule and only when an acceptable number of participants agree, would they take his results and store them on the blockchain. The process of being selected to rule is mining.</p>
<p><strong>WHAT COMPLEX PROBLEM IS GETTING SOLVED?</strong><br />Right at the start, I said mining is simply a guessing game, yeah it is, just complex. Miners try to get a large hexadecimal(base 16) number closest to a number chosen by the network and software. This number is a very very large number</p>
<p>The process of solving starts out like a race, every miner has to initially fill a block body with transactions, which are sourced from the transaction/memory pool and after that, fill up the block header with the right values, these include:</p>
<ul>
<li><p>Previous block hash</p>
</li>
<li><p>Merkle root hash</p>
</li>
<li><p>Timestamp</p>
</li>
<li><p>Difficulty target</p>
</li>
<li><p>Nonce(very important data for miners).</p>
</li>
</ul>
<p>Once all of this is assembled, the call to begin a new race of who solves the new problem first begins immediately after a winner for a previous round is found.</p>
<p><strong>THE HEADERS</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661114883408/DUfUXr_3j.png" alt="header.png" class="image--center mx-auto" /></p>
<hr />
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661129980357/zEo-UHExj.png" alt="field-header.png" class="image--center mx-auto" /></p>
<p><strong>HASHING</strong><br />At this point when the block is completely set up(filled with ), the game of guessing and hashing begins. What does hashing mean? In an earlier <a target="_blank" href="https://ebode.hashnode.dev/what-is-blockchain-technolgy">article</a> talking about web 3.0 technology, I touched on hashing. Simply put, to hash something means to select a word, text, picture, video, music or any digital file and convert it into a fixed length of very random and unpredictable data. The length and other properties of a hash are decided by the hashing algorithm. There are different hashing algorithms. Bitcoin uses the Sha-256 algorithm, while Ethereum uses Keccak-256.</p>
<p>Let's try with examples. If you hash the letter '<em>a'</em> with the sha256 hashing function, you get the resulting hash value:</p>
<pre><code class="lang-plaintext">sha256(a)
output &gt;&gt; ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb
</code></pre>
<p>If you hash letters ( <em>ab</em> )using sha256 :</p>
<pre><code class="lang-plaintext">sha256(ab)
output &gt;&gt; fb8e20fc2e4c3f248c60c39bd652f3c1347298bb977b8b4d5903b85055620603
</code></pre>
<p>If you hash the word ( <em>I am a cryptocurrency miner</em> ) using sha256 :</p>
<pre><code class="lang-plaintext">sha256(I am a cryptocurrency miner)
output &gt;&gt; 3206361d094df9beadf6cec28e3efa6b8e36303206aae99c83148874ab8d2153
</code></pre>
<p>If you hash all the words in the dictionary combined using sha256, you would still get a 64-character length hexadecimal, likewise hashing a 300-hour youtube video or a bitcoin block header, the output would always be 64 characters. These characters are also very random and almost unpredictable.</p>
<p>Hashing should not be mistaken for encryption, in encryption, what is encrypted can be recovered by reversing the encryption process(decryption). Once data is hashed, it can't be recovered, it can only be compared with other hashes. Therefore a hash has to be deterministic(given the same input, a hash function will always return the same output), it also means the hash value for 'ab' should remain the same forever. Another hash function property is that a little change to its input should cause a big and unpredictable change in the output(Avalanche effect).</p>
<p><strong>HOW HASHING IS USED IN MINING</strong><br />Earlier, I mentioned the <strong>nonce in</strong> Bitcoin's block header. A nonce is a number that is used only once in the mining process of Bitcoin. It is a field in the block header of a transaction. Miners repeatedly change the nonce value in the block header, along with other fields such as the timestamp, in an attempt to find a hash lower than the target hash set by Bitcoin's network.</p>
<p>The target hash is adjusted from time to time based on the overall mining power of the network. The mining power is the sum of the number of computers on the network at a particular time mining. It is designed to be a very difficult value to find and it changes over time, making the mining process more challenging as more miners join the network.</p>
<p>The network adjusts the target hash such that a new block is added to the blockchain approximately every 10 minutes. This is called <strong>difficulty retargeting</strong>. The network calculates how long it took for 2016 blocks(about two weeks) to get mined, it compares that time with a time set by the network, if the time to mine 2016 blocks was lesser than the network-defined time, it meant the difficulty had reduced and it would get increased and if it was higher, it meant the difficulty was higher and it would get decreased.</p>
<pre><code class="lang-plaintext">Target Hash : 00000000000000000007bafbad22baee03420dccc0a853ac60673398e66ec8ca
</code></pre>
<p>The more zeroes at the start, the greater the difficulty, it increases exponentially with each zero. If you remember from earlier, any little change to a hash input changes the hash output unexpectedly, it is random and not guessable. To solve the problem, the miner takes the block header of the block it created and hashes it. The goal here is to find a number lesser than the target hash. To keep getting different hash values, the miner keeps changing the value in the nonce field in the block header and for each new value, it compares it with the target hash to see if it is lesser.</p>
<p>An example of a hash with a lesser than the target hash would begin with something like this <em>00000000000000000005. If you observe, you would notice that 5 is less than 7, this is an indicator it is lesser. These are very large numbers and this is one example I could come up with that could easily show which is lesser or greater.</em></p>
<pre><code class="lang-plaintext">Target Hash:⬇️
0000000000000000000(7)bafbad22baee03420dccc0a853ac60673398e66ec8ca

0000000000000000000(5)a1f9e8d7c6b5a4f3e2d1c2b3a4f5e6d7c8b9a0f1e2d3
⬆️:Value lesser than Target Hash
</code></pre>
<p>If a miner finds the lesser-than-target hash while hashing his nonce, the rest of the block header and the block body, he automatically wins that round. Now you see how it is more of a game of guessing. Just that the numbers involved are very very very large numbers which make the game something only computers can play. Also, the process of hashing and comparing is intensive. The more data a computer can hash per second the stronger it is. Mining machines are ranked by that.</p>
<pre><code class="lang-plaintext">Target Hash(base 16 | Hexadecimal):
00000000000000000007bafbad22baee03420dccc0a853ac60673398e66ec8ca
Target Hash(base 10 | Decimal):
740,425,486,432,857,267,178,346,074,642,572,195,919,787,393,044,971,520

Mining:
a game of incredibly large number
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661133986331/pVTXo1jLM.png" alt="validity.png" class="image--center mx-auto" /></p>
<blockquote>
<blockquote>
<p>check the block explorer <a target="_blank" href="https://www.blockchain.com/btc/block/000000000000000000021fffa7d23a20229abf52b6e8c0262e63a504e0e8fd35">here</a></p>
</blockquote>
</blockquote>
<p>The image above is a valid block from Bitcoin's blockchain, you can check it with the link above. The hash circled in orange, was the hash lower than the target difficulty, the miner had to find to win the mining process. The Nonce circled in blue was the magic value his machines had to guess, which he hashed the block header and body to get the winning hash. That is the magic there is to it.</p>
<p>There are situations where miners exhaust all the valid nonce values and still don't find a hash lower than the target hash. In situations like this, a field for ExtraNonce is introduced and used.</p>
<p><strong>MINERS REWARD</strong><br />The process we just talked about is energy intensive and the energy here refers to electricity, which also costs money. Regular computer CPUs can't mine Bitcoin anymore, due to the competition on the network, although it was initially possible. Specialized hardware are used for mining these days.</p>
<ul>
<li><p>GPU (⤵️)</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661135333753/iQykLql6t.jpg" alt="geforce.jpg" class="image--center mx-auto" /></p>
</li>
<li><p>GPU FARM (⤵️)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661136044171/Ia8Qk-Q8Z.jpg" alt="gpu-farm.jpg" class="image--center mx-auto" /></p>
<p><strong>GPU(Graphics Process Units)</strong> were made specifically to handle graphics processing in intensive graphics use environments like Animation rendering, 3D Modeling, Gaming, etcetera. Due to having more strength than CPUs, and also being compatible with mining certain cryptocurrencies, they found a spot in the cryptocurrency mining field. It is especially used in Ethereum Mining.</p>
<ul>
<li><p>FPGA(⤵️)</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661135604092/DboZ8KyYt.jpg" alt="FPGA.jpg" class="image--center mx-auto" /></p>
</li>
</ul>
<p>A <strong>Field Programmable Gate Array (FPGA)</strong> is an electrical circuit that is programmed to carry out one particular logical process. This makes it possible to program an FPGA miner to mine specific cryptocurrencies. However, if necessary, it could be reconfigured to mine a different cryptocurrency. FPGA programming and configuration, however, call for specialized skills.</p>
<ul>
<li><p>ASIC (⤵️)</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661135815847/535Fyph7W.jpg" alt="asic.jpg" class="image--center mx-auto" /></p>
</li>
<li><p>ASIC FARM</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1661135973201/mMffYmnNS.jpg" alt="asic-farm.jpg" class="image--center mx-auto" /></p>
<p><strong>Application-Specific Integrated</strong> <strong>Circuit</strong> (ASIC) are electronic chips that are designed specifically to carry out a given function. One such possible function is to mine a cryptocurrency. ASICs are well used for Bitcoin mining. ASICs are not as flexible as FPGAs.</p>
<p>Buying and using such equipment is expensive. Therefore, miners make sure that their mining covers the expenses involved in setting up and running the whole process.</p>
<p>In most cryptocurrency mining, there is a mining reward for a miner who successfully adds a block to the blockchain. On the Bitcoin network, the mining reward started at 50 bitcoins(2009), but halves every 4 years. It is currently at 6.25 Bitcoins. Other cryptocurrencies follow a similar approach.</p>
<p><strong>SOLO MINING Vs POOL MINING Vs MINING FARMERS</strong><br />A <strong>solo miner</strong> is an individual that sets up his machine(computer or GPU or ASIC or FPGA), to validate, record transactions and propagate transactions on a cryptocurrency's blockchain network. They compete with other miners to solve the cryptographic puzzle.</p>
<p><strong>Pool mining</strong> is more like a community activity, where miners put together all of their machine's power and mine as one entity. This gives them an edge over other miners, especially solo miners. There are two types of mining pools:</p>
<ul>
<li><p>Mining pools that pay miners according to the power they provide to the pool's network.</p>
</li>
<li><p>Mining pools that pay miners only when a block mined by that particular miner is found.</p>
</li>
</ul>
<p>The first option is the most popular, as it means, users don't have to be lucky, they get rewards every day. Popular Mining Pools are <a target="_blank" href="https://foundrydigital.com/">FoundryUSA</a>, <a target="_blank" href="https://www.antpool.com/home">AntPool</a>, <a target="_blank" href="https://www.f2pool.com/">F2Pool</a>, etcetera.</p>
<p>A <strong>Mining Farm</strong> has more is structured corporately. There are shareholders, managers and staff(technicians, electrical engineers, software engineers and lots more). The stakes here are high, and so are the rewards. Farms like this could have thousands and thousands of ASICs mining (24/7)/365. The video below would show what it feels and looks like on a mining farm.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/f0HC1Udk6-E">https://youtu.be/f0HC1Udk6-E</a></div>
<p> </p>
<p>A great deal of energy is used in the mining process where <strong>millions</strong> of miners compete and exhaust electricity only for about <strong>144</strong> miners to be selected each day, there has been a lot of upset amongst people and the government. They want cryptocurrency consensus algorithms to switch to less electricity-demanding mining algorithms.</p>
<p>Bitcoin never really asked for permission before breaking into space and getting accepted, I doubt it would bend now.</p>
<p>This was a long post. I hope you picked up something.</p>
]]></content:encoded></item><item><title><![CDATA[Do we really need the blockchain (picture says it)]]></title><description><![CDATA[Disclaimers or Disclaimers or Disclaimers..🤌..

This is a conversation between a friend and me. This is our view of the crypto space which in no way, tries to undermine the efforts of developers in the space, but should rather be seen as a view into...]]></description><link>https://blog.ebode.dev/do-we-really-need-the-blockchain</link><guid isPermaLink="true">https://blog.ebode.dev/do-we-really-need-the-blockchain</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Bitcoin]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[decentralization]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Wed, 06 Jul 2022 21:16:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1657079351180/oXypB1jOY.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Disclaimers or Disclaimers or Disclaimers..🤌..</p>
</blockquote>
<p>This is a conversation between a friend and me. This is our view of the crypto space which in no way, tries to undermine the efforts of developers in the space, but should rather be seen as a view into our thoughts of the crypto space in the context of its current state.</p>
<p>It touches more on cryptocurrencies rather than blockchain technology in itself, but it's a ride around town on different topics.</p>
<p>The conversation is not pure English, you might have to resort to an in-between filling in the gap. Some parts of the messages have been removed(they were just random and possibly personal).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657141663030/bg9ISll6l.png" alt="page1F.png" class="image--center mx-auto" /></p>
<p>[---- page 1 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657109339354/m7-pC0j6F.png" alt="page2.png" class="image--center mx-auto" /></p>
<p>[---- page 2 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657109700469/ueoECVA2z.png" alt="page3.png" class="image--center mx-auto" /></p>
<p>[---- page 3 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657109973563/JRTE06PLf.png" alt="page4.png" class="image--center mx-auto" /></p>
<p>[---- page 4 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657141964824/maF22JZb6.png" alt="page5F.png" class="image--center mx-auto" /></p>
<p>[---- page 5 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657192664100/xTNgsilUT.png" alt="page6F.png" class="image--center mx-auto" /></p>
<p>[---- page 6 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657111151504/RvU5ZIPcc.png" alt="page7.png" class="image--center mx-auto" /></p>
<p>[---- page 7 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657111447574/b79NuqoQW.png" alt="page8.png" class="image--center mx-auto" /></p>
<p>[---- page 8 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657111833502/_HllbGADB.png" alt="page9.png" class="image--center mx-auto" /></p>
<p>[---- page 9 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657112062001/V-HcVf87A.png" alt="page10.png" class="image--center mx-auto" /></p>
<p>[---- page 10 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657112355148/-f9yvfkZh.png" alt="page11.png" class="image--center mx-auto" /></p>
<p>[---- page 11 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657112728017/BU4Lmk-MT.png" alt="page12.png" class="image--center mx-auto" /></p>
<p>[---- page 12 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657113155363/vSdnN_5aM.png" alt="page13.png" class="image--center mx-auto" /></p>
<p>[---- page 13 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657113439509/WhsOE0TGa.png" alt="page14.png" class="image--center mx-auto" /></p>
<p>[---- page 14 (above)]</p>
<p>[ --------------------- Later that day --------------------- ]  </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657217195058/xLYcnbQSy.png" alt="page15.png" class="image--center mx-auto" /></p>
<p>[---- page 15 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657217073081/RgJMgRW2P.png" alt="page16.png" class="image--center mx-auto" /></p>
<p>[---- page 16 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657217452609/YU79DcyUZ.png" alt="page17.png" class="image--center mx-auto" /></p>
<p>[---- page 17 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657217685314/prf9v1gz-.png" alt="page18.png" class="image--center mx-auto" /></p>
<p>[---- page 18 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657217972974/ldgLuMnA9.png" alt="page19.png" class="image--center mx-auto" /></p>
<p>[---- page 19 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657218434000/_YWCAkA0O.png" alt="page20.png" class="image--center mx-auto" /></p>
<p>[---- page 20 (above)]</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1657218793982/d2Sr_t6iU.png" alt="page21.png" class="image--center mx-auto" /></p>
<p>[---- page 21 (above)]</p>
<p>This is a lot, but yeah, eventually it came to an end, and the conversation was great. It's between two guys still trying to find out more and understand the decentralized/blockchain space.</p>
<p>Again, this conversation is heavily opinionated, tread gently.</p>
<p>[Thanks for your time]</p>
<blockquote>
<p>To reach out to <a target="_blank" href="https://twitter.com/devteepy"><strong>Tobi</strong></a>, that's his birdy handle.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Nakamoto's Consensus]]></title><description><![CDATA[How do you maintain order and sanity in an organization without a central authority, whilst still making sure the majority of everyone is on the same page??

Maintaining order in a system or environment without a centralized authority or governing bo...]]></description><link>https://blog.ebode.dev/nakamotos-consensus</link><guid isPermaLink="true">https://blog.ebode.dev/nakamotos-consensus</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Bitcoin]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[decentralization]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 24 Apr 2022 03:55:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1656043400294/u1XFzrxpi.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>How do you maintain order and sanity in an organization without a central authority, whilst still making sure the majority of everyone is on the same page??</p>
</blockquote>
<p>Maintaining order in a system or environment without a centralized authority or governing body and where every individual within the system have equal power to make decisions and influence the direction of the network becomes a very complex task. This is the same dilemma decentralized systems face. The decentralized system has to ensure that even with the presence of malicious actors, it can still work efficiently and at some point, kick the bad actors off its network. There is also the problem of how to ensure all participants on the system/network agree on how to move forwards. The agreements make it such that all the participants have a consistent view of the state of the system, ensure there is no central authority to impose a single version of the truth and avoid confusion, mistrust, and ultimately, the failure of the system. This agreement is called a 'Consensus'.</p>
<p><strong>CONSENSUS</strong><br />A consensus is simply a general agreement. A general agreement, wherein the majority of individuals within a group or system decide on a course of action. A simple example of this would be the process of how five roommates decide if the lights in the room should be turned off or on at night. For any decision to be reached, not less than three of the roommate must pick any one of the options.</p>
<p>Agreement within a decentralized system is exponentially tougher than in the example above. Here, participants are nodes across the network all over the world. Rules on how decisions can be made, the impact of decisions, and the requirements to participate in the decision-making process all have to be stated right from the onset.</p>
<p>A system like this should be able to handle a wide variety of cases, normal cases, malicious cases, incorrect cases, biased cases and other cases and scenarios. The first efficient, usable and accepted solution to succeed in being able to both handle such decision-making complexity and also continuously exist in a decentralized manner, was Bitcoin, which it implemented with its Nakamoto Consensus spelled out in its white paper.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1655931350057/mV2djclqQ.png" alt="bitcoin's white paper.png" class="image--center mx-auto" /></p>
<p>The writing in Nakamoto's white paper proposed block selection and proof of work mechanism used in Bitcoin till today. It created a system to incentivize honest miners and also make the system trustless. The fact that bitcoin as a decentralized peer-to-peer electronic cash system is successful, answers the question asked at the beginning of this article and this article, goes on to explain how it was answered.</p>
<h2 id="heading-nakamotos-consensus">NAKAMOTO'S CONSENSUS</h2>
<p>The implementation of Nakamoto's Consensus is why bitcoin is trusted even though it's trustless. Nakamoto's consensus is a set of rules that verify the authenticity of a peer-to-peer network which is itself based on the Byzantine Fault Tolerance(BFT) model. BFT was born out of a logical problem, 'The Byzantine's General Problem', where a supposed set of Eastern Roman Empire Byzantine generals had to come up with a solution to handle combining forces in a war attack scenario, where communication might be a problem.</p>
<p>Take a look at the Byzantine Generals Problem paper <a target="_blank" href="https://www.microsoft.com/en-us/research/uploads/prod/2016/12/The-Byzantine-Generals-Problem.pdf">here</a>.</p>
<p>In this theory, generals at different geographical locations in the war had to make a coordinated decision to either attack or not attack a common enemy in war. A single general's army can't single-handedly attack and win the war, rather a joint force from all the army generals is required to secure a win. They had to all agree on either attack or not, once a decision is reached, it could not change and they also all had to attack at the same time and there was the possibility of having rogue generals. Looking at it, the problem centered around communication. How would they all communicate with each other quickly enough, securely and be sure every general got the message?</p>
<p>Applying this to the Blockchain's context, the generals are nodes and the nodes have to agree(come to a consensus) on the state of the network, even in the presence of evil generals(malicious nodes).</p>
<p>All of this eventually led to the development of highly fault-tolerable systems in the real world.</p>
<p><strong>How it fits into the big picture</strong><br />We've already touched on the cores in the consensus, but how this fits into bitcoin's blockchain architecture might still seem vague. To see the picture clearer, we have to take a look at what Bitcoin's Blockchain network has to do to achieve a stable network;</p>
<ul>
<li><p>Organize the network of individuals to agree on the generation of a new block</p>
</li>
<li><p>Select a miner fairly from the network.</p>
</li>
<li><p>Collect all the transactions from all over the network and write them into the blocks and make sure the majority of everyone on the network sees and agrees to it quickly enough.</p>
</li>
<li><p>Give a good reason for anyone to be a part of the network or contribute computational power.</p>
</li>
<li><p>Make sure participants who provide computational power to the network(miners) do not act irrationally or act maliciously.</p>
</li>
</ul>
<p>The question goes on and on. Nakamoto's answer to these questions came in the form of 'Proof of Work'.</p>
<h2 id="heading-proof-of-work">PROOF OF WORK</h2>
<p>The proof of work consensus algorithm solved major problems, which in turn solved other problems till a stable and usable system emerged. These problems include:</p>
<ul>
<li><p>Problem I:: Fair miner selection and Incentivizing miners</p>
</li>
<li><p>Problem II:: Block creation, Transactions entry, Block propagation, Block validation</p>
</li>
<li><p>Problem III:: Security and longest chain rule</p>
</li>
</ul>
<p>How is a miner selected and how does that happen fairly was one question I always asked myself while learning how all this worked. On the bitcoin network, there are over 200,000 nodes(a rough estimate), that take part in the decision-making, validation and mining process. Not all of the nodes on the blockchain are mining nodes. They carry out different actions based on their nature. There are full nodes, light nodes and mining nodes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656006881441/g9lNMTSTb.png" alt="bitcoin nodes.png" class="image--center mx-auto" /></p>
<p>No entity or authority selects a miner, doing this would betray the whole idea of decentralization. Instead, one miner is selected amongst thousands of others every ten minutes based on their speed in solving a cryptographic puzzle generated by Bitcoin's core protocol. The process of solving the puzzle is mining.</p>
<h3 id="heading-mining"><strong>MINING</strong></h3>
<p>What miners do when they mine, is to gather all valid transactions that could be fitted into a block from the memory pool(temporary storage for transactions on the network before they are recorded into a block). The miner creates a new block, orders the transactions into the block, writes a valid header for the block and then shows other miners the block, so they can verify its validity before appending it to the existing chain of blocks. For a deep dive into cryptocurrency mining, I wrote an article <a target="_blank" href="https://ebode.hashnode.dev/what-does-it-mean-to-mine-cryptocurrencies">here</a>.</p>
<p>A block header has different fields, but for mining, the most important field is the <strong>Nonce</strong> header field. The image below shows the different fields in Bitcoin's block header.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656001440185/Ea3oKAw7i.png" alt="bitcoin block header.png" class="image--center mx-auto" /></p>
<h3 id="heading-reward-system"><strong>REWARD SYSTEM</strong></h3>
<p>For any miner who successfully creates a new block, the first transaction written into the block is a Coinbase transaction. A Coinbase is the only transaction that creates Bitcoin. It creates Bitcoin out of thin air as a reward for the computational power provided by the miner and transfers it to the wallet address of that miner. The reward given to the miner was defined early in the development of Bitcoin's system by Satoshi Nakomoto. The reward to the miner gets halved over the years till it gets to zero. The reward started at fifty(50) Bitcoins per miner and it's currently at 6.25 Bitcoins.</p>
<p>The mining reward gets halved over time to control the rate at which new Bitcoins are created and released into the market. This halving happens after every 210,000 new blocks are created. It takes an average of about 10mins for a new block to be created and added to the Bitcoin network. Doing the maths,</p>
<pre><code class="lang-plaintext">10mins(block creation) * 210,000(blocks mined before reward halving) 
= 2100000mins(for every halving);

2100000mins / 1440mins = ~ 1458days;
(1day = 1440mins)

1458days / 365days = ~ 4years;
</code></pre>
<p>From above, we see why the bitcoin mining reward halving happens every 4years. right from the inception of bitcoin. The Bitcoin mining milestone is shown below:</p>
<ul>
<li><p>(2009) - 50 Bitcoins rewarded to miners.</p>
</li>
<li><p>(2013) - 25 Bitcoins rewarded to miners.</p>
</li>
<li><p>(2017) - 12.5 Bitcoins rewarded to miners.</p>
</li>
<li><p>(2021) - 6.25 Bitcoins rewarded to miners.</p>
</li>
<li><p>(2025) - Next halving to 3.125 Bitcoins would occur.</p>
</li>
<li><p>(2140) - The supposed final halving would occur.</p>
</li>
</ul>
<p>This reward helps miners offset their running expenses. Bitcoin mimics gold scarcity with the halving and mining process, it also keeps the value of existing bitcoins stable, as there can only ever be twenty-one million coins.</p>
<h3 id="heading-longest-chain-rule">LONGEST CHAIN RULE</h3>
<p><strong>CHAIN SELECTION</strong><br />While I was learning, a question popped into my head, wasn't it possible for two or more miners to find a valid block at the same time, what happens then? This question leads us to the next property of Nakamoto's consensus.</p>
<p>There is a possibility of multiple miners finding and propagating new blocks onto the network simultaneously, it only happens to be rare though. Let's paint a scenario of what happens and how it does in one such case.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674311947038/a58311b9-fe9e-4c17-aec9-ab0bb7922250.png" alt class="image--center mx-auto" /></p>
<p>Let's assume two miners on different ends of the network find a valid hash and create a new block, this block is sent to the network for validation and storage. One thing to note is that miners are allowed to pick transactions randomly and fill them into their block, this means every miner's blocks contain different transactions and the Coinbase reward also is sent to different addresses(the different miners). This would mean that nodes on the chain now have different data and the chain is no longer unified. To resolve this, the <strong>'longest chain rule'</strong> is applied. The longest chain rule enforces prioritizing the chain with the highest number of blocks preceding. Blocks preceding a newly created block are tracked with the 'block-height' field in the block's header.</p>
<p><strong>How the longest chain rule is implemented</strong><br />Earlier, I said every node on the blockchain gets out of sync when two miners find and contest for the same block creation, and its reward. How then is a miner decided as the final creator? The two miners are allowed to keep their block and reward, but a miner is chosen based on the next miner who finds the newest block. When a new miner finds a new block, the block on which they find this new block becomes the top priority block, because now it is longer, and the next miner after that adds their new block onto the longer chain and on till the length is decided to be finalized, without the possibility of ever reverting.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1674312119953/3a2176ea-fc04-49fe-af63-406d65c6f40d.png" alt="Blockchain image attempting to solve the fork situation" class="image--center mx-auto" /></p>
<p>In the image above, the two miners we mentioned created blocks <strong>Y</strong> and <strong>Y2</strong> simultaneously, creating an imbalance. The two miners then had to wait for a new miner to decide who stays, the new miner created block <strong>Z</strong> and linked it to block <strong>Y</strong>, deciding that Block Y stays.</p>
<p>All the transactions in the unaccepted block put back into the memory pool by the miner that mined them and the nodes that took that miner's block, this is is called block re-organization. This situation is what leads to the concept of FINALITY( when it is sure that a transaction can no longer be returned to the memory pool). Exchanges have to be sure a transaction is final so that they do not pay customers, only for the transaction to send their asset to the exchange to get reversed later. If this happens, the exchange would be at a loss.</p>
<p>For bitcoin, the accepted block finality is after a 6-blocks depth. A block takes on average ten minutes to be mined, 6-blocks finality time would equal one hour.</p>
<p>The block with the longer chain continues to get linked to, while the rejected block becomes stale. The stale block is referred to as an ORPHAN BLOCK on bitcoin and the miner for that block doesn't get any reward. On Ethereum, it used to be called an UNCLE BLOCK, now it is called an OMMER BLOCK the miner gets a small reward for their efforts.</p>
<h3 id="heading-security"><strong>SECURITY</strong></h3>
<p>All of these parts come together to create a balanced and secured blockchain network. Security features put in place on the blockchain network(using Bitcoin as a reference), include:</p>
<ul>
<li><p>Miners are randomly selected</p>
</li>
<li><p>The network difficulty adjusts to the number of nodes on the network(increases or decreases to make sure block creation time stays in range).</p>
</li>
<li><p>Miners are incentivized to do the right thing. Other nodes and miners validate a miner's generated block, if it doesn't meet the criteria, it is not recorded and discarded and they lose their reward.</p>
</li>
</ul>
<p>For an entity to successfully control or hijack a blockchain's network, they would need to control more than half of the nodes on the network(51%), which would enable them to create the longest chain and only let in transactions they want. This is called a 51% attack, it is also limited in what it could do, as every transaction on the blockchain requires a signature from the account holder before it can become valid. This means the attacker can't steal bitcoin from other accounts.</p>
<p>As of 24th of April 2022, <a target="_blank" href="https://www.blockchain.com/explorer?view=btc">blockchain.com</a> puts the hashing power on the Bitcoin network to over 216 quintillion hashes per second (216,000,000,000,000,000,000 h/s) [ 216 Exahash per second] power on the network, so for any one entity to get more than half of this, would cost way much that it would for any reasons they might want to, there sure would almost be no financial gain at that point. Also, as such actions would send people running off the network, the value and use of the network, would almost immediately become worthless.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1656041335621/iKx_sdgIw.png" alt="powerrrrr.png" class="image--center mx-auto" /></p>
<p>This is a lot to take in, but if you can, it's fun and worth the time. I'll leave links to resources I found useful while learning and writing this article.</p>
<p><strong>RESOURCES</strong></p>
<p>#&gt;: <a target="_blank" href="https://en.wikipedia.org/wiki/Byzantine_fault">Byzantine Fault</a></p>
<p>#&gt;: <a target="_blank" href="https://bitcoin.org/en/resources">BITCOIN.ORG RESOURCE</a></p>
<p>#&gt;: <a target="_blank" href="https://en.wikipedia.org/wiki/Byzantine_fault">Byzantine Fault</a></p>
<p>#&gt;: <a target="_blank" href="https://golden.com/wiki/Nakamoto_consensus-AMB5VWM">Golden's page on Nakamoto's Consensus</a></p>
<p>#&gt;: <a target="_blank" href="https://bitcoin.org/bitcoin.pdf">BITCOIN's WHITE PAPER</a></p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/CdyDoCk8IKs">https://youtu.be/CdyDoCk8IKs</a></div>
<p> </p>
<p>Crypto Economic's channel on Nakamoto's Consensus</p>
]]></content:encoded></item><item><title><![CDATA[Generations of Blockchain]]></title><description><![CDATA[Art challenges technology and technology inspires art. - John Lasseter (American film director)

I admire one-liner intros, AD does too. It attempts to give an overview of the article, as smoothly as possible, right from the beginning. New technology...]]></description><link>https://blog.ebode.dev/generations-of-blockchain</link><guid isPermaLink="true">https://blog.ebode.dev/generations-of-blockchain</guid><category><![CDATA[Web3]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[Bitcoin]]></category><category><![CDATA[Solidity]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 03 Apr 2022 03:13:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1653831102915/SU7yWZRgQ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Art challenges technology and technology inspires art. - John Lasseter (American film director)</p>
</blockquote>
<p>I admire one-liner intros, AD does too. It attempts to give an overview of the article, as smoothly as possible, right from the beginning. New technology gets created due to creativity and curiosity or sometimes by accident, we begin to use it, our need from the technology, and our creative use pushes the development of said technology in an almost endless cycle.</p>
<p>The generations of blockchain do not have an explicitly defined milestone, rather it is an observation of how the use case and properties of the blockchain technology have evolved and improved over time.</p>
<p>Each new generation builds on the previous generation and introduces improvement and efficiency to the older generation. In the blockchain space, the first generation made what seemed impossible, possible. The second generation after that built a computer on the chain, the generation we could call the third, brought power efficiency, speed and interoperability improvements into the space. Let's get into more details.</p>
<h2 id="heading-first-generation-blockchains">First Generation Blockchains</h2>
<p>The first generation of applications on the blockchains, notably Bitcoin and any other chains that adhered to a similar protocol. The Bitcoin blockchain was that one chain that proved that a trustless decentralized monetary system was possible. Its core functionality, rested on the shoulders of cryptography, peer-to-peer networking, and a proof-of-work consensus mechanism specifically, Nakamoto's consensus.</p>
<p>In that generation, it wasn't just bitcoin. Another notable chain developed after Bitcoin was Tenebrix, it imitated bitcoin but changed some functionality under the hood.</p>
<p><strong>TENEBRIX</strong><br />Tenebrix replaced the SHA-256 rounds in Bitcoin's mining algorithm with the Scrypt function, this would allow Tenebrix to be "GPU-resistant" making it possible for regular people with CPUs to be miners. It never took off, because people criticized the creator for pre-mining 7.7 million Tenebrix(TBX ) for himself at no cost.</p>
<p>Q &amp; A on Tenebrix by the creator from 2011 <a target="_blank" href="https://bitcointalk.org/index.php?topic=45667.0">here</a></p>
<p><strong>LITECOIN</strong><br /><a target="_blank" href="https://en.wikipedia.org/wiki/Charlie_Lee_(computer_scientist)">Charlie Lee</a>, a Google employee at the time created an alternative version of Tenebrix called Fairbrix (FBX) and eventually went on to create Litecoin. Litecoin used the scrypt function, and took other characteristics from Bitcoin, but was faster and had lesser fees.</p>
<p><strong>DOGECOIN</strong><br />Dogecoin climbed out in the early 2014s, initially released in 2013, it is considered both the first meme coin and more specifically, the first dog coin. It is also based on Scrypt's algorithm, and the transaction process is more convenient than Bitcoin. Dogecoin takes only 1 minute to confirm, while BTC takes 10 minutes.</p>
<h2 id="heading-second-generation-blockchains">Second Generation Blockchains</h2>
<p>The next Blockchain generation decided to improve on the first generation. This generation took a huge leap forward by creating a Turing complete blockchain(a system that could process and solve any logically complete computational problem). Simply put, it built a computer into the blockchain, so now users aren't restricted to just making transactions, but rather their imaginations on what programs they could build on the computer. They created programs compatible with the blockchain using smart contracts. Smart contracts are programs stored on a blockchain that run when predetermined conditions are met.</p>
<p>One notable chain in this generation is the Ethereum chain, which is not Turing complete, but Quasi-Turing complete instead, this means that all execution processes are limited to a finite number of computational steps(simply put, it won't execute a program that would run forever). With Ethereum, smart contracts became a thing, which then birthed a whole ecosystem of programs, utilities and communities. This includes the developments of tokens(fungible and non-fungible), which themselves are a type of smart contracts, decentralized autonomous organizations(DAOs), Oracles, etcetera, the list is endless.</p>
<p>This innovation quickly made Ethereum a hub for many applications (Decentralized Apps), but this rapid growth on Ethereum came at a cost and the chain almost immediately began to suffer from scaling problems.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1654135122845/rG3vQPq-_.jpeg" alt="Ethereum gas use meme image" class="image--center mx-auto" /></p>
<ul>
<li><a target="_blank" href="https://medium.datadriveninvestor.com/rollups-ultimate-solution-to-cheaper-faster-ethereum-transactions-part-1-f7002f3003d">Image(src) and more on Ethereum's scaling solutions</a></li>
</ul>
<p><strong>ETHEREUM</strong><br />The scaling issues with Ethereum quickly lead to different developers rushing to come up with different solutions. Most solutions are divided into two sections, on-chain(Layer1) solutions and off-chain(Layer2) solutions. I wrote an <a target="_blank" href="https://ebode.hashnode.dev/the-blockchain-trilemma">article</a> covering the subject.</p>
<p>Much of the talk on the second generation has been on Ethereum, while it is not the only chain in this category, one of its co-founders Vitalik Buterin was the individual that popularized the idea of a blockchain that was computationally capable.</p>
<p><strong>NEO</strong><br />Neo launched as antshares in 2014, it was created by Da Hongfei and Erick Zhang, and it was later rebranded to Neo in 2017. Neo is a platform on top of which anyone can transact and create decentralized products and services with its NeoContracts. It is sometimes referred to as the “Ethereum of China”. NeoContracts is quite different in the sense that developers can build applications on it using existing languages (like C# and Java), rather than learning a new language like Solidity or Vyper used to write Ethereum's smart contracts.</p>
<p>More recent chains that do what Ethereum does now would include, Solana, Avalanche, Fantom and Ethereum Classic.</p>
<h2 id="heading-third-generation-blockchains">Third Generation Blockchains</h2>
<p>The present blockchain generation took another step forward, bringing, improvements, efficiency, scalability and interoperability to the blockchain realms. One of the major issues facing blockchain is scaling, Bitcoin remains troubled by its slow transaction processing time and bottlenecks. Ethereum users also suffer from high transaction costs from its gas payment infrastructure defeating the promise of being cheap and accessible to everyone. Many new blockchains have attempted to solve these problems with varying levels of success. The attempts of making chains scalable, interoperable and cheap ushered in the new generation.</p>
<p>Some of the blockchains with that goal and drive at the forefront of solving the problems include, Cardano and Polkadot, both of whose creators were formerly Ethereum's Co-founders. It's a trail of Ethereum everywhere.</p>
<p><strong>CARDANO</strong><br />Cardano can already process thousands of transactions per second using their Hydra node system. It can also scale to making millions of transactions per second if the need arises. It runs on a proof-of-stake consensus algorithm, bringing power usage and efficiency to the game. Transaction costs are also very low in cents. Confirmation time is also within minutes. Though it did not start out having smart contracts built in, an upgrade happened in late 2021 that brought in the feature.</p>
<p><strong>POLKADOT</strong><br />Polkadot can also process thousands of transactions per second with the possibility of scaling up to millions like Cardano. It also operates on a proof-of-stake consensus algorithm. Polkadot's ecosystem is more developed than Cardano’s ecosystem currently, with projects such as Kusama and Ocean Protocol already on the blockchain. Its development is going rapidly which is what the space needs. Polkadot was started by Gavin Wood, the same guy that created solidity, wrote the first set of testnets on Ethereum and lead the team that wrote the Parity Ethereum software client, written in Rust.</p>
<p>There is still a lot coming up ahead, that we have no idea of or how it would impact our everyday life, but as long as our needs from this technology continue to increase, the technology would continuously improve and keep up as well.</p>
<p><strong>What a time to be alive!</strong></p>
]]></content:encoded></item><item><title><![CDATA[Blockchains and Oracles]]></title><description><![CDATA[There is an African saying; (more likely Yoruba) ::>

A single tree can't make a forest

This also goes for a blockchain network. A stand-alone chain/network is only as powerful as the data it can handle. As blockchains attain the computationally pow...]]></description><link>https://blog.ebode.dev/blockchains-and-oracles</link><guid isPermaLink="true">https://blog.ebode.dev/blockchains-and-oracles</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Bitcoin]]></category><category><![CDATA[Oracle]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 27 Mar 2022 02:05:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1650267249077/5vn21AioC.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There is an African saying; (more likely Yoruba) ::&gt;</p>
<blockquote>
<p>A single tree can't make a forest</p>
</blockquote>
<p>This also goes for a blockchain network. A stand-alone chain/network is only as powerful as the data it can handle. As blockchains attain the computationally powerful helm, it would be a bummer if they could not communicate with other chains or the real world for live data.</p>
<p>This article aims to touch on what an oracle is(in the blockchain context), its use cases, and a little on the types of oracles.</p>
<h3 id="heading-what-is-an-oracle">What is an Oracle?</h3>
<p>An Oracle is a bridge between on-chain data and off-chain data in a blockchain network. The next question that would pop up then would be, what are off or on-chain data and what do they do?</p>
<ul>
<li><strong>On-Chain Data</strong>: In a previous <a target="_blank" href="https://ebode.hashnode.dev/what-is-blockchain-technolgy">article</a>, we talked about the structure of the blockchain and how it works. On a blockchain network, some nodes participate in creating and validating transactions and also keeping the network safe. Most blockchain networks are built to guarantee uniformity. Uniformity in this context means everyone has the same data, therefore they can all agree on how to move forward(Consensus). If the data available to participants on the network for one reason or the other goes out of sync, multiplied across the possible thousands of nodes on the network, chaos would rip through the network and break it down.</li>
</ul>
<p>This data available within the blockchain network is the on-chain data. The on-chain data consists of all information written into blocks, most of which are transactional data(user A transferred D amount to user B ) 'A, D and B' are data. There is also the block's metadata( information about a block in the blockchain ), all of this makes up the data on the chain(on-chain).</p>
<ul>
<li><p><strong>Off-Chain Data</strong>: It's any data that comes from the outside world (outside the blockchain network). Off-chain data is not limited to anything as long as it can be computed and transferred, it is valid. Examples of off-chain data include::</p>
<p>  <strong>[-]</strong> Total number of astronauts aboard the International space station and their names.</p>
<p>  <strong>[-]</strong> Long Tennis player's global ranking and their points.</p>
<p>  <strong>[-]</strong> Scores from a football match</p>
<p>  <strong>[-]</strong> Prices of stock and assets in the real world.</p>
</li>
</ul>
<p>Almost any type of data from the real world can be regarded as off-chain data. A simple definition of off-chain data is that it is information that cannot be generated or would rarely be created on the blockchain but rather gotten from outside it.</p>
<p>Back to the definition of an oracle, it is an entity, program, tool, medium or bridge that brings data from the outside world onto the blockchain network.</p>
<h3 id="heading-whats-the-need-for-off-chain-data-on-the-blockchain">What's the need for Off-chain data on the blockchain?</h3>
<p>Yeah, right. Why?</p>
<p>Initially, everyone was satisfied with how the first generation of blockchain worked(majorly Bitcoin). It made the transfer of value to anywhere in the world, possible and faster in comparison to banks, it also served as a store of value.</p>
<p>As humans, we always want things to be better and strive to improve things, this is good, as it is what fuels development. We realized Bitcoin had its limitations and developers began to make proposals to improve Bitcoin's core structure. This created friction among blockchain developers and eventually lead to the creation of multiple factions, one of which is Bitcoin cash. Developers eventually agreed to build on top and around Bitcoin, but not rebuild.</p>
<p>Things like colored coins popped up, the lightning network and other infrastructures/systems to extend Bitcoin capabilities. It was at this point Vitalik Buterin(co-founder of Ethereum), had the brilliant idea to create smart contracts(codes that lived and got executed on the blockchain). This brought about a paradigm shift in the blockchain space and gave it new powers. I am beginning to diverge away from the main point. I think I'll write about the generations of blockchain in the next article, for now, Let's get back to Oracles.</p>
<p>Off-chain data became important with the existence of smart contracts. It meant the blockchain wasn't just for recording transactions, developers could now write codes to perform tasks. Once the code(smart contract) is put up on the blockchain, it was nearly impossible to stop except explicitly determined by the creator at the time of creation. Executing a smart contract is as simple as interacting with its address.</p>
<p>This new shift meant developers could write smart contracts to do almost anything, but there was a big limitation, they could only use data that was available on the chain. Blockchains at the time were designed to be independent.</p>
<p>Problems like the absence of a source of true randomness(some dev tried finding ways around it, but most were vulnerable to exploits) and others popped up. They were left to use data from the chain. Some beautiful things happened in the space even with these limitations. Tokens became a thing, Fungible Tokens following the ERC-20 standards, Non-Fungible Tokens following ERC-721, etcetera. Decentralized exchanges came alive using Automated Market Makers, instead of order books(this enabled users to exchange their tokens), there were automated IEOs(Initial Exchange Offerings) and other creative innovations with smart contracts and on-chain data. There was more that could happen if there was a way for developers to get access to external data. Then this happened, and Oracles came to the aid of mortal developers.</p>
<p>In essence, off-chain data brings a whole new range of possibilities to writing smart contracts. Oracles came around and it became possible to write Insurance smart contracts that settled individuals based on what happens in the outside world, betting on sports became a thing, and true randomness could now be gotten and used in games and programs like random NFT purchases, gambling(flipping a coin or dice on the chain), etcetera. One other important thing is that oracles also give smart contracts the ability to call APIs in the regular web2 world.</p>
<h3 id="heading-a-question">A question</h3>
<p>If we say the blockchain is decentralized(no central authority) and a smart contract is almost impossible to change when up there, and now smart contracts on the blockchain depend on Oracles who get data from a centralized world, isn't that defeating the purpose of decentralization? How do we trust the oracle? So many things could go wrong with smart contracts if an Oracle goes rogue.</p>
<p>Hey! easy, oracle developers have had those same thoughts and worries too. Almost everyone in space within the early Oracle days thought about this same issue too, and there happened to be a solution. They are called <strong>'Decentralized Oracles'</strong>. These oracles do not get their data from a single source, rather they aggregate data from across multiple sources and weigh them with the aid of algorithms to pick the most trusted data entry. This put everyone's fear to rest.</p>
<h3 id="heading-how-oracles-work">How Oracles work</h3>
<p>Oracles work almost the same way smart contracts do, they can talk to other smart contracts, they can be interacted with via their address and other contracts can place listeners to know when an event occurs or changes. One big difference between a regular smart contract and an Oracle is that it has a component that lets it talk to the outside world. In the case of Ethereum, it talks via JSON-RPC ( a communications protocol for Ethereum blockchain nodes).</p>
<p>To complete the communication channel, there is a system on the outside world that collects all real-world data in a decentralized manner as we earlier discussed, and on a request, passes the data from the off-chain systems onto the listening smart contract on the blockchain network. Other smart contracts would then reach out to that smart contract to request and use its data at a fee. Examples of Oracle service providers include::</p>
<ul>
<li><p><a target="_blank" href="https://chain.link/">Chainlink</a></p>
</li>
<li><p><a target="_blank" href="https://witnet.io/">Witnet</a></p>
</li>
<li><p><a target="_blank" href="https://provable.xyz/">Provable</a></p>
</li>
<li><p><a target="_blank" href="https://paralink.network/">Paralink</a></p>
</li>
<li><p><a target="_blank" href="https://dos.network/">Dos.Network</a></p>
</li>
</ul>
<p>In summary, an oracle is a tool(the smart contract and the external data aggregation system) that allows smart contracts to access data or external events from outside the blockchain network. It acts as a bridge between the smart contract and the external world.</p>
<h3 id="heading-types-of-oracle">Types Of Oracle</h3>
<p>Due to the nature of the JSON-RPC commonly used by nodes to communicate, this means communication could go in two ways, into the blockchain network or out of the network, creating a range of possibilities.</p>
<ul>
<li><p><strong>Input/Inbound Oracles</strong> :&gt;&gt; This type of oracle transmits data from external sources(real-world) into the chain, it's the most common way oracles are used.</p>
</li>
<li><p><strong>Output/Outbound Oracles</strong> :&gt;&gt; Data or commands are sent out, to real word systems( a listening computer ), which on receiving the data or command, triggers it to take an action. One example of such would be sending a command with data for a task that would be too computationally expensive to do on-chain, the result is later fed back on-chain after processing.</p>
</li>
<li><p><strong>Cross-chain Oracles</strong> :&gt;&gt; The oracles can both listen and send commands to more than one blockchain. This enables data sharing amongst different blockchains, making them interoperable.</p>
</li>
</ul>
<p>We have come to the end of this article. This was just a scratch on Oracles, there's still so much involved, but the aim of the article was to subtly touch on oracles as smoothly as possible.</p>
]]></content:encoded></item><item><title><![CDATA[The Blockchain Trilemma]]></title><description><![CDATA[In the beginning, was a block, the chain was good but the blockchain shied away from perfection.

Earlier we touched on Blockchain technology, its types, its use cases, and the possible improvements it would bring into the tech space in the coming ye...]]></description><link>https://blog.ebode.dev/the-blockchain-trilemma</link><guid isPermaLink="true">https://blog.ebode.dev/the-blockchain-trilemma</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[Bitcoin]]></category><category><![CDATA[Web3]]></category><category><![CDATA[decentralization]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 20 Mar 2022 18:02:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674487253813/863d8fe9-9b41-4071-97ce-c350fbe7d72a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>In the beginning, was a block, the chain was good but the blockchain shied away from perfection.</p>
</blockquote>
<p>Earlier we touched on Blockchain technology, its types, its use cases, and the possible improvements it would bring into the tech space in the coming years.</p>
<p>Like everything or any technology, perfection is impossible. In this article, we discuss the three major properties(scalability, security and decentralization) the blockchain attempts to have at the same time but that remains elusive, mainly due to its design structure and the type of service it offers.</p>
<p>The inability of a blockchain system to equally cover or have all of the three earlier properties mentioned is known as the 'Blockchain Trilemma'. Vitalik Buterin(Co-Founder of Ethereum) described the trilemma as a situation where a blockchain can't be decentralized, secured and at the same time highly scalable, instead, certain properties are reduced or increased to create balance. This statement has been heavily contested, but in the end, it stayed proven and true.</p>
<p>💡| Ethereum is one of the most active blockchains. It is, has and is still being battle tested. The devs in charge, take a great deal of caution and precaution making core changes.</p>
<h2 id="heading-the-trilemma">THE TRILEMMA</h2>
<p>The perfect blockchain has the best security, scales easily and is fully decentralized. But just like an individual in real life, we don't get to have everything, how we manage what we have and strive for better defines us. This analogy resonates with what's happening in the blockchain space. Let's go over the properties a chain seeks to have.</p>
<h3 id="heading-decentralization">DECENTRALIZATION</h3>
<p>This refers to the distribution of the blockchain network's power and decision-making authority among its participants, rather than having a central authority control the network. This allows for a more democratic and transparent system, as no single entity holds disproportionate power over the network. If a decision is to be made, there has to be a form of consensus(agreement).</p>
<h3 id="heading-security">SECURITY</h3>
<p>The blockchain has serious defense mechanisms in place against malicious actors, preventing them from doing stuff like overwhelming the network(a 51% attack) to manipulate data and then going ahead to cause things like a double spend and other possible attack varieties. For the blockchain to be really useful, it has to guarantee a certain level of security while still being decentralized.</p>
<h3 id="heading-scalability">SCALABILITY</h3>
<p>This is the ability of the chain to handle an increase in the number of participants on the network and also an increase in the number of activities (mostly transactions) at any time. As the use case of the technology increases, adoption and user activities on the network increase and in a correctly working environment, performance and efficiency should likewise increase. That's what being scalable means.</p>
<h2 id="heading-where-the-problem-comes-knocking">WHERE THE PROBLEM COMES KNOCKING</h2>
<p>Now you'll probably ask, why can't the all-powerful and supreme blockchain technology have all three of that? Glad you asked;</p>
<p>Decentralization is the backbone of blockchain technology, it gives everyone a hand in the decision-making process. Although giving every and anyone the power to make decisions, also comes with its downsides.</p>
<p>No one on the network can be trusted. Securing a decentralized system comes with its own set of complexities. One of these is making sure every participant on the network gets updated in near real-time with actions by other participants on the network to enable them to take part in the validation process. The problem is, the more participants come on the network, the more transactions are made, and the heavier the load on the network becomes to process, validate and propagate transactions across the network quickly enough.</p>
<p>If the technology cannot keep up with traditional centralized systems or at certain points beat the system, the possibility of adoption looks bleak. But alas! Different solutions attempting to handle the problems have and are been developed.</p>
<h2 id="heading-solutions-to-the-trilemma-problem">Solutions to the Trilemma problem</h2>
<p>Different blockchain implementations have different teams of developers behind them. Everyone doesn't think in the same direction, which is a good thing in this case, as the problem creative and diverse approach.</p>
<p>In solving the trilemma problem, a lot of Innovative ideas and solutions have come around, we'll touch on different approaches to a solution briefly.</p>
<p>Currently, most of the solutions available fall under two major categories;</p>
<ul>
<li><p>LAYER-1 (L1) solutions</p>
</li>
<li><p>LAYER-2 (L2) solutions</p>
</li>
</ul>
<h3 id="heading-layer-1-solutions">LAYER-1 solutions</h3>
<p>These solutions are implemented directly on the main blockchain's protocols. By 'main' blockchain, I mean the base/primary blockchain network. Examples of these chains include but are not limited to Bitcoin, Ethereum, Litecoin, Solana, Cardano, and Elrond. Some of the solutions applied in this layer include:</p>
<p>[-] <strong>Improving the Consensus Protocol</strong> The use of the proof-of-work consensus model is not favored, due to its computational difficulty. The more participants join the network, the more complex the operations required to run the network become. This increases the barrier of entry to becoming a miner or taking part in the network, killing decentralization. Hence blockchains tend to either transition to Proof-of-Stake or other consensus mechanisms, to reduce their computational complexities and lower the barriers of entry and promote decentralization.</p>
<p>[-] <strong>Sharding</strong> In the blockchain context, it means breaking large transaction data into smaller datasets called "shards". In doing this, the network doesn't make each participant hold all the data from the genesis block on the network, instead, it is split up and shared across specifically designed Nodes. This allows a different section of the network handle different transactions and data at different periods. When sharding is implemented, a system is built to monitor and keep all the shards across the nodes in sync with each other. In the case of Ethereum, the system that does that is the Beacon Chain.</p>
<h3 id="heading-layer-2-solutions">LAYER-2 solutions</h3>
<p>A blockchain "layer 2" solution refers to a technology built on top of an existing blockchain network that aims to improve scalability and speed without compromising the security provided by the underlying blockchain.</p>
<p>For example, a layer 1 blockchain is Bitcoin, which has a relatively slow transaction processing time and high fees. A layer 2 solution like the Lightning Network is then built on top of the Bitcoin blockchain to allow for faster and cheaper transactions without compromising the security of the underlying blockchain.</p>
<p>Another example is Ethereum's layer 2 scaling solution, which is used to offload some of the computational and storage load from the base layer of the Ethereum blockchain, by moving some of the workloads to a separate layer.</p>
<p>Examples of layer-1 solutions are detailed below.</p>
<p>[-] <strong>Sidechains</strong> sidechains are blockchains that are attached to the main chain. This makes it possible to move digital assets, such as coins or tokens, back and forth between the two chains. They are used to handle large numbers of transactions. Most sidechains use an independent consensus mechanism unlike that of the main chain to optimize for speed and scalability. They allow for more flexibility and scalability, as well as the ability to test new features without disrupting the main blockchain network.</p>
<p>[-] <strong>Rollups</strong> Rollups allow networks on Ethereum’s blockchain to “roll up” multiple transactions off-chain(that are validated) and then submit the rolled-up data to the main chain. Rollups reduce the data and computational power needed for multiple transactions on the main chain by merging multiple transactions that are not on the main chain into one and then posting it on the main chain. It also reduces traffic and enhances speed.</p>
<p>[-] <strong>Polkadot: Relay and Parachain</strong> Polkadot came up with a new idea and approach to the trilemma in the blockchain space. Instead of being a single blockchain solution, it embodies the implementation of an l1 and l2 solution as its default features. There is the relay chain, which is the backbone of the network and offers high scalability, then there are multiple parachains, which are themselves also independent blockchains but connect and communicate with the relay chain. Multiple smaller blockchains(parachains) operate independently in their decision-making process and can scale easily, but they all converge at the feet of the relay chain for security and top-level validation.</p>
<p>This idea of relay and para chains comes off as an exciting way to handle the trilemma. It also does feel like something from a movie. If you've watched Avatar(James Cameron), the Tree of Souls, where all things come to unite, even though they can be independent, that's the vibe being given off here.</p>
<p>Yeah, it's been a very lengthy article on the trilemma, I hope it was worthwhile and you found it useful.</p>
]]></content:encoded></item><item><title><![CDATA[What is Blockchain Technolgy]]></title><description><![CDATA[Let's start here;

Bitcoin is not the BLOCKCHAIN

Bitcoin's pseudonymous creator(s) 'Satoshi Nakamoto' brought to life the idea of a decentralized currency, built on blockchain technology. The currency system also uses other important technologies li...]]></description><link>https://blog.ebode.dev/what-is-blockchain-technolgy</link><guid isPermaLink="true">https://blog.ebode.dev/what-is-blockchain-technolgy</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Bitcoin]]></category><category><![CDATA[Ethereum]]></category><category><![CDATA[Web3]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 13 Mar 2022 18:05:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1674484284325/1e0c4a8f-8076-4d20-bf70-f763c3aa684c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's start here;</p>
<blockquote>
<p>Bitcoin is not the BLOCKCHAIN</p>
</blockquote>
<p>Bitcoin's pseudonymous creator(s) <strong>'Satoshi Nakamoto'</strong> brought to life the idea of a decentralized currency, built on blockchain technology. The currency system also uses other important technologies like Networking(peer-to-peer), Cryptography(Hashing and Digital signing), Agreement Logic(Consensus) and other systems to achieve its desired functionality. Therefore, I think it is safe to say, <em>'the Bitcoin system works on top of blockchain technology'</em>.</p>
<h2 id="heading-what-is-blockchain-technology">What is Blockchain Technology</h2>
<p>Technically, Wikipedia says:</p>
<ul>
<li>A blockchain is a growing list of records, called blocks, that are linked together using cryptography. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data (generally represented as a Merkle tree).</li>
</ul>
<p>So what does all this mean? The word blockchain is made up of two parts, <strong>block</strong> and <strong>chain</strong>. The block in 'blockchain', describes a store with the ability to hold data(any type of data). In the case of Bitcoin, this block holds mostly transaction data, while on Ethereum(a higher-order blockchain system), the blocks hold both transactional data and also executable programs(a smart contract).</p>
<p>The chain defines how blocks are securely connected over a network, to ensure everyone on the network has access to the blocks and the data contained in them.</p>
<p>There are other components to a blockchain ;</p>
<p><strong>Miner</strong> &gt;&gt; Depending on the consensus mechanism adopted, a miner can either operate on:</p>
<ul>
<li><p><strong>Proof of Work</strong>; where every miner competes to find the next block by attempting to solve a complex mathematical problem with their computer/machine. Whichever miner finds a block first, writes a portion of transactions in the transaction pool into the block they found. Once the block is filled, it is verified across the network by other miners and the winning miner is either rewarded or punished.</p>
</li>
<li><p><strong>Proof of Stake;</strong> Here, the miners(more technically 'Validators') do not compete. They submit an agreed amount of money(a stake) in that cryptocurrency. The validators are then randomly selected in a supposed fair manner. The money submitted is used as a method of punishment, by either destroying half or a good amount to deter a chosen validator from acting irrationally and against the rules of the system, when filling transactions into the block</p>
</li>
</ul>
<p>There are other consensus mechanisms;</p>
<ol>
<li><p>Delegated proof of stake</p>
</li>
<li><p>Proof of space-time</p>
</li>
<li><p>Proof of Elapsed time</p>
</li>
<li><p>Proof of Capacity</p>
</li>
</ol>
<p><strong>Nodes</strong> &gt;&gt; They are computers on the blockchain network that solely store every transaction and data(metadata) for each block. They listen to miners to get block updates and also serve as storage for miners and non-miners to retrieve information about a block or a transaction. Back to the definition Wikipedia gave, there are certain words mentioned that we should go over;</p>
<p><strong>Cryptographic Hash</strong> &gt;&gt; We wouldn't delve too much into computer science here, so this might be a little oversimplified. A cryptographic hash function is a term used to define a mathematical method that takes in any size of data and returns a fixed length of very very random and unique data as its output. A little or any change to the input changes the resulting output. One other thing to take note of is that the input(whatever you put in) must always give out the same output every time.</p>
<p>Below is an example of a sha256 hash function to explain better.</p>
<pre><code class="lang-bash">sha256(<span class="hljs-string">'adunni'</span>);
&gt;&gt; 99DCA03A59525C5AEED4C3C018B37D1B596F697F9EE474EEA1A0666543B9E648
</code></pre>
<p>The result of using 'adunni' as the input to a sha256 function, is a random 256bits (64chacracters) output. This shows the randomness of a hashing function.</p>
<p>Bitcoin uses this same hashing function primarily but does the data hashing twice(double sha256).</p>
<pre><code class="lang-bash">sha256(<span class="hljs-string">'Adunni'</span>);
&gt;&gt; C55C0C7C6BC033081D0DE5352742081680DBCE87F22881F1B6353EA8BAE0C954
</code></pre>
<p>Earlier I mentioned how a little change to a hashing function's input changes the output. In this case, I capitalized the first letter of the previous input( 'a' became 'A') and the content above shows how the resulting output changed. This shows the level of randomness and unpredictability of a hash function.</p>
<p>Another important feature of a hash function is that it is a one-way function. This means that it should be practically impossible to get back the input from the output, if I give you the hash <strong>C555...C954</strong> from above, you shouldn't be able to easily find out 'Adunni' was the input.</p>
<p><strong>Hashing and Blockchain</strong></p>
<p>The blockchain uses hashing as one of its core features to reduce the size of data moving across the network, create and manage keys, and handle digital signatures.</p>
<p>For block hashing, each block and its metadata is hashed and a fixed length output is gotten. The output of the hash becomes the pointer to the block, previously mined block can point to that reference and any block mined later ahead of it can also point back to the reference hash. If for any reason a bad actor tries to change something inside a block in the past, the resulting hash would be different and the system's protocol and other miners on the network would automatically spot and flag the bad actor.</p>
<p><strong>Timestamp &gt;&gt;</strong> The blockchain's timestamp is data that is stored in the block metadata field, to determine when the block was mined or created and it is verified by the system. It functions to provide a type of security, as timestamps are monitored to determine and adjust block mining difficulty, which is based on the total mining power available on the network.</p>
<p><strong>Transaction Data &gt;&gt;</strong> This is the main content of each block. The data stored in blocks refers to users' actions across the blockchain network. On the Bitcoin network, it is the transfer of X amount of coins from one user to another, on Ethereum, it is the transfer of Ether from a wallet address to another, it's also the execution of a program(smart contract) on Ethereum's network. on Storj and Filecoin networks, it is the storage and transfer of data across the network. What is regarded as an action on a blockchain-powered network is defined by the system.</p>
<p>Earlier on, we mentioned the 'Merkle tree'. A Merkle tree in the blockchain context is the hash of all the transactions in a block in order from the bottom to the top, the topmost hash is called the 'root hash'. This is useful to quickly and simply validate transactions in a block using its hash and the root hash. For blockchain efficiency, the Merkle root hash of all transactions in a block, instead of the hash, is what is carried in the header of the block ahead.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1647193153058/pID0zkg1T.png" alt="Hash_Tree.svg.png" /></p>
<h2 id="heading-types-of-blockchain-networks">Types of Blockchain networks</h2>
<p><strong>Private Blockchain Network:</strong> These networks implement the basic underlying blockchain technology components we mentioned earlier and more, but in this case, the network is not publicly accessible.</p>
<p><strong>Public Blockchain Network:</strong> Bitcoin and other Cryptocurrencies operate on this type of network, making use of distributed ledger technology. Here, the network is available to everyone and anyone and a lot of standards are built to ensure the safe and orderly entry of data into the ledgers. Consensus Algorithms such as Proof of Work, Proof of stake, Delegated Proof of stake etcetera are implemented to fairly select the next miner or validator.</p>
<p><strong>Permissioned Blockchain Network</strong> In a permissioned blockchain, majorly used on private networks, participants on the network are assigned different roles by a governing entity. Each member can only perform activities permitted by the roles they are assigned.</p>
<p><strong>Consortium Blockchains</strong> This type of blockchain has both public and private components to them, but the major difference is that it is set up, organized and maintained by multiple organizations or collaborating companies, which allows them to share data and make transactions amongst themselves.</p>
<p><strong>SideChains</strong> A side chain is another type of blockchain. It is a chain that doesn't run independently, instead, it runs dependent on another chain(a Main Chain). The side and main chain are connected via a bridge that goes both ways. It allows for the exchange of data between both chains. Side chains mostly exist to take some load off the main chain, but rely on the main chain for security.</p>
<h2 id="heading-blockchain-features">Blockchain Features</h2>
<p>Most Blockchain but not all, have certain core characteristics to make them accessible and open to the public, and at the same time, keep transactions and activities happening on the chain within the bounds of sanity.</p>
<p><strong>Consensus</strong> : Before data is written into a block and linked to the blockchain, the majority of the participant on the network have to agree.</p>
<p><strong>Finality</strong> : A real-life scenario of finality would be that after paying for a frozen chicken at a store and it is cut, sealed and handed over to you, the purchase is final, and the chicken can't be returned. Except that this is Nigeria!! anything can happen, till that chicken is eaten.</p>
<p>That same idea is carried over to how blockchains operate, most transactions don't instantly attain finality, and this is dependent on the underlying network's design. In most cases, finality happens over time, 'probabilistic finality'. In this situation, the more blocks are mined atop the block in which a certain transaction is written, the more it becomes impossible to revert.</p>
<ul>
<li><p>Bitcoin is regarded as finalized after 6 blocks in depth(a block is mined every ~10mins, that's around 60mins for finality).</p>
</li>
<li><p>BNB - 1 second (1 second per block, needs 1 commitment).</p>
</li>
</ul>
<p>Some other blockchain network transactions attain instant or near instant finality(Absolute finality) ex:: Tendermint blockchain. There is also Economic Finality, this type of finality is dependent on value(money). Here, it is expensive/costly to revert a transaction. These are used in Proof Of Stake(POS) environments.</p>
<p>Reverting a transaction is considered malicious, so if a validator tries to do so and the system picks up the actor, their stake is slashed. This makes it gives finality an economic value. Examples of blockchains using Proof of Stake include Polkadot, Cardano and now Ethereum.</p>
<p><strong>Immutability :</strong> This means, once data has successfully been recorded in a block and enough blocks have been mined ahead of that block to reach finality, that data can no longer be changed.</p>
<p><strong>Provenance</strong> : A user can prove beyond reasonable doubt that something happened on the chain. This happens due to two main reasons, one is that blockchain data and transactions are public, and the other is that transactions require practically unforgeable signatures to be valid, so any finalized transaction, can be proven to have been intentionally carried out.</p>
<h2 id="heading-blockchain-use-cases">Blockchain Use Cases</h2>
<p>It's gotten long enough, so we'd gloss over it here, there are a lot of possible use cases for blockchain technology, those we can already see happening now and those we have no idea are coming.</p>
<ul>
<li><p>Cryptocurrency and digital payments: Blockchain technology is the backbone of many cryptocurrencies such as Bitcoin and Ethereum.</p>
</li>
<li><p>A global and decentralized computing Infrastructure: Blockchain technology can be used to create self-executing contracts.</p>
</li>
<li><p>Digital Identity Management: Blockchain technology can be used to create secure and decentralized digital identities</p>
</li>
<li><p>IoT: Blockchain technology is used to secure and manage data from Internet of Things (IoT) devices.</p>
</li>
<li><p>Gaming and digital collectibles: Blockchain technology is used to create unique, digital assets that can be bought, sold and traded.</p>
</li>
<li><p>Healthcare: Blockchain technology can be used to securely store and share patient health information and medical records.</p>
</li>
<li><p>Government: Blockchain technology can be used to create secure and transparent government services, such as voting systems and public record management.</p>
</li>
<li><p>Banking and finance: Blockchain technology is increasingly being used in the banking and finance sector to streamline processes, reduce costs and enhance security.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[How Is Web 3.0 Any Different?]]></title><description><![CDATA['Web 3.0 is here' everyone says, but how did we get here?

Before getting started on web3, the web itself has an interesting backstory.
THE WEB
Almost everyone, if not everyone has at a point used a 'www' or at least tried to find something with a se...]]></description><link>https://blog.ebode.dev/how-is-web-3-any-different</link><guid isPermaLink="true">https://blog.ebode.dev/how-is-web-3-any-different</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Web3]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[web]]></category><category><![CDATA[internet]]></category><dc:creator><![CDATA[Peter Olusegun-Ebode]]></dc:creator><pubDate>Sun, 06 Mar 2022 14:15:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1646569103324/BuPrW5abK.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>'Web 3.0 is here' everyone says, but how did we get here?</p>
</blockquote>
<p>Before getting started on web3, the web itself has an interesting backstory.</p>
<h2 id="heading-the-web">THE WEB</h2>
<p>Almost everyone, if not everyone has at a point used a '<strong><em>www</em></strong>' or at least tried to find something with a search engine(Google, Bing or DuckDuckGo).</p>
<p>WWW(World-Wide-Web) generally known as the web, sits on top of the internet. It retrieves information identified by URLs(Uniform Resource Locators) or simply known as 'web addresses', an example of this is <strong>https://abc.xyz</strong> .</p>
<p>The web isn't itself the internet, a lot of people wrongly use them interchangeably, the Internet is the global network of connected computers, while the web is a collection of interconnected resources linked by URLs.</p>
<p>Tim Berners-Lee co-invented the web with Robert Cailliau in 1989. The purpose of the web at the time was to make it easy for internet users to find data and resources across the growing interconnected network of computers(the internet). This gave birth to the first generation of the web(Web 1.0).</p>
<h3 id="heading-evolution-of-web-technologies">Evolution of Web Technologies</h3>
<p>Earlier, we learned the web was built to allow users on a network share resources. As humans, the better our understanding and use of the web became, the better we needed the web to become.</p>
<p><strong>Web 1.0 (1989-2005)</strong> This was the static web, I would more like call it the largely read-only web. The majority of web users at this time only got to view and access resources on the web, while a select few put that information on the internet.</p>
<p>At this point, there were no search engines to help users find relevant pages, CSS(a language for styling webpages) and Javascript(a language providing webpages with functionality) were both non-existent. The web mostly functioned as a place for universities and large companies to share information.</p>
<p><strong>Web 2.0 (2005 - now)</strong> This brought about the birth of social media, it allowed users to create media content for the internet, smartphones and personal computers got more powerful, hence we could now properly interact with the web. CSS and Javascript became a thing and brought web pages to life.</p>
<p>The internet's infrastructure and user devices had become better. This enabled startups to take advantage of this new power and push the limits of the web. Youtube, Twitter, Facebook, Amazon, Wikipedia and the likes began to spring up.</p>
<p><strong>Web 3.0 (slowly rolling in)</strong> This represents the next stage of web evolution. The features promised include decentralization, collection and use of big data, artificial intelligence, a higher level of personalized experiences on the web, machine-to-machine communications and other features. Web3 is still in its development phase.</p>
<p>Tim Berners-Lee called web 3.0 the 'semantic web' and hopes it is the web generation that gets smart enough to require little to no human intervention to perform certain complex events/tasks in the future.</p>
<h2 id="heading-defining-web-30">Defining Web 3.0</h2>
<p>Web 3.0 is still developing and not fully here yet. There is also no agreed-upon definition as it is still in its iterative stage. One thing I find funny though is the number of people that are anti-web3, claiming no such thing exists, and at the same time, the sheer number of individuals that would give their life to defend the presence/arrival of web3, pointing out cases like cryptocurrencies, IPFS, DAOs and the likes.</p>
<p>My take on this would be, web3 is not really about what we can see and do right now, there is still so much yet to come. I also don't think the debate is necessary yet and also I don't think web3 is a stand-alone evolvement, it is still fully adherent to the general Internet protocols and uses a lot of pre-existing web2 technologies and infrastructures, like we said earlier, this is just another stage of development.</p>
<p>Web 3.0 is a merger of different technologies like Machine learning, Data Analysis, Decentralized Ledger Technology, etcetera, in the hope that the web as a whole gets smarter, faster, better and with improved security and better data control for users.</p>
<h3 id="heading-features-of-web-30">Features of Web 3.0</h3>
<p>Web 3.0 aims to improve the internet, how we use it and what we build on it. These are some of its promising core features;</p>
<ul>
<li><p>Decentralization</p>
</li>
<li><p>Artificial Intelligence</p>
</li>
<li><p>Virtual and Augmented reality</p>
</li>
<li><p>Connectivity (Internet of things)</p>
</li>
<li><p>Machine-to-Machine Communication</p>
</li>
</ul>
<h3 id="heading-getting-involved-with-web-30">Getting Involved with web 3.0</h3>
<p>Web3 isn't just about cryptocurrencies or the crypto ecosystem, though the area has a lot of active interest, active builders and active participants. It is just one of the features web 3.0 promises. I think cryptocurrencies and NFTs have gotten public attention due to the 'extreme' financial incentive it has brought in for early adopters and has also provided a taste of what decentralization feels and tastes like.</p>
<p>In other areas, technologies are improving the standard and ease of living. Artificial intelligence for example has gotten a lot of adoption and has slowly gotten integrated into our everyday life experiences.</p>
<p>Google uses AI to improve page ranking and indexing, which in turn improves search results for users. Spotify, Netflix, and Youtube all use AI to understand our preferences and try to make suggestions based on that.</p>
<p>Voice assistants like Google Assistant, Bixby, Siri, and Alexa, all improve our lives by being there to assist with certain tasks throughout the day.</p>
<p>Artificial Intelligence also runs in semi-driverless cars like Tesla, Waymo, Lucid, etcetera. They help companies identify and sort things on a very large scale. There are lots of possible applications in the space.</p>
<p>Then there are virtual and augmented reality used in applications like Snapchat, Meta's Oculus, HTC's Vive and Valve's Index devices and the like.</p>
<p>The web is improving and becoming smarter every day, with new technologies and even newer ways to use old technology, it would only get better.</p>
<p><strong>It's a great time to be alive.</strong></p>
]]></content:encoded></item></channel></rss>