40
40
EmptyUncleHash = rlpHash ([]* Header (nil ))
41
41
)
42
42
43
+ type VerifyStatus struct {
44
+ Code uint16
45
+ Msg string
46
+ }
47
+
48
+ var (
49
+ // StatusVerified means the processing of request going as expected and found the root correctly.
50
+ StatusVerified = VerifyStatus {Code : 0x100 }
51
+ StatusFullVerified = VerifyStatus {Code : 0x101 , Msg : "state root full verified" }
52
+ StatusUntrustedVerified = VerifyStatus {Code : 0x102 , Msg : "state root untrusted verified, because of difflayer not found" }
53
+
54
+ // StatusFailed means the request has something wrong.
55
+ StatusFailed = VerifyStatus {Code : 0x200 }
56
+ StatusDiffHashMismatch = VerifyStatus {Code : 0x201 , Msg : "verify failed because of blockhash mismatch with diffhash" }
57
+ StatusImpossibleFork = VerifyStatus {Code : 0x202 , Msg : "verify failed because of impossible fork detected" }
58
+
59
+ // StatusUncertain means verify node can't give a certain result of the request.
60
+ StatusUncertain = VerifyStatus {Code : 0x300 }
61
+ StatusBlockTooNew = VerifyStatus {Code : 0x301 , Msg : "can’t verify because of block number larger than current height more than 11" }
62
+ StatusBlockNewer = VerifyStatus {Code : 0x302 , Msg : "can’t verify because of block number larger than current height" }
63
+ StatusPossibleFork = VerifyStatus {Code : 0x303 , Msg : "can’t verify because of possible fork detected" }
64
+ StatusRequestTooBusy = VerifyStatus {Code : 0x304 , Msg : "can’t verify because of request too busy" }
65
+
66
+ // StatusUnexpectedError is unexpected internal error.
67
+ StatusUnexpectedError = VerifyStatus {Code : 0x400 , Msg : "can’t verify because of unexpected internal error" }
68
+ )
69
+
70
+ type VerifyResult struct {
71
+ Status VerifyStatus
72
+ BlockNumber uint64
73
+ BlockHash common.Hash
74
+ Root common.Hash
75
+ }
76
+
43
77
// A BlockNonce is a 64-bit hash which proves (combined with the
44
78
// mix-hash) that a sufficient amount of computation has been carried
45
79
// out on a block.
@@ -383,7 +417,7 @@ type DiffLayer struct {
383
417
DiffHash common.Hash
384
418
}
385
419
386
- type extDiffLayer struct {
420
+ type ExtDiffLayer struct {
387
421
BlockHash common.Hash
388
422
Number uint64
389
423
Receipts []* ReceiptForStorage // Receipts are duplicated stored to simplify the logic
@@ -395,7 +429,7 @@ type extDiffLayer struct {
395
429
396
430
// DecodeRLP decodes the Ethereum
397
431
func (d * DiffLayer ) DecodeRLP (s * rlp.Stream ) error {
398
- var ed extDiffLayer
432
+ var ed ExtDiffLayer
399
433
if err := s .Decode (& ed ); err != nil {
400
434
return err
401
435
}
@@ -415,7 +449,7 @@ func (d *DiffLayer) EncodeRLP(w io.Writer) error {
415
449
for i , receipt := range d .Receipts {
416
450
storageReceipts [i ] = (* ReceiptForStorage )(receipt )
417
451
}
418
- return rlp .Encode (w , extDiffLayer {
452
+ return rlp .Encode (w , ExtDiffLayer {
419
453
BlockHash : d .BlockHash ,
420
454
Number : d .Number ,
421
455
Receipts : storageReceipts ,
@@ -443,17 +477,66 @@ type DiffCode struct {
443
477
Code []byte
444
478
}
445
479
480
+ // DiffCodeSlice is used for sort
481
+ type DiffCodeSlice []DiffCode
482
+
483
+ func (s DiffCodeSlice ) Len () int {
484
+ return len (s )
485
+ }
486
+
487
+ func (s DiffCodeSlice ) Less (i , j int ) bool {
488
+ return s [i ].Hash .Hex () < s [j ].Hash .Hex ()
489
+ }
490
+
491
+ func (s DiffCodeSlice ) Swap (i , j int ) {
492
+ s [i ].Hash , s [j ].Hash = s [j ].Hash , s [i ].Hash
493
+ s [i ].Code , s [j ].Code = s [j ].Code , s [i ].Code
494
+ }
495
+
446
496
type DiffAccount struct {
447
497
Account common.Address
448
498
Blob []byte
449
499
}
450
500
501
+ // DiffAccountSlice is used for sort
502
+ type DiffAccountSlice []DiffAccount
503
+
504
+ func (s DiffAccountSlice ) Len () int {
505
+ return len (s )
506
+ }
507
+
508
+ func (s DiffAccountSlice ) Less (i , j int ) bool {
509
+ return s [i ].Account .Hex () < s [j ].Account .Hex ()
510
+ }
511
+
512
+ func (s DiffAccountSlice ) Swap (i , j int ) {
513
+ s [i ].Account , s [j ].Account = s [j ].Account , s [i ].Account
514
+ s [i ].Blob , s [j ].Blob = s [j ].Blob , s [i ].Blob
515
+ }
516
+
451
517
type DiffStorage struct {
452
518
Account common.Address
453
519
Keys []string
454
520
Vals [][]byte
455
521
}
456
522
523
+ // DiffStorageSlice is used for sort
524
+ type DiffStorageSlice []DiffStorage
525
+
526
+ func (s DiffStorageSlice ) Len () int {
527
+ return len (s )
528
+ }
529
+
530
+ func (s DiffStorageSlice ) Less (i , j int ) bool {
531
+ return s [i ].Account .Hex () < s [j ].Account .Hex ()
532
+ }
533
+
534
+ func (s DiffStorageSlice ) Swap (i , j int ) {
535
+ s [i ].Account , s [j ].Account = s [j ].Account , s [i ].Account
536
+ s [i ].Keys , s [j ].Keys = s [j ].Keys , s [i ].Keys
537
+ s [i ].Vals , s [j ].Vals = s [j ].Vals , s [i ].Vals
538
+ }
539
+
457
540
type DiffAccountsInTx struct {
458
541
TxHash common.Hash
459
542
Accounts map [common.Address ]* big.Int
0 commit comments