Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192]
	helo=mx.sourceforge.net)
	by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76)
	(envelope-from <mh.in.england@gmail.com>) id 1Uz2zE-0001dQ-09
	for bitcoin-development@lists.sourceforge.net;
	Tue, 16 Jul 2013 11:00:04 +0000
Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com
	designates 209.85.219.47 as permitted sender)
	client-ip=209.85.219.47; envelope-from=mh.in.england@gmail.com;
	helo=mail-oa0-f47.google.com; 
Received: from mail-oa0-f47.google.com ([209.85.219.47])
	by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128)
	(Exim 4.76) id 1Uz2zC-0001tI-16
	for bitcoin-development@lists.sourceforge.net;
	Tue, 16 Jul 2013 11:00:03 +0000
Received: by mail-oa0-f47.google.com with SMTP id m1so612496oag.6
	for <bitcoin-development@lists.sourceforge.net>;
	Tue, 16 Jul 2013 03:59:56 -0700 (PDT)
MIME-Version: 1.0
X-Received: by 10.60.79.131 with SMTP id j3mr1143328oex.96.1373972396558; Tue,
	16 Jul 2013 03:59:56 -0700 (PDT)
Sender: mh.in.england@gmail.com
Received: by 10.76.23.36 with HTTP; Tue, 16 Jul 2013 03:59:56 -0700 (PDT)
In-Reply-To: <2A1C412D-414E-4C41-8E20-F0D21F801328@grabhive.com>
References: <B87F1213-5BD8-43F5-9744-F69947561ED5@grabhive.com>
	<CANEZrP2xh=m8yWLt-o2UrrUVfU+cUYBuMVxkVFF5mVMtWdRwOQ@mail.gmail.com>
	<C1727B41-AF61-44FA-BE17-5FE4425FDEA8@grabhive.com>
	<CANEZrP0_H9+prDSF92q8a4QzP=fzDM6cTDv0+KcfV9NF9thkmw@mail.gmail.com>
	<3E7894A0-06F3-453D-87F8-975A244EBACF@include7.ch>
	<CANEZrP2jmWkDbpJEm0vd2CKF-prFNbz_ZeNJfDWtSCKb8k5ZXA@mail.gmail.com>
	<2BDA0943-22BB-4405-9AF0-86FB41FD04A6@include7.ch>
	<CANEZrP0McSrVzwv=-qimPyX41EEDmyQdYW5QjPr_i+KWyJZSZw@mail.gmail.com>
	<2F20A509-13A9-4C84-86D7-A15C21BACD53@include7.ch>
	<CANEZrP2yQvmvwP_ZULdS2i+X6L9MeZ+DfidiuZPD2EHwLsN2MA@mail.gmail.com>
	<2A1C412D-414E-4C41-8E20-F0D21F801328@grabhive.com>
Date: Tue, 16 Jul 2013 12:59:56 +0200
X-Google-Sender-Auth: w8eYBxUe30J6cvkwfiTaxKJYJak
Message-ID: <CANEZrP12V_5Ak0f91RsMziuqXysde102rGeSko=qPBjefy3AeA@mail.gmail.com>
From: Mike Hearn <mike@plan99.net>
To: Wendell <w@grabhive.com>
Content-Type: multipart/alternative; boundary=047d7b678126a0d23304e19ee022
X-Spam-Score: -0.5 (/)
X-Spam-Report: Spam Filtering performed by mx.sourceforge.net.
	See http://spamassassin.org/tag/ for more details.
	-1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for
	sender-domain
	0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
	(mh.in.england[at]gmail.com)
	-0.0 SPF_PASS               SPF: sender matches SPF record
	1.0 HTML_MESSAGE           BODY: HTML included in message
	0.1 DKIM_SIGNED            Message has a DKIM or DK signature,
	not necessarily valid
	-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
X-Headers-End: 1Uz2zC-0001tI-16
X-Mailman-Approved-At: Sun, 21 Jul 2013 14:12:24 +0000
Cc: Bitcoin Dev <bitcoin-development@lists.sourceforge.net>,
	Jonas Schnelli <jonas.schnelli@include7.ch>
Subject: Re: [Bitcoin-development] Introducing BitcoinKit.framework
X-BeenThere: bitcoin-development@lists.sourceforge.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: <bitcoin-development.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development>
List-Post: <mailto:bitcoin-development@lists.sourceforge.net>
List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>,
	<mailto:bitcoin-development-request@lists.sourceforge.net?subject=subscribe>
X-List-Received-Date: Tue, 16 Jul 2013 11:00:04 -0000

--047d7b678126a0d23304e19ee022
Content-Type: text/plain; charset=UTF-8

I think that's a great approach. Here is the patch Satoshi sent me back in
2010. All the code has changed since but it can be a source of inspiration.

From Satoshi:

*The simplified payment verification in the paper imagined you would
receive transactions directly, as with sending to IP address which nobody
uses, or a node would index all transactions by public key and you could
download them like downloading mail from a mail server.

Instead, I think client-only nodes should receive full blocks so they can
scan them for their own transactions.  They don't need to store them or
index them.  For the initial download, they only need to download headers,
since there couldn't be any payments before the first time the program was
run (a header download command was added in 0.3.18).  From then on, they
download full blocks (but only store the headers).

Code for client-only mode is mostly implemented.  There's a feature branch
on github with it, also I'm attaching the patch to this message.

Here's some more about it:

"Here's my client-mode implementation so far.  Client-only mode only
records block headers and doesn't use the tx index.  It can't generate, but
it can still send and receive transactions.  It's not fully finished for
use by end-users, but it doesn't matter because it's a complete no-op if
fClient is not enabled.  At this point it's mainly documentation showing
the cut-lines for client-only re-implementers.

With fClient=true, I've only tested the header-only initial download.

A little background.  CBlockIndex contains all the information of the block
header, so to operate with headers only, I just maintain the CBlockIndex
structure as usual.  The nFile/nBlockPos are null, since the full block is
not recorded on disk.

The code to gracefully switch between client-mode on/off without deleting
blk*.dat in between is not implemented yet.  It would mostly be a matter of
having non-client LoadBlockIndex ignore block index entries with null block
pos.  That would make it re-download those as full blocks.  Switching back
to client-mode is no problem, it doesn't mind if the full blocks are there.

If the initial block download becomes too long, we'll want client mode as
an option so new users can get running quickly.  With graceful switch-off
of client mode, they can later turn off client mode and have it download
the full blocks if they want to start generating.  They should rather just
use a getwork miner to join a pool instead.

Client-only re-implementations would not need to implement EvalScript at
all, or at most just implement the five ops used by the standard
transaction templates."
*




diff -u old\db.cpp new\db.cpp
--- old\db.cpp  Sat Dec 18 18:35:59 2010
+++ new\db.cpp  Sun Dec 19 20:53:59 2010
@@ -464,29 +464,32 @@
     ReadBestInvalidWork(bnBestInvalidWork);

     // Verify blocks in the best chain
-    CBlockIndex* pindexFork = NULL;
-    for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex
= pindex->pprev)
+    if (!fClient)
     {
-        if (pindex->nHeight < nBestHeight-2500 &&
!mapArgs.count("-checkblocks"))
-            break;
-        CBlock block;
-        if (!block.ReadFromDisk(pindex))
-            return error("LoadBlockIndex() : block.ReadFromDisk failed");
-        if (!block.CheckBlock())
+        CBlockIndex* pindexFork = NULL;
+        for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev;
pindex = pindex->pprev)
         {
-            printf("LoadBlockIndex() : *** found bad block at %d,
hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
-            pindexFork = pindex->pprev;
+            if (pindex->nHeight < nBestHeight-2500 &&
!mapArgs.count("-checkblocks"))
+                break;
+            CBlock block;
+            if (!block.ReadFromDisk(pindex))
+                return error("LoadBlockIndex() : block.ReadFromDisk
failed");
+            if (!block.CheckBlock())
+            {
+                printf("LoadBlockIndex() : *** found bad block at %d,
hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
+                pindexFork = pindex->pprev;
+            }
+        }
+        if (pindexFork)
+        {
+            // Reorg back to the fork
+            printf("LoadBlockIndex() : *** moving best chain pointer back
to block %d\n", pindexFork->nHeight);
+            CBlock block;
+            if (!block.ReadFromDisk(pindexFork))
+                return error("LoadBlockIndex() : block.ReadFromDisk
failed");
+            CTxDB txdb;
+            block.SetBestChain(txdb, pindexFork);
         }
-    }
-    if (pindexFork)
-    {
-        // Reorg back to the fork
-        printf("LoadBlockIndex() : *** moving best chain pointer back to
block %d\n", pindexFork->nHeight);
-        CBlock block;
-        if (!block.ReadFromDisk(pindexFork))
-            return error("LoadBlockIndex() : block.ReadFromDisk failed");
-        CTxDB txdb;
-        block.SetBestChain(txdb, pindexFork);
     }

     return true;
diff -u old\main.cpp new\main.cpp
--- old\main.cpp        Sat Dec 18 18:35:59 2010
+++ new\main.cpp        Sun Dec 19 20:53:59 2010
@@ -637,6 +637,9 @@
     if (!IsStandard())
         return error("AcceptToMemoryPool() : nonstandard transaction
type");

+    if (fClient)
+        return true;
+
     // Do we already have it?
     uint256 hash = GetHash();
     CRITICAL_BLOCK(cs_mapTransactions)
@@ -1308,23 +1311,26 @@
     if (!CheckBlock())
         return false;

-    //// issue here: it doesn't know the version
-    unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(),
SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size());
-
-    map<uint256, CTxIndex> mapUnused;
-    int64 nFees = 0;
-    foreach(CTransaction& tx, vtx)
+    if (!fClient)
     {
-        CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
-        nTxPos += ::GetSerializeSize(tx, SER_DISK);
+        //// issue here: it doesn't know the version
+        unsigned int nTxPos = pindex->nBlockPos +
::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size(
));
+
+        map<uint256, CTxIndex> mapUnused;
+        int64 nFees = 0;
+        foreach(CTransaction& tx, vtx)
+        {
+            CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos);
+            nTxPos += ::GetSerializeSize(tx, SER_DISK);

-        if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex, nFees,
true, false))
+            if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex,
nFees, true, false))
+                return false;
+        }
+
+        if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees))
             return false;
     }

-    if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees))
-        return false;
-
     // Update block index on disk without changing it in memory.
     // The memory index structure will be changed after the db commits.
     if (pindex->pprev)
@@ -1378,7 +1384,7 @@
     foreach(CBlockIndex* pindex, vDisconnect)
     {
         CBlock block;
-        if (!block.ReadFromDisk(pindex))
+        if (!block.ReadFromDisk(pindex, !fClient))
             return error("Reorganize() : ReadFromDisk for disconnect
failed");
         if (!block.DisconnectBlock(txdb, pindex))
             return error("Reorganize() : DisconnectBlock failed");
@@ -1395,7 +1401,7 @@
     {
         CBlockIndex* pindex = vConnect[i];
         CBlock block;
-        if (!block.ReadFromDisk(pindex))
+        if (!block.ReadFromDisk(pindex, !fClient))
             return error("Reorganize() : ReadFromDisk for connect failed");
         if (!block.ConnectBlock(txdb, pindex))
         {
@@ -1526,7 +1532,7 @@

     txdb.Close();

-    if (pindexNew == pindexBest)
+    if (!fClient && pindexNew == pindexBest)
     {
         // Notify UI to display prev block's coinbase if it was ours
         static uint256 hashPrevBestCoinBase;
@@ -1547,10 +1553,6 @@
     // These are checks that are independent of context
     // that can be verified before saving an orphan block.

-    // Size limits
-    if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE ||
::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
-        return error("CheckBlock() : size limits failed");
-
     // Check proof of work matches claimed amount
     if (!CheckProofOfWork(GetHash(), nBits))
         return error("CheckBlock() : proof of work failed");
@@ -1559,6 +1561,13 @@
     if (GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60)
         return error("CheckBlock() : block timestamp too far in the
future");

+    if (fClient && vtx.empty())
+        return true;
+
+    // Size limits
+    if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE ||
::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE)
+        return error("CheckBlock() : size limits failed");
+
     // First transaction must be coinbase, the rest must not be
     if (vtx.empty() || !vtx[0].IsCoinBase())
         return error("CheckBlock() : first tx is not coinbase");
@@ -1623,13 +1632,14 @@
         return error("AcceptBlock() : out of disk space");
     unsigned int nFile = -1;
     unsigned int nBlockPos = 0;
-    if (!WriteToDisk(nFile, nBlockPos))
-        return error("AcceptBlock() : WriteToDisk failed");
+    if (!fClient)
+        if (!WriteToDisk(nFile, nBlockPos))
+            return error("AcceptBlock() : WriteToDisk failed");
     if (!AddToBlockIndex(nFile, nBlockPos))
         return error("AcceptBlock() : AddToBlockIndex failed");

     // Relay inventory, but don't relay old inventory during initial block
download
-    if (hashBestChain == hash)
+    if (!fClient && hashBestChain == hash)
         CRITICAL_BLOCK(cs_vNodes)
             foreach(CNode* pnode, vNodes)
                 if (nBestHeight > (pnode->nStartingHeight != -1 ?
pnode->nStartingHeight - 2000 : 55000))
@@ -2405,6 +2415,8 @@
         {
             if (fShutdown)
                 return true;
+            if (fClient && inv.type == MSG_TX)
+                continue;
             pfrom->AddInventoryKnown(inv);

             bool fAlreadyHave = AlreadyHave(txdb, inv);
@@ -2441,6 +2453,9 @@

             if (inv.type == MSG_BLOCK)
             {
+                if (fClient)
+                    return true;
+
                 // Send block from disk
                 map<uint256, CBlockIndex*>::iterator mi =
mapBlockIndex.find(inv.hash);
                 if (mi != mapBlockIndex.end())
@@ -2486,6 +2501,8 @@

     else if (strCommand == "getblocks")
     {
+        if (fClient)
+            return true;
         CBlockLocator locator;
         uint256 hashStop;
         vRecv >> locator >> hashStop;
@@ -2556,6 +2573,8 @@

     else if (strCommand == "tx")
     {
+        if (fClient)
+            return true;
         vector<uint256> vWorkQueue;
         CDataStream vMsg(vRecv);
         CTransaction tx;
@@ -2620,6 +2639,33 @@

         if (ProcessBlock(pfrom, &block))
             mapAlreadyAskedFor.erase(inv);
+    }
+
+
+    else if (strCommand == "headers")
+    {
+        if (!fClient)
+            return true;
+        vector<CBlock> vHeaders;
+        vRecv >> vHeaders;
+
+        uint256 hashBestBefore = hashBestChain;
+        foreach(CBlock& block, vHeaders)
+        {
+            block.vtx.clear();
+
+            printf("received header %s\n", block.GetHash().ToString().
substr(0,20).c_str());
+
+            CInv inv(MSG_BLOCK, block.GetHash());
+            pfrom->AddInventoryKnown(inv);
+
+            if (ProcessBlock(pfrom, &block))
+                mapAlreadyAskedFor.erase(inv);
+        }
+
+        // Request next batch
+        if (hashBestChain != hashBestBefore)
+            pfrom->PushGetBlocks(pindexBest, uint256(0));
     }


On Tue, Jul 16, 2013 at 12:17 PM, Wendell <w@grabhive.com> wrote:

> I for one would be interested in taking a look at that.
>
> In San Jose I was asking around about the possibility of hiring someone to
> complete such a patch. Pieter Wuille introduced me to Eric Lombrozo, who
> expressed interest, but has since gotten quite busy. So we haven't arrived
> at a detailed estimate of what it would involve.
>
> Maybe it would be better to start a completely new thread for this topic,
> but I would very much be interested in an open dissection of what adding
> SPV support to bitcoind would take. I am willing to fund or (ideally)
> co-fund this endeavor, if I can ever get my head around it. I'm super
> interested in all of these possibilities (including micro-stripped-VMs and
> transpilation), but would simply like to encourage the proliferation of
> _options_ whenever possible.
>
> -wendell
>
> grabhive.com | twitter.com/grabhive
>
> On Jul 16, 2013, at 11:51 AM, Mike Hearn wrote:
>
> > If you wanted to implement SPV mode in bitcoind, Gavin or I could send
> you Satoshi's old patch although of course it is no longer usable. It would
> indicate the basic cut lines though.
>
>

--047d7b678126a0d23304e19ee022
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think that&#39;s a great approach. Here is the patch Sat=
oshi sent me back in 2010. All the code has changed since but it can be a s=
ource of inspiration.<div><br>From Satoshi:</div><div><br></div><div><i><sp=
an style=3D"font-family:arial,sans-serif;font-size:13px">The simplified pay=
ment verification in the paper imagined you would receive transactions dire=
ctly, as with sending to IP address which nobody uses, or a node would inde=
x all transactions by public key and you could download them like downloadi=
ng mail from a mail server.</span><br style=3D"font-family:arial,sans-serif=
;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">Instead, I think client-only nod=
es should receive full blocks so they can scan them for their own transacti=
ons. =C2=A0They don&#39;t need to store them or index them. =C2=A0For the i=
nitial download, they only need to download headers, since there couldn&#39=
;t be any payments before the first time the program was run (a header down=
load command was added in 0.3.18). =C2=A0From then on, they download full b=
locks (but only store the headers).</span><br style=3D"font-family:arial,sa=
ns-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">Code for client-only mode is mos=
tly implemented. =C2=A0There&#39;s a feature branch on github with it, also=
 I&#39;m attaching the patch to this message.</span><br style=3D"font-famil=
y:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">Here&#39;s some more about it:</=
span><br style=3D"font-family:arial,sans-serif;font-size:13px"><br style=3D=
"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">&quot;Here&#39;=
s my client-mode implementation so far. =C2=A0Client-only mode only records=
 block headers and doesn&#39;t use the tx index. =C2=A0It can&#39;t generat=
e, but it can still send and receive transactions. =C2=A0It&#39;s not fully=
 finished for use by end-users, but it doesn&#39;t matter because it&#39;s =
a complete no-op if fClient is not enabled. =C2=A0At this point it&#39;s ma=
inly documentation showing the cut-lines for client-only re-implementers.</=
span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">With fClient=3Dtrue, I&#39;ve on=
ly tested the header-only initial download.</span><br style=3D"font-family:=
arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">A little background. =C2=A0CBloc=
kIndex contains all the information of the block header, so to operate with=
 headers only, I just maintain the CBlockIndex structure as usual. =C2=A0Th=
e nFile/nBlockPos are null, since the full block is not recorded on disk.</=
span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">The code to gracefully switch be=
tween client-mode on/off without deleting blk*.dat in between is not implem=
ented yet. =C2=A0It would mostly be a matter of having non-client LoadBlock=
Index ignore block index entries with null block pos. =C2=A0That would make=
 it re-download those as full blocks. =C2=A0Switching back to client-mode i=
s no problem, it doesn&#39;t mind if the full blocks are there.</span><br s=
tyle=3D"font-family:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">If the initial block download be=
comes too long, we&#39;ll want client mode as an option so new users can ge=
t running quickly. =C2=A0With graceful switch-off of client mode, they can =
later turn off client mode and have it download the full blocks if they wan=
t to start generating. =C2=A0They should rather just use a getwork miner to=
 join a pool instead.</span><br style=3D"font-family:arial,sans-serif;font-=
size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">Client-only re-implementations w=
ould not need to implement EvalScript at all, or at most just implement the=
 five ops used by the standard transaction templates.&quot;</span><br>
</i></div><div><span style=3D"font-family:arial,sans-serif;font-size:13px">=
<br></span></div><div><br></div><div><br></div><div><br></div><div><span st=
yle=3D"font-family:arial,sans-serif;font-size:13px">diff -u old\db.cpp new\=
db.cpp</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">--- old\db.cpp =
=C2=A0Sat Dec 18 18:35:59 2010</span><br style=3D"font-family:arial,sans-se=
rif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:1=
3px">+++ new\db.cpp =C2=A0Sun Dec 19 20:53:59 2010</span><br style=3D"font-=
family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -464,29 +464=
,32 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><spa=
n style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=
=A0ReadBestInvalidWork(</span><span style=3D"font-family:arial,sans-serif;f=
ont-size:13px">bnBestInvalidWork);</span><br style=3D"font-family:arial,san=
s-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0// Verify bl=
ocks in the best chain</span><br style=3D"font-family:arial,sans-serif;font=
-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">- =
=C2=A0 =C2=A0CBlockIndex* pindexFork =3D NULL;</span><br style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
for (CBlockIndex* pindex =3D pindexBest; pindex &amp;&amp; pindex-&gt;pprev=
; pindex =3D pindex-&gt;pprev)</span><br style=3D"font-family:arial,sans-se=
rif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
if (!fClient)</span><br style=3D"font-family:arial,sans-serif;font-size:13p=
x"><span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=
=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:13px"=
>
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (pindex-&gt;nHeight &lt; nBestHeight-2500 &amp;&amp; !mapA=
rgs.count(&quot;-checkblocks&quot;)</span><span style=3D"font-family:arial,=
sans-serif;font-size:13px">)</span><br style=3D"font-family:arial,sans-seri=
f;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;</span><br style=3D"font-family:arial,san=
s-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-si=
ze:13px">- =C2=A0 =C2=A0 =C2=A0 =C2=A0CBlock block;</span><br style=3D"font=
-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!block.ReadFromDisk(pindex))</span><br style=3D"font-fami=
ly:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-s=
erif;font-size:13px">- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return erro=
r(&quot;LoadBlockIndex() : block.ReadFromDisk failed&quot;);</span><br styl=
e=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!block.CheckBlock())</span><br style=3D"font-family:arial=
,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;fon=
t-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0CBlockIndex* pindexFork =3D NULL;=
</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0for (CBlockIndex* pindex =3D pindexBest; pindex &amp;&amp; pi=
ndex-&gt;pprev; pindex =3D pindex-&gt;pprev)</span><br style=3D"font-family=
:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-=
size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">- =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf(&quot;LoadBlockIndex() : **=
* found bad block at %d, hash=3D%s\n&quot;, pindex-&gt;nHeight, pindex-&gt;=
GetBlockHash().</span><span style=3D"font-family:arial,sans-serif;font-size=
:13px">ToString().c_str());</span><br style=3D"font-family:arial,sans-serif=
;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0pindexFork =3D pindex-&gt;pprev;</span><br styl=
e=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-famil=
y:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0if (pindex-&gt;nHeight &lt; nBestHeight-2500 &amp;&amp; !mapArgs.count(&=
quot;-checkblocks&quot;)</span><span style=3D"font-family:arial,sans-serif;=
font-size:13px">)</span><br style=3D"font-family:arial,sans-serif;font-size=
:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0break;</span><br style=3D"font-fa=
mily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans=
-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CBlock bl=
ock;</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.ReadFromDisk(pindex))</span><br styl=
e=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-famil=
y:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0return error(&quot;LoadBlockIndex() : block.ReadFromDisk f=
ailed&quot;);</span><br style=3D"font-family:arial,sans-serif;font-size:13p=
x">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.CheckBlock())</span><br style=3D"fon=
t-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,=
sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{</sp=
an><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf(&quot;LoadBlockIndex() : *=
** found bad block at %d, hash=3D%s\n&quot;, pindex-&gt;nHeight, pindex-&gt=
;GetBlockHash().</span><span style=3D"font-family:arial,sans-serif;font-siz=
e:13px">ToString().c_str());</span><br style=3D"font-family:arial,sans-seri=
f;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pindexFork =3D pindex-&gt;pprev;<=
/span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=
=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0}</span><br style=3D"font-family:arial,sans-serif;font-siz=
e:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0}</span><br style=3D"font-family:arial,sans-serif;font-size:1=
3px"><span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =
=C2=A0 =C2=A0 =C2=A0if (pindexFork)</span><br style=3D"font-family:arial,sa=
ns-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:1=
3px"><span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// Reorg back to the fork</span><br style=
=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf(&quot;LoadBlockIndex() : *** moving best=
 chain pointer back to block %d\n&quot;, pindexFork-&gt;nHeight);</span><br=
 style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0CBlock block;</span><br style=3D"font-family:ar=
ial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;=
font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.ReadF=
romDisk(</span><span style=3D"font-family:arial,sans-serif;font-size:13px">=
pindexFork))</span><br style=3D"font-family:arial,sans-serif;font-size:13px=
">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return error(&quot;LoadBlockIndex=
() : block.ReadFromDisk failed&quot;);</span><br style=3D"font-family:arial=
,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;fon=
t-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CTxDB txdb;</span><=
br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0block.SetBestChain(txdb, pindexFork);</span><br=
 style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-=
family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}=
</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
}</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span sty=
le=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0if (pinde=
xFork)</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
{</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span sty=
le=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0 =C2=A0 =
=C2=A0// Reorg back to the fork</span><br style=3D"font-family:arial,sans-s=
erif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0printf(&quot;LoadBlockIndex() : *** moving best chain pointer=
 back to block %d\n&quot;, pindexFork-&gt;nHeight);</span><br style=3D"font=
-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0CBlock block;</span><br style=3D"font-family:arial,sans-serif=
;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px=
">- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.ReadFromDisk(</span><span style=
=3D"font-family:arial,sans-serif;font-size:13px">pindexFork))</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0return error(&quot;LoadBlockIndex() : block.Rea=
dFromDisk failed&quot;);</span><br style=3D"font-family:arial,sans-serif;fo=
nt-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">-=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0CTxDB txdb;</span><br style=3D"font-family:aria=
l,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0block.SetBestChain(txdb, pindexFork);</span><br style=3D"font=
-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,s=
ans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0}</span><br style=3D"font-fam=
ily:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0return true;=
</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span styl=
e=3D"font-family:arial,sans-serif;font-size:13px">diff -u old\main.cpp new\=
main.cpp</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">--- old\main.cp=
p =C2=A0 =C2=A0 =C2=A0 =C2=A0Sat Dec 18 18:35:59 2010</span><br style=3D"fo=
nt-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial=
,sans-serif;font-size:13px">+++ new\main.cpp =C2=A0 =C2=A0 =C2=A0 =C2=A0Sun=
 Dec 19 20:53:59 2010</span><br style=3D"font-family:arial,sans-serif;font-=
size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -637,6 +637,=
9 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span =
style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0i=
f (!IsStandard())</span><br style=3D"font-family:arial,sans-serif;font-size=
:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0return error(&quot;AcceptToMemoryPool() : nonstandard t=
ransaction type&quot;);</span><br style=3D"font-family:arial,sans-serif;fon=
t-size:13px"><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
if (fClient)</span><br style=3D"font-family:arial,sans-serif;font-size:13px=
"><span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=
=A0 =C2=A0 =C2=A0return true;</span><br style=3D"font-family:arial,sans-ser=
if;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0// Do we already ha=
ve it?</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0uint256 hash =3D GetHash();</span><br style=3D"font-family:arial,sans=
-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-siz=
e:13px">=C2=A0 =C2=A0 =C2=A0CRITICAL_BLOCK(cs_</span><span style=3D"font-fa=
mily:arial,sans-serif;font-size:13px">mapTransactions)</span><br style=3D"f=
ont-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -1308,23 +13=
11,26 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><s=
pan style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=
=A0if (!CheckBlock())</span><br style=3D"font-family:arial,sans-serif;font-=
size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0return false;</span><br style=3D"font-family:arial,sans=
-serif;font-size:13px"><br style=3D"font-family:arial,sans-serif;font-size:=
13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =
=C2=A0//// issue here: it doesn&#39;t know the version</span><br style=3D"f=
ont-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
unsigned int nTxPos =3D pindex-&gt;nBlockPos + ::GetSerializeSize(CBlock(),=
 SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size(</span><span style=3D"font-f=
amily:arial,sans-serif;font-size:13px">));</span><br style=3D"font-family:a=
rial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">-</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0map&lt;uint256, CTxIndex=
&gt; mapUnused;</span><br style=3D"font-family:arial,sans-serif;font-size:1=
3px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
int64 nFees =3D 0;</span><br style=3D"font-family:arial,sans-serif;font-siz=
e:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=
=A0 =C2=A0foreach(CTransaction&amp; tx, vtx)</span><br style=3D"font-family=
:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
if (!fClient)</span><br style=3D"font-family:arial,sans-serif;font-size:13p=
x"><span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=
=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:13px"=
>
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0CDiskTxPos posThisTx(pindex-&gt;nFile, pindex-&gt;nBlockPos, =
nTxPos);</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><s=
pan style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0 =
=C2=A0 =C2=A0nTxPos +=3D ::GetSerializeSize(tx, SER_DISK);</span><br style=
=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0//// issue here: it doesn&#39;t know the version</span><br st=
yle=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fam=
ily:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned =
int nTxPos =3D pindex-&gt;nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK=
) - 1 + GetSizeOfCompactSize(vtx.size(</span><span style=3D"font-family:ari=
al,sans-serif;font-size:13px">));</span><br style=3D"font-family:arial,sans=
-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0map&lt;uin=
t256, CTxIndex&gt; mapUnused;</span><br style=3D"font-family:arial,sans-ser=
if;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0int64 nFees =3D 0;</span><br style=3D"font-family:arial,sans-=
serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size=
:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0foreach(CTransaction&amp; tx, vtx)</spa=
n><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:1=
3px"><span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CDiskTxPos posThisTx(pindex-&gt;nFile, pi=
ndex-&gt;nBlockPos, nTxPos);</span><br style=3D"font-family:arial,sans-seri=
f;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0nTxPos +=3D ::GetSerializeSize(tx, SER_DISK);</=
span><br style=3D"font-family:arial,sans-serif;font-size:13px"><br style=3D=
"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex, nFe=
es, true, false))</span><br style=3D"font-family:arial,sans-serif;font-size=
:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!tx.ConnectInputs(txdb, mapUnused, p=
osThisTx, pindex, nFees, true, false))</span><br style=3D"font-family:arial=
,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return false;</span><br style=3D"=
font-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:ari=
al,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0}</span><br styl=
e=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (vtx[0]=
.GetValueOut() &gt; GetBlockValue(pindex-&gt;nHeight, nFees))</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return false;</span><br style=3D"font-fam=
ily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-=
serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0}</span><br style=3D"font-family:=
arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0if (vtx[0].GetVal=
ueOut() &gt; GetBlockValue(pindex-&gt;nHeight, nFees))</span><br style=3D"f=
ont-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0return false;</span><br style=3D"font-family:arial,sans-serif=
;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px=
">-</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0// Update block index on disk without changing it in memory.</span><b=
r style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font=
-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0// The memory =
index structure will be changed after the db commits.</span><br style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0if (pindex-&gt;pprev)</span><br style=3D"font-family:arial,sans-serif=
;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px=
">@@ -1378,7 +1384,7 @@</span><br style=3D"font-family:arial,sans-serif;fon=
t-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0foreach(CBlockIndex* pindex, vDisconnect)</span><br style=3D"font-fam=
ily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-=
serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0{</span><br style=3D"font-family:=
arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0CBlock block;</span><br style=3D"font-family:arial,sans=
-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-siz=
e:13px">- =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.ReadFromDisk(pindex))</span=
><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!block.ReadFromDisk(pindex, !fClient))</span><br style=3D=
"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:ar=
ial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0return error(&quot;Reorganize() : ReadFromDisk for disconnect failed&=
quot;);</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0if (!block.DisconnectBlock(txdb, pindex))</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0return error(&quot;Reorganize() : DisconnectBlock failed&quot;);<=
/span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -1395,7 +140=
1,7 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><spa=
n style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=
=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0CBlockIndex* pindex =3D vConnect[i];</span><br style=3D=
"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:ar=
ial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CBlock blo=
ck;</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!block.ReadFromDisk(pindex))</span><br style=3D"font-fami=
ly:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-s=
erif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.ReadFromDisk(p=
index, !fClient))</span><br style=3D"font-family:arial,sans-serif;font-size=
:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return error(&quot;Reorganize() : ReadFro=
mDisk for connect failed&quot;);</span><br style=3D"font-family:arial,sans-=
serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size=
:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!block.ConnectBlock(txdb, pind=
ex))</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-=
size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -=
1526,7 +1532,7 @@</span><br style=3D"font-family:arial,sans-serif;font-size=
:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0txdb.Close()=
;</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><br style=
=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
if (pindexNew =3D=3D pindexBest)</span><br style=3D"font-family:arial,sans-=
serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size=
:13px">+ =C2=A0 =C2=A0if (!fClient &amp;&amp; pindexNew =3D=3D pindexBest)<=
/span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><sp=
an style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0// Notify UI to display prev block&#39;s coinbase if it wa=
s ours</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0static uint256 hashPrevBestCoinBase;</span><br style=3D=
"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:ar=
ial,sans-serif;font-size:13px">@@ -1547,10 +1553,6 @@</span><br style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0// These are checks that are independent of context</span><br style=
=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-family=
:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0// that can be verifi=
ed before saving an orphan block.</span><br style=3D"font-family:arial,sans=
-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0// Size limits</s=
pan><br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=
=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0if (vtx.emp=
ty() || vtx.size() &gt; MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NET=
WORK) &gt; MAX_BLOCK_SIZE)</span><br style=3D"font-family:arial,sans-serif;=
font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0return error(&quot;CheckBlock() : size limits failed&quot;);<=
/span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=
=3D"font-family:arial,sans-serif;font-size:13px">-</span><br style=3D"font-=
family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0// Check proof of work matches claimed amount</span><br style=3D"font=
-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,s=
ans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0if (!CheckProofOfWork(GetHash=
(), nBits))</span><br style=3D"font-family:arial,sans-serif;font-size:13px"=
>
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0return error(&quot;CheckBlock() : proof of work failed&=
quot;);</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><sp=
an style=3D"font-family:arial,sans-serif;font-size:13px">@@ -1559,6 +1561,1=
3 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0if (GetBlockTime() &gt; GetAdjustedTime() + 2 * 60 * 60)</span><br st=
yle=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fam=
ily:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0retu=
rn error(&quot;CheckBlock() : block timestamp too far in the future&quot;);=
</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0if (fClient &amp;=
&amp; vtx.empty())</span><br style=3D"font-family:arial,sans-serif;font-siz=
e:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=
=A0 =C2=A0 =C2=A0 =C2=A0return true;</span><br style=3D"font-family:arial,s=
ans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0// Size limits</span><br=
 style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
if (vtx.empty() || vtx.size() &gt; MAX_BLOCK_SIZE || ::GetSerializeSize(*th=
is, SER_NETWORK) &gt; MAX_BLOCK_SIZE)</span><br style=3D"font-family:arial,=
sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0return error(&quot;CheckBlock() : size limits failed&quot;);<=
/span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=
=3D"font-family:arial,sans-serif;font-size:13px">+</span><br style=3D"font-=
family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0// First transaction must be coinbase, the rest must not be</span><br=
 style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-=
family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0if (vtx.empty()=
 || !vtx[0].IsCoinBase())</span><br style=3D"font-family:arial,sans-serif;f=
ont-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0return error(&quot;CheckBlock() : first tx is not coinb=
ase&quot;);</span><br style=3D"font-family:arial,sans-serif;font-size:13px"=
><span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -1623,13 +1=
632,14 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0return error(&quot;AcceptBlock() : out of disk space&qu=
ot;);</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span=
 style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0=
unsigned int nFile =3D -1;</span><br style=3D"font-family:arial,sans-serif;=
font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0unsigned int nBlockPos =3D 0;</span><br style=3D"font-family:arial,sa=
ns-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-s=
ize:13px">- =C2=A0 =C2=A0if (!WriteToDisk(nFile, nBlockPos))</span><br styl=
e=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
 =C2=A0 =C2=A0return error(&quot;AcceptBlock() : WriteToDisk failed&quot;);=
</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span styl=
e=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0if (!fClie=
nt)</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!WriteToDisk(nFile, nBlockPos))</span><br style=3D"font-f=
amily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,san=
s-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return e=
rror(&quot;AcceptBlock() : WriteToDisk failed&quot;);</span><br style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0if (!AddToBlockIndex(nFile, nBlockPos))</span><br style=3D"font-famil=
y:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-se=
rif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return error(&quot;Ac=
ceptBlock() : AddToBlockIndex failed&quot;);</span><br style=3D"font-family=
:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0// Relay inv=
entory, but don&#39;t relay old inventory during initial block download</sp=
an><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">- =C2=A0 =C2=A0=
if (hashBestChain =3D=3D hash)</span><br style=3D"font-family:arial,sans-se=
rif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:1=
3px">+ =C2=A0 =C2=A0if (!fClient &amp;&amp; hashBestChain =3D=3D hash)</spa=
n><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0CRITICAL_BLOCK(cs_vNodes)</span><br style=3D"font-famil=
y:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-se=
rif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0foreach=
(CNode* pnode, vNodes)</span><br style=3D"font-family:arial,sans-serif;font=
-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (nBestHeight &gt; (pnode=
-&gt;nStartingHeight !=3D -1 ? pnode-&gt;nStartingHeight - 2000 : 55000))</=
span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -2405,6 +241=
5,8 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><spa=
n style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-siz=
e:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fShutdown)</span><br style=3D"font-fa=
mily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans=
-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0return true;</span><br style=3D"font-family:arial,sans-serif;font=
-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fClient &amp;&amp; inv.type =3D=3D MSG_TX)<=
/span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=
=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0continue;</span><br style=3D"font-family:ari=
al,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0pfrom-&gt;AddInventoryKnown(inv);</span><=
br style=3D"font-family:arial,sans-serif;font-size:13px"><br style=3D"font-=
family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0bool fAlreadyHave =3D AlreadyHave(txdb, i=
nv);</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><span =
style=3D"font-family:arial,sans-serif;font-size:13px">@@ -2441,6 +2453,9 @@=
</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<br style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"fo=
nt-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0if (inv.type =3D=3D MSG_BLOCK)</span><br style=3D"font-fam=
ily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-=
serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0{</sp=
an><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fClient)</span><br style=3D"f=
ont-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:aria=
l,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0return true;</span><br style=3D"font-family:aria=
l,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0// Send block from disk</span><br style=3D"font-fam=
ily:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0map&lt;uint256, CBlockIndex=
*&gt;::iterator mi =3D mapBlockIndex.find(inv.hash);</span><br style=3D"fon=
t-family:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,=
sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (mi !=3D mapBlockIndex.end())</span><br style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -2486,6 +250=
1,8 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><br =
style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-f=
amily:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0else if (strComm=
and =3D=3D &quot;getblocks&quot;)</span><br style=3D"font-family:arial,sans=
-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><sp=
an style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =
=C2=A0 =C2=A0if (fClient)</span><br style=3D"font-family:arial,sans-serif;f=
ont-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;</span><br style=3D"font-family:ari=
al,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;f=
ont-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CBlockLocator locator;</sp=
an><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0uint256 hashStop;</span><br style=3D"font-family:arial,=
sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font=
-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vRecv &gt;&gt; locator &gt;&g=
t; hashStop;</span><br style=3D"font-family:arial,sans-serif;font-size:13px=
">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -2556,6 +257=
3,8 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><br =
style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-f=
amily:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0else if (strComm=
and =3D=3D &quot;tx&quot;)</span><br style=3D"font-family:arial,sans-serif;=
font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0{</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><sp=
an style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =
=C2=A0 =C2=A0if (fClient)</span><br style=3D"font-family:arial,sans-serif;f=
ont-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;</span><br style=3D"font-family:ari=
al,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;f=
ont-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0vector&lt;uint256&gt; vWor=
kQueue;</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0CDataStream vMsg(vRecv);</span><br style=3D"font-family=
:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-ser=
if;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0CTransaction tx;</span=
><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">@@ -2620,6 +263=
9,33 @@</span><br style=3D"font-family:arial,sans-serif;font-size:13px"><br=
 style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-=
family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0i=
f (ProcessBlock(pfrom, &amp;block))</span><br style=3D"font-family:arial,sa=
ns-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mapAlreadyAskedFor.erase(inv);</span><br =
style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-f=
amily:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0}</span><br style=3D"=
font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+</span><br style=3D"font-family:arial,=
sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
else if (strCommand =3D=3D &quot;headers&quot;)</span><br style=3D"font-fam=
ily:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-=
serif;font-size:13px">+ =C2=A0 =C2=A0{</span><br style=3D"font-family:arial=
,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (!fClient)</span><br style=3D"font-family:arial,sans-serif=
;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-size:13px=
">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return true;</span><br style=
=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0vector&lt;CBlock&gt; vHeaders;</span><br style=3D"font-family=
:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-ser=
if;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0vRecv &gt;&gt; vHeaders;</s=
pan><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0uint256 ha=
shBestBefore =3D hashBestChain;</span><br style=3D"font-family:arial,sans-s=
erif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0foreach(CBlock&amp; block, vHeaders)</span><br style=3D"font-=
family:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sa=
ns-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0{</span><br style=3D"=
font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0block.vtx.clear();</span><br style=3D"font-fami=
ly:arial,sans-serif;font-size:13px"><span style=3D"font-family:arial,sans-s=
erif;font-size:13px">+</span><br style=3D"font-family:arial,sans-serif;font=
-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0printf(&quot;received header %s\n&quot;, block.=
GetHash().ToString().</span><span style=3D"font-family:arial,sans-serif;fon=
t-size:13px">substr(0,20).c_str());</span><br style=3D"font-family:arial,sa=
ns-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0CInv inv(MSG_BLOCK, block.GetHash());</span><br style=3D"font-family:=
arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0pfrom-&gt;AddInventoryKnown(inv);</span><br sty=
le=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-fami=
ly:arial,sans-serif;font-size:13px">+</span><br style=3D"font-family:arial,=
sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (ProcessBlock(pfrom, &amp;block))</span><br =
style=3D"font-family:arial,sans-serif;font-size:13px"><span style=3D"font-f=
amily:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0mapAlreadyAskedFor.erase(inv);</span><br style=3D"font=
-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0}</span><br style=3D"font-family:arial,sans-serif;font-size:1=
3px"><span style=3D"font-family:arial,sans-serif;font-size:13px">+</span><b=
r style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0// Request next batch</span><br style=3D"font-family:arial,sa=
ns-serif;font-size:13px"><span style=3D"font-family:arial,sans-serif;font-s=
ize:13px">+ =C2=A0 =C2=A0 =C2=A0 =C2=A0if (hashBestChain !=3D hashBestBefor=
e)</span><br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">+ =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0pfrom-&gt;PushGetBlocks(</span><span style=3D"f=
ont-family:arial,sans-serif;font-size:13px">pindexBest, uint256(0));</span>=
<br style=3D"font-family:arial,sans-serif;font-size:13px">
<span style=3D"font-family:arial,sans-serif;font-size:13px">=C2=A0 =C2=A0 =
=C2=A0}</span><br style=3D"font-family:arial,sans-serif;font-size:13px"></d=
iv></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On T=
ue, Jul 16, 2013 at 12:17 PM, Wendell <span dir=3D"ltr">&lt;<a href=3D"mail=
to:w@grabhive.com" target=3D"_blank">w@grabhive.com</a>&gt;</span> wrote:<b=
r>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">I for one would be interested in taking a lo=
ok at that.<br>
<br>
In San Jose I was asking around about the possibility of hiring someone to =
complete such a patch. Pieter Wuille introduced me to Eric Lombrozo, who ex=
pressed interest, but has since gotten quite busy. So we haven&#39;t arrive=
d at a detailed estimate of what it would involve.<br>

<br>
Maybe it would be better to start a completely new thread for this topic, b=
ut I would very much be interested in an open dissection of what adding SPV=
 support to bitcoind would take. I am willing to fund or (ideally) co-fund =
this endeavor, if I can ever get my head around it. I&#39;m super intereste=
d in all of these possibilities (including micro-stripped-VMs and transpila=
tion), but would simply like to encourage the proliferation of _options_ wh=
enever possible.<br>

<br>
-wendell<br>
<br>
<a href=3D"http://grabhive.com" target=3D"_blank">grabhive.com</a> | <a hre=
f=3D"http://twitter.com/grabhive" target=3D"_blank">twitter.com/grabhive</a=
><br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
On Jul 16, 2013, at 11:51 AM, Mike Hearn wrote:<br>
<br>
&gt; If you wanted to implement SPV mode in bitcoind, Gavin or I could send=
 you Satoshi&#39;s old patch although of course it is no longer usable. It =
would indicate the basic cut lines though.<br>
<br>
</div></div></blockquote></div><br></div>

--047d7b678126a0d23304e19ee022--