<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://en.zaoniao.it/index.php?action=history&amp;feed=atom&amp;title=Bitcoin_Binary_Data_Protocol</id>
	<title>Bitcoin Binary Data Protocol - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://en.zaoniao.it/index.php?action=history&amp;feed=atom&amp;title=Bitcoin_Binary_Data_Protocol"/>
	<link rel="alternate" type="text/html" href="http://en.zaoniao.it/index.php?title=Bitcoin_Binary_Data_Protocol&amp;action=history"/>
	<updated>2026-05-15T13:20:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>http://en.zaoniao.it/index.php?title=Bitcoin_Binary_Data_Protocol&amp;diff=3400&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;====0. The URLs==== URL: http://yyz.us/bitcoin/pushpool-0.4.tar.gz Repo: https://github.com/jgarzik/pushpool  ====1. The Problem==== With the recent slashdotting and resultant...&quot;</title>
		<link rel="alternate" type="text/html" href="http://en.zaoniao.it/index.php?title=Bitcoin_Binary_Data_Protocol&amp;diff=3400&amp;oldid=prev"/>
		<updated>2019-04-18T04:51:52Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;====0. The URLs==== URL: http://yyz.us/bitcoin/pushpool-0.4.tar.gz Repo: https://github.com/jgarzik/pushpool  ====1. The Problem==== With the recent slashdotting and resultant...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;====0. The URLs====&lt;br /&gt;
URL: http://yyz.us/bitcoin/pushpool-0.4.tar.gz&lt;br /&gt;
Repo: https://github.com/jgarzik/pushpool&lt;br /&gt;
&lt;br /&gt;
====1. The Problem====&lt;br /&gt;
With the recent slashdotting and resultant influx in new users, the 'getwork' network protocol used in mining is showing some strain, particularly on the pools.  Miners request work once every 5-10 seconds using HTTP JSON-RPC, which has several glaring inefficiencies that lead to unnecessary server load:&lt;br /&gt;
HTTP/1.1 persistent connections are uncommon, possibly because bitcoind does not support them.  This results in a new TCP connection from every miner, every 5-10 seconds, to the same network host.&lt;br /&gt;
'getwork' data is a mere 256 bytes, but HTTP headers and binary-to-hexidecimal encoding for JSON increase the payload to more than double that&lt;br /&gt;
official bitcoin client's RPC server implementation is essentially a single-threaded loop, where requests from clients B, C, and D will be stalled and ignored until client A's request is finished -- or a 30 second timeout (see -rpctimeout).  This algorithm does not tolerate a high TCP request rate from multiple threads / computers.&lt;br /&gt;
&lt;br /&gt;
Several people, pool operators in particular, have a keen interest in solving these problems.  In addition, push mining (see below) has been discussed as a future alternative to the 'getwork' polling method currently employed.&lt;br /&gt;
&lt;br /&gt;
====2. Design goals for a solution====&lt;br /&gt;
I have written a demonstration pool server (aka a 'getwork' proxy server) that functions in a similar fashion to the recently-discussed poold.py:  large numbers of miners connect to the pool server, which proxies 'getwork' JSON-RPC requests to the official bitcoin client.  This demonstration server implements a new binary protocol that was designed to meet the following goals:&lt;br /&gt;
&lt;br /&gt;
Persistent TCP connections, to eliminate TCP disconnect+reconnect behavior by miners&lt;br /&gt;
Network-efficient for the common use case:  one network packet for 'getwork', one network packet for the returned data.&lt;br /&gt;
Network-efficient for similar use cases (monitorblocks, monitortx) where clients connect, and then passively wait for real-time events to be delivered&lt;br /&gt;
Existing miner client workflows supported, to minimize network protocol change impact on miners&lt;br /&gt;
Support &amp;quot;push mining,&amp;quot; where server delivers new work to miners unsolicited (ie. without the miner first sending a 'getwork' message)&lt;br /&gt;
&lt;br /&gt;
This is not intended to replace JSON-RPC API, but to supplement it for specific use cases.  Yes, that means bitcoind will listen to three network ports: P2P network, JSON-RPC, and binary RPC (though as now, only P2P is required for operation; the servers are always optional).&lt;br /&gt;
&lt;br /&gt;
====3. Let's start with a protocol example: today's getwork mining====&lt;br /&gt;
The specific details of the protocol itself are in ubbp.h and protocol.h of the above URL (pushpool-0.1.1.tar.gz).  Here is an example, to provide a suitable introduction:&lt;br /&gt;
&lt;br /&gt;
* TCP connection is broken up into messages.  Each message has a 64-bit header, with 8-bit opcode and 24-bit length fields.&lt;br /&gt;
* Miner client connects to TCP server, and issues a LOGIN message, which is compressed JSON login data + sha256 hash of (data + shared secret).&lt;br /&gt;
* Server responds with an OP_LOGIN_RESP msg, compressed JSON, indicating options and capabilities&lt;br /&gt;
* Client issues an OP_GETWORK msg (8 bytes)&lt;br /&gt;
* Server responds with an OP_WORK msg (264 bytes)&lt;br /&gt;
* Client uses its CPU/GPU to work on proof-of-work solution...&lt;br /&gt;
* Client issues an OP_GETWORK msg (8 bytes)&lt;br /&gt;
* Server responds with an OP_WORK msg (264 bytes)&lt;br /&gt;
&lt;br /&gt;
The above example intentionally matches existing 'getwork' JSON-RPC miner client workflow today.  Miner clients may even support stateless operation by pipelining the OP_LOGIN and OP_GETWORK requests together, and closing the TCP connection.  Stateless operation is not recommended, but it is supported, in order to support the widest range of existing mining clients.&lt;br /&gt;
&lt;br /&gt;
====4.  Tomorrow's mining:  push mining====&lt;br /&gt;
&lt;br /&gt;
When a block or tx arrives, it is preferable to begin working immediately on the new work.  From the server's perspective, this is a classic data-broadcast problem, where the server wants to broadcast N different pieces of work to N miners.  Hence, &amp;quot;push mining&amp;quot; where the server pushes new work pro-actively to the miner clients.&lt;br /&gt;
&lt;br /&gt;
This new network protocol supports pushing mining, as demonstrated in this example:&lt;br /&gt;
&lt;br /&gt;
* Client connects to server, issues a LOGIN message with the &amp;quot;send_me_work&amp;quot; flag set&lt;br /&gt;
* Server responds with OP_LOGIN_RESP msg&lt;br /&gt;
* Server sends a OP_WORK msg&lt;br /&gt;
* Server sends a OP_WORK msg&lt;br /&gt;
* Server sends a OP_WORK msg&lt;br /&gt;
&lt;br /&gt;
====5.  A similar use case:  monitorblocks====&lt;br /&gt;
Gavin Andresen has a patch in his github which provides a very useful feature:  when a new block is received (monitorblocks) or new wallet transaction (monitortx), bitcoind sends an HTTP POST to the specified URL.  Thus, monitorblocks provides real-time monitoring of the bitcoin network, and monitortx provides real-time monitoring of the local wallet.  This sort of featureset pushes data as events occur, rather than forcing a website operator to poll JSON-RPC for certain operations to complete.&lt;br /&gt;
&lt;br /&gt;
Monitoring new blocks on the bitcoin network is a very easy data broadcasting problem that this binary network protocol may easily support:&lt;br /&gt;
&lt;br /&gt;
* Client connects to server, issues a LOGIN message with the &amp;quot;send_me_blocks&amp;quot; flag set&lt;br /&gt;
* Server responds with OP_LOGIN_RESP msg&lt;br /&gt;
* Server sends a OP_BLOCK msg&lt;br /&gt;
* Server sends a OP_BLOCK msg&lt;br /&gt;
* Server sends a OP_BLOCK msg&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
monitortx is more complicated, because one may specify transaction-matching criteria.  But with this new protocol's support of JSON, flexibility is not a problem.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
* [https://bitcointalk.org/index.php?topic=3493.0 BitcoinTalk forum thread]&lt;br /&gt;
* [https://github.com/jgarzik/pushpool/blob/master/protocol.h Reference implementation header]&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
&lt;br /&gt;
[http://bitcoin.it/ http://bitcoin.it/]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technology]]&lt;br /&gt;
[[Category:Protocol]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
</feed>