summaryrefslogtreecommitdiff
path: root/cb/2d5e31962a4ef5d56adcabd16e1352330c71e2
blob: d4e78fb8bc1bc7a95cbf7d24a400e61096eba707 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
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--