github.com/amazechain/amc@v0.1.3/api/protocol/types_pb/generated.ssz.go (about) 1 // Code generated by fastssz. DO NOT EDIT. 2 // Hash: ff4c0802b1b743077781dae4de752322633988f240bb8e40a9f01dbceed1d869 3 package types_pb 4 5 import ( 6 ssz "github.com/prysmaticlabs/fastssz" 7 ) 8 9 // MarshalSSZ ssz marshals the H128 object 10 func (h *H128) MarshalSSZ() ([]byte, error) { 11 return ssz.MarshalSSZ(h) 12 } 13 14 // MarshalSSZTo ssz marshals the H128 object to a target array 15 func (h *H128) MarshalSSZTo(buf []byte) (dst []byte, err error) { 16 dst = buf 17 18 // Field (0) 'Hi' 19 dst = ssz.MarshalUint64(dst, h.Hi) 20 21 // Field (1) 'Lo' 22 dst = ssz.MarshalUint64(dst, h.Lo) 23 24 return 25 } 26 27 // UnmarshalSSZ ssz unmarshals the H128 object 28 func (h *H128) UnmarshalSSZ(buf []byte) error { 29 var err error 30 size := uint64(len(buf)) 31 if size != 16 { 32 return ssz.ErrSize 33 } 34 35 // Field (0) 'Hi' 36 h.Hi = ssz.UnmarshallUint64(buf[0:8]) 37 38 // Field (1) 'Lo' 39 h.Lo = ssz.UnmarshallUint64(buf[8:16]) 40 41 return err 42 } 43 44 // SizeSSZ returns the ssz encoded size in bytes for the H128 object 45 func (h *H128) SizeSSZ() (size int) { 46 size = 16 47 return 48 } 49 50 // HashTreeRoot ssz hashes the H128 object 51 func (h *H128) HashTreeRoot() ([32]byte, error) { 52 return ssz.HashWithDefaultHasher(h) 53 } 54 55 // HashTreeRootWith ssz hashes the H128 object with a hasher 56 func (h *H128) HashTreeRootWith(hh *ssz.Hasher) (err error) { 57 indx := hh.Index() 58 59 // Field (0) 'Hi' 60 hh.PutUint64(h.Hi) 61 62 // Field (1) 'Lo' 63 hh.PutUint64(h.Lo) 64 65 if ssz.EnableVectorizedHTR { 66 hh.MerkleizeVectorizedHTR(indx) 67 } else { 68 hh.Merkleize(indx) 69 } 70 return 71 } 72 73 // MarshalSSZ ssz marshals the H160 object 74 func (h *H160) MarshalSSZ() ([]byte, error) { 75 return ssz.MarshalSSZ(h) 76 } 77 78 // MarshalSSZTo ssz marshals the H160 object to a target array 79 func (h *H160) MarshalSSZTo(buf []byte) (dst []byte, err error) { 80 dst = buf 81 82 // Field (0) 'Hi' 83 if h.Hi == nil { 84 h.Hi = new(H128) 85 } 86 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 87 return 88 } 89 90 // Field (1) 'Lo' 91 dst = ssz.MarshalUint32(dst, h.Lo) 92 93 return 94 } 95 96 // UnmarshalSSZ ssz unmarshals the H160 object 97 func (h *H160) UnmarshalSSZ(buf []byte) error { 98 var err error 99 size := uint64(len(buf)) 100 if size != 20 { 101 return ssz.ErrSize 102 } 103 104 // Field (0) 'Hi' 105 if h.Hi == nil { 106 h.Hi = new(H128) 107 } 108 if err = h.Hi.UnmarshalSSZ(buf[0:16]); err != nil { 109 return err 110 } 111 112 // Field (1) 'Lo' 113 h.Lo = ssz.UnmarshallUint32(buf[16:20]) 114 115 return err 116 } 117 118 // SizeSSZ returns the ssz encoded size in bytes for the H160 object 119 func (h *H160) SizeSSZ() (size int) { 120 size = 20 121 return 122 } 123 124 // HashTreeRoot ssz hashes the H160 object 125 func (h *H160) HashTreeRoot() ([32]byte, error) { 126 return ssz.HashWithDefaultHasher(h) 127 } 128 129 // HashTreeRootWith ssz hashes the H160 object with a hasher 130 func (h *H160) HashTreeRootWith(hh *ssz.Hasher) (err error) { 131 indx := hh.Index() 132 133 // Field (0) 'Hi' 134 if err = h.Hi.HashTreeRootWith(hh); err != nil { 135 return 136 } 137 138 // Field (1) 'Lo' 139 hh.PutUint32(h.Lo) 140 141 if ssz.EnableVectorizedHTR { 142 hh.MerkleizeVectorizedHTR(indx) 143 } else { 144 hh.Merkleize(indx) 145 } 146 return 147 } 148 149 // MarshalSSZ ssz marshals the H256 object 150 func (h *H256) MarshalSSZ() ([]byte, error) { 151 return ssz.MarshalSSZ(h) 152 } 153 154 // MarshalSSZTo ssz marshals the H256 object to a target array 155 func (h *H256) MarshalSSZTo(buf []byte) (dst []byte, err error) { 156 dst = buf 157 158 // Field (0) 'Hi' 159 if h.Hi == nil { 160 h.Hi = new(H128) 161 } 162 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 163 return 164 } 165 166 // Field (1) 'Lo' 167 if h.Lo == nil { 168 h.Lo = new(H128) 169 } 170 if dst, err = h.Lo.MarshalSSZTo(dst); err != nil { 171 return 172 } 173 174 return 175 } 176 177 // UnmarshalSSZ ssz unmarshals the H256 object 178 func (h *H256) UnmarshalSSZ(buf []byte) error { 179 var err error 180 size := uint64(len(buf)) 181 if size != 32 { 182 return ssz.ErrSize 183 } 184 185 // Field (0) 'Hi' 186 if h.Hi == nil { 187 h.Hi = new(H128) 188 } 189 if err = h.Hi.UnmarshalSSZ(buf[0:16]); err != nil { 190 return err 191 } 192 193 // Field (1) 'Lo' 194 if h.Lo == nil { 195 h.Lo = new(H128) 196 } 197 if err = h.Lo.UnmarshalSSZ(buf[16:32]); err != nil { 198 return err 199 } 200 201 return err 202 } 203 204 // SizeSSZ returns the ssz encoded size in bytes for the H256 object 205 func (h *H256) SizeSSZ() (size int) { 206 size = 32 207 return 208 } 209 210 // HashTreeRoot ssz hashes the H256 object 211 func (h *H256) HashTreeRoot() ([32]byte, error) { 212 return ssz.HashWithDefaultHasher(h) 213 } 214 215 // HashTreeRootWith ssz hashes the H256 object with a hasher 216 func (h *H256) HashTreeRootWith(hh *ssz.Hasher) (err error) { 217 indx := hh.Index() 218 219 // Field (0) 'Hi' 220 if err = h.Hi.HashTreeRootWith(hh); err != nil { 221 return 222 } 223 224 // Field (1) 'Lo' 225 if err = h.Lo.HashTreeRootWith(hh); err != nil { 226 return 227 } 228 229 if ssz.EnableVectorizedHTR { 230 hh.MerkleizeVectorizedHTR(indx) 231 } else { 232 hh.Merkleize(indx) 233 } 234 return 235 } 236 237 // MarshalSSZ ssz marshals the H384 object 238 func (h *H384) MarshalSSZ() ([]byte, error) { 239 return ssz.MarshalSSZ(h) 240 } 241 242 // MarshalSSZTo ssz marshals the H384 object to a target array 243 func (h *H384) MarshalSSZTo(buf []byte) (dst []byte, err error) { 244 dst = buf 245 246 // Field (0) 'Hi' 247 if h.Hi == nil { 248 h.Hi = new(H256) 249 } 250 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 251 return 252 } 253 254 // Field (1) 'Lo' 255 if h.Lo == nil { 256 h.Lo = new(H128) 257 } 258 if dst, err = h.Lo.MarshalSSZTo(dst); err != nil { 259 return 260 } 261 262 return 263 } 264 265 // UnmarshalSSZ ssz unmarshals the H384 object 266 func (h *H384) UnmarshalSSZ(buf []byte) error { 267 var err error 268 size := uint64(len(buf)) 269 if size != 48 { 270 return ssz.ErrSize 271 } 272 273 // Field (0) 'Hi' 274 if h.Hi == nil { 275 h.Hi = new(H256) 276 } 277 if err = h.Hi.UnmarshalSSZ(buf[0:32]); err != nil { 278 return err 279 } 280 281 // Field (1) 'Lo' 282 if h.Lo == nil { 283 h.Lo = new(H128) 284 } 285 if err = h.Lo.UnmarshalSSZ(buf[32:48]); err != nil { 286 return err 287 } 288 289 return err 290 } 291 292 // SizeSSZ returns the ssz encoded size in bytes for the H384 object 293 func (h *H384) SizeSSZ() (size int) { 294 size = 48 295 return 296 } 297 298 // HashTreeRoot ssz hashes the H384 object 299 func (h *H384) HashTreeRoot() ([32]byte, error) { 300 return ssz.HashWithDefaultHasher(h) 301 } 302 303 // HashTreeRootWith ssz hashes the H384 object with a hasher 304 func (h *H384) HashTreeRootWith(hh *ssz.Hasher) (err error) { 305 indx := hh.Index() 306 307 // Field (0) 'Hi' 308 if err = h.Hi.HashTreeRootWith(hh); err != nil { 309 return 310 } 311 312 // Field (1) 'Lo' 313 if err = h.Lo.HashTreeRootWith(hh); err != nil { 314 return 315 } 316 317 if ssz.EnableVectorizedHTR { 318 hh.MerkleizeVectorizedHTR(indx) 319 } else { 320 hh.Merkleize(indx) 321 } 322 return 323 } 324 325 // MarshalSSZ ssz marshals the H768 object 326 func (h *H768) MarshalSSZ() ([]byte, error) { 327 return ssz.MarshalSSZ(h) 328 } 329 330 // MarshalSSZTo ssz marshals the H768 object to a target array 331 func (h *H768) MarshalSSZTo(buf []byte) (dst []byte, err error) { 332 dst = buf 333 334 // Field (0) 'Hi' 335 if h.Hi == nil { 336 h.Hi = new(H384) 337 } 338 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 339 return 340 } 341 342 // Field (1) 'Lo' 343 if h.Lo == nil { 344 h.Lo = new(H384) 345 } 346 if dst, err = h.Lo.MarshalSSZTo(dst); err != nil { 347 return 348 } 349 350 return 351 } 352 353 // UnmarshalSSZ ssz unmarshals the H768 object 354 func (h *H768) UnmarshalSSZ(buf []byte) error { 355 var err error 356 size := uint64(len(buf)) 357 if size != 96 { 358 return ssz.ErrSize 359 } 360 361 // Field (0) 'Hi' 362 if h.Hi == nil { 363 h.Hi = new(H384) 364 } 365 if err = h.Hi.UnmarshalSSZ(buf[0:48]); err != nil { 366 return err 367 } 368 369 // Field (1) 'Lo' 370 if h.Lo == nil { 371 h.Lo = new(H384) 372 } 373 if err = h.Lo.UnmarshalSSZ(buf[48:96]); err != nil { 374 return err 375 } 376 377 return err 378 } 379 380 // SizeSSZ returns the ssz encoded size in bytes for the H768 object 381 func (h *H768) SizeSSZ() (size int) { 382 size = 96 383 return 384 } 385 386 // HashTreeRoot ssz hashes the H768 object 387 func (h *H768) HashTreeRoot() ([32]byte, error) { 388 return ssz.HashWithDefaultHasher(h) 389 } 390 391 // HashTreeRootWith ssz hashes the H768 object with a hasher 392 func (h *H768) HashTreeRootWith(hh *ssz.Hasher) (err error) { 393 indx := hh.Index() 394 395 // Field (0) 'Hi' 396 if err = h.Hi.HashTreeRootWith(hh); err != nil { 397 return 398 } 399 400 // Field (1) 'Lo' 401 if err = h.Lo.HashTreeRootWith(hh); err != nil { 402 return 403 } 404 405 if ssz.EnableVectorizedHTR { 406 hh.MerkleizeVectorizedHTR(indx) 407 } else { 408 hh.Merkleize(indx) 409 } 410 return 411 } 412 413 // MarshalSSZ ssz marshals the H512 object 414 func (h *H512) MarshalSSZ() ([]byte, error) { 415 return ssz.MarshalSSZ(h) 416 } 417 418 // MarshalSSZTo ssz marshals the H512 object to a target array 419 func (h *H512) MarshalSSZTo(buf []byte) (dst []byte, err error) { 420 dst = buf 421 422 // Field (0) 'Hi' 423 if h.Hi == nil { 424 h.Hi = new(H256) 425 } 426 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 427 return 428 } 429 430 // Field (1) 'Lo' 431 if h.Lo == nil { 432 h.Lo = new(H256) 433 } 434 if dst, err = h.Lo.MarshalSSZTo(dst); err != nil { 435 return 436 } 437 438 return 439 } 440 441 // UnmarshalSSZ ssz unmarshals the H512 object 442 func (h *H512) UnmarshalSSZ(buf []byte) error { 443 var err error 444 size := uint64(len(buf)) 445 if size != 64 { 446 return ssz.ErrSize 447 } 448 449 // Field (0) 'Hi' 450 if h.Hi == nil { 451 h.Hi = new(H256) 452 } 453 if err = h.Hi.UnmarshalSSZ(buf[0:32]); err != nil { 454 return err 455 } 456 457 // Field (1) 'Lo' 458 if h.Lo == nil { 459 h.Lo = new(H256) 460 } 461 if err = h.Lo.UnmarshalSSZ(buf[32:64]); err != nil { 462 return err 463 } 464 465 return err 466 } 467 468 // SizeSSZ returns the ssz encoded size in bytes for the H512 object 469 func (h *H512) SizeSSZ() (size int) { 470 size = 64 471 return 472 } 473 474 // HashTreeRoot ssz hashes the H512 object 475 func (h *H512) HashTreeRoot() ([32]byte, error) { 476 return ssz.HashWithDefaultHasher(h) 477 } 478 479 // HashTreeRootWith ssz hashes the H512 object with a hasher 480 func (h *H512) HashTreeRootWith(hh *ssz.Hasher) (err error) { 481 indx := hh.Index() 482 483 // Field (0) 'Hi' 484 if err = h.Hi.HashTreeRootWith(hh); err != nil { 485 return 486 } 487 488 // Field (1) 'Lo' 489 if err = h.Lo.HashTreeRootWith(hh); err != nil { 490 return 491 } 492 493 if ssz.EnableVectorizedHTR { 494 hh.MerkleizeVectorizedHTR(indx) 495 } else { 496 hh.Merkleize(indx) 497 } 498 return 499 } 500 501 // MarshalSSZ ssz marshals the H1024 object 502 func (h *H1024) MarshalSSZ() ([]byte, error) { 503 return ssz.MarshalSSZ(h) 504 } 505 506 // MarshalSSZTo ssz marshals the H1024 object to a target array 507 func (h *H1024) MarshalSSZTo(buf []byte) (dst []byte, err error) { 508 dst = buf 509 510 // Field (0) 'Hi' 511 if h.Hi == nil { 512 h.Hi = new(H512) 513 } 514 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 515 return 516 } 517 518 // Field (1) 'Lo' 519 if h.Lo == nil { 520 h.Lo = new(H512) 521 } 522 if dst, err = h.Lo.MarshalSSZTo(dst); err != nil { 523 return 524 } 525 526 return 527 } 528 529 // UnmarshalSSZ ssz unmarshals the H1024 object 530 func (h *H1024) UnmarshalSSZ(buf []byte) error { 531 var err error 532 size := uint64(len(buf)) 533 if size != 128 { 534 return ssz.ErrSize 535 } 536 537 // Field (0) 'Hi' 538 if h.Hi == nil { 539 h.Hi = new(H512) 540 } 541 if err = h.Hi.UnmarshalSSZ(buf[0:64]); err != nil { 542 return err 543 } 544 545 // Field (1) 'Lo' 546 if h.Lo == nil { 547 h.Lo = new(H512) 548 } 549 if err = h.Lo.UnmarshalSSZ(buf[64:128]); err != nil { 550 return err 551 } 552 553 return err 554 } 555 556 // SizeSSZ returns the ssz encoded size in bytes for the H1024 object 557 func (h *H1024) SizeSSZ() (size int) { 558 size = 128 559 return 560 } 561 562 // HashTreeRoot ssz hashes the H1024 object 563 func (h *H1024) HashTreeRoot() ([32]byte, error) { 564 return ssz.HashWithDefaultHasher(h) 565 } 566 567 // HashTreeRootWith ssz hashes the H1024 object with a hasher 568 func (h *H1024) HashTreeRootWith(hh *ssz.Hasher) (err error) { 569 indx := hh.Index() 570 571 // Field (0) 'Hi' 572 if err = h.Hi.HashTreeRootWith(hh); err != nil { 573 return 574 } 575 576 // Field (1) 'Lo' 577 if err = h.Lo.HashTreeRootWith(hh); err != nil { 578 return 579 } 580 581 if ssz.EnableVectorizedHTR { 582 hh.MerkleizeVectorizedHTR(indx) 583 } else { 584 hh.Merkleize(indx) 585 } 586 return 587 } 588 589 // MarshalSSZ ssz marshals the H2048 object 590 func (h *H2048) MarshalSSZ() ([]byte, error) { 591 return ssz.MarshalSSZ(h) 592 } 593 594 // MarshalSSZTo ssz marshals the H2048 object to a target array 595 func (h *H2048) MarshalSSZTo(buf []byte) (dst []byte, err error) { 596 dst = buf 597 598 // Field (0) 'Hi' 599 if h.Hi == nil { 600 h.Hi = new(H1024) 601 } 602 if dst, err = h.Hi.MarshalSSZTo(dst); err != nil { 603 return 604 } 605 606 // Field (1) 'Lo' 607 if h.Lo == nil { 608 h.Lo = new(H1024) 609 } 610 if dst, err = h.Lo.MarshalSSZTo(dst); err != nil { 611 return 612 } 613 614 return 615 } 616 617 // UnmarshalSSZ ssz unmarshals the H2048 object 618 func (h *H2048) UnmarshalSSZ(buf []byte) error { 619 var err error 620 size := uint64(len(buf)) 621 if size != 256 { 622 return ssz.ErrSize 623 } 624 625 // Field (0) 'Hi' 626 if h.Hi == nil { 627 h.Hi = new(H1024) 628 } 629 if err = h.Hi.UnmarshalSSZ(buf[0:128]); err != nil { 630 return err 631 } 632 633 // Field (1) 'Lo' 634 if h.Lo == nil { 635 h.Lo = new(H1024) 636 } 637 if err = h.Lo.UnmarshalSSZ(buf[128:256]); err != nil { 638 return err 639 } 640 641 return err 642 } 643 644 // SizeSSZ returns the ssz encoded size in bytes for the H2048 object 645 func (h *H2048) SizeSSZ() (size int) { 646 size = 256 647 return 648 } 649 650 // HashTreeRoot ssz hashes the H2048 object 651 func (h *H2048) HashTreeRoot() ([32]byte, error) { 652 return ssz.HashWithDefaultHasher(h) 653 } 654 655 // HashTreeRootWith ssz hashes the H2048 object with a hasher 656 func (h *H2048) HashTreeRootWith(hh *ssz.Hasher) (err error) { 657 indx := hh.Index() 658 659 // Field (0) 'Hi' 660 if err = h.Hi.HashTreeRootWith(hh); err != nil { 661 return 662 } 663 664 // Field (1) 'Lo' 665 if err = h.Lo.HashTreeRootWith(hh); err != nil { 666 return 667 } 668 669 if ssz.EnableVectorizedHTR { 670 hh.MerkleizeVectorizedHTR(indx) 671 } else { 672 hh.Merkleize(indx) 673 } 674 return 675 } 676 677 // MarshalSSZ ssz marshals the Block object 678 func (b *Block) MarshalSSZ() ([]byte, error) { 679 return ssz.MarshalSSZ(b) 680 } 681 682 // MarshalSSZTo ssz marshals the Block object to a target array 683 func (b *Block) MarshalSSZTo(buf []byte) (dst []byte, err error) { 684 dst = buf 685 offset := int(8) 686 687 // Offset (0) 'Header' 688 dst = ssz.WriteOffset(dst, offset) 689 if b.Header == nil { 690 b.Header = new(Header) 691 } 692 offset += b.Header.SizeSSZ() 693 694 // Offset (1) 'Body' 695 dst = ssz.WriteOffset(dst, offset) 696 if b.Body == nil { 697 b.Body = new(Body) 698 } 699 offset += b.Body.SizeSSZ() 700 701 // Field (0) 'Header' 702 if dst, err = b.Header.MarshalSSZTo(dst); err != nil { 703 return 704 } 705 706 // Field (1) 'Body' 707 if dst, err = b.Body.MarshalSSZTo(dst); err != nil { 708 return 709 } 710 711 return 712 } 713 714 // UnmarshalSSZ ssz unmarshals the Block object 715 func (b *Block) UnmarshalSSZ(buf []byte) error { 716 var err error 717 size := uint64(len(buf)) 718 if size < 8 { 719 return ssz.ErrSize 720 } 721 722 tail := buf 723 var o0, o1 uint64 724 725 // Offset (0) 'Header' 726 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 727 return ssz.ErrOffset 728 } 729 730 if o0 < 8 { 731 return ssz.ErrInvalidVariableOffset 732 } 733 734 // Offset (1) 'Body' 735 if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { 736 return ssz.ErrOffset 737 } 738 739 // Field (0) 'Header' 740 { 741 buf = tail[o0:o1] 742 if b.Header == nil { 743 b.Header = new(Header) 744 } 745 if err = b.Header.UnmarshalSSZ(buf); err != nil { 746 return err 747 } 748 } 749 750 // Field (1) 'Body' 751 { 752 buf = tail[o1:] 753 if b.Body == nil { 754 b.Body = new(Body) 755 } 756 if err = b.Body.UnmarshalSSZ(buf); err != nil { 757 return err 758 } 759 } 760 return err 761 } 762 763 // SizeSSZ returns the ssz encoded size in bytes for the Block object 764 func (b *Block) SizeSSZ() (size int) { 765 size = 8 766 767 // Field (0) 'Header' 768 if b.Header == nil { 769 b.Header = new(Header) 770 } 771 size += b.Header.SizeSSZ() 772 773 // Field (1) 'Body' 774 if b.Body == nil { 775 b.Body = new(Body) 776 } 777 size += b.Body.SizeSSZ() 778 779 return 780 } 781 782 // HashTreeRoot ssz hashes the Block object 783 func (b *Block) HashTreeRoot() ([32]byte, error) { 784 return ssz.HashWithDefaultHasher(b) 785 } 786 787 // HashTreeRootWith ssz hashes the Block object with a hasher 788 func (b *Block) HashTreeRootWith(hh *ssz.Hasher) (err error) { 789 indx := hh.Index() 790 791 // Field (0) 'Header' 792 if err = b.Header.HashTreeRootWith(hh); err != nil { 793 return 794 } 795 796 // Field (1) 'Body' 797 if err = b.Body.HashTreeRootWith(hh); err != nil { 798 return 799 } 800 801 if ssz.EnableVectorizedHTR { 802 hh.MerkleizeVectorizedHTR(indx) 803 } else { 804 hh.Merkleize(indx) 805 } 806 return 807 } 808 809 // MarshalSSZ ssz marshals the Header object 810 func (h *Header) MarshalSSZ() ([]byte, error) { 811 return ssz.MarshalSSZ(h) 812 } 813 814 // MarshalSSZTo ssz marshals the Header object to a target array 815 func (h *Header) MarshalSSZTo(buf []byte) (dst []byte, err error) { 816 dst = buf 817 offset := int(664) 818 819 // Field (0) 'ParentHash' 820 if h.ParentHash == nil { 821 h.ParentHash = new(H256) 822 } 823 if dst, err = h.ParentHash.MarshalSSZTo(dst); err != nil { 824 return 825 } 826 827 // Field (1) 'Coinbase' 828 if h.Coinbase == nil { 829 h.Coinbase = new(H160) 830 } 831 if dst, err = h.Coinbase.MarshalSSZTo(dst); err != nil { 832 return 833 } 834 835 // Field (2) 'Root' 836 if h.Root == nil { 837 h.Root = new(H256) 838 } 839 if dst, err = h.Root.MarshalSSZTo(dst); err != nil { 840 return 841 } 842 843 // Field (3) 'TxHash' 844 if h.TxHash == nil { 845 h.TxHash = new(H256) 846 } 847 if dst, err = h.TxHash.MarshalSSZTo(dst); err != nil { 848 return 849 } 850 851 // Field (4) 'ReceiptHash' 852 if h.ReceiptHash == nil { 853 h.ReceiptHash = new(H256) 854 } 855 if dst, err = h.ReceiptHash.MarshalSSZTo(dst); err != nil { 856 return 857 } 858 859 // Field (5) 'Difficulty' 860 if h.Difficulty == nil { 861 h.Difficulty = new(H256) 862 } 863 if dst, err = h.Difficulty.MarshalSSZTo(dst); err != nil { 864 return 865 } 866 867 // Field (6) 'Number' 868 if h.Number == nil { 869 h.Number = new(H256) 870 } 871 if dst, err = h.Number.MarshalSSZTo(dst); err != nil { 872 return 873 } 874 875 // Field (7) 'GasLimit' 876 dst = ssz.MarshalUint64(dst, h.GasLimit) 877 878 // Field (8) 'GasUsed' 879 dst = ssz.MarshalUint64(dst, h.GasUsed) 880 881 // Field (9) 'Time' 882 dst = ssz.MarshalUint64(dst, h.Time) 883 884 // Field (10) 'Nonce' 885 dst = ssz.MarshalUint64(dst, h.Nonce) 886 887 // Field (11) 'BaseFee' 888 if h.BaseFee == nil { 889 h.BaseFee = new(H256) 890 } 891 if dst, err = h.BaseFee.MarshalSSZTo(dst); err != nil { 892 return 893 } 894 895 // Offset (12) 'Extra' 896 dst = ssz.WriteOffset(dst, offset) 897 offset += len(h.Extra) 898 899 // Field (13) 'Signature' 900 if h.Signature == nil { 901 h.Signature = new(H768) 902 } 903 if dst, err = h.Signature.MarshalSSZTo(dst); err != nil { 904 return 905 } 906 907 // Field (14) 'Bloom' 908 if h.Bloom == nil { 909 h.Bloom = new(H2048) 910 } 911 if dst, err = h.Bloom.MarshalSSZTo(dst); err != nil { 912 return 913 } 914 915 // Field (15) 'MixDigest' 916 if h.MixDigest == nil { 917 h.MixDigest = new(H256) 918 } 919 if dst, err = h.MixDigest.MarshalSSZTo(dst); err != nil { 920 return 921 } 922 923 // Field (12) 'Extra' 924 if size := len(h.Extra); size > 117 { 925 err = ssz.ErrBytesLengthFn("--.Extra", size, 117) 926 return 927 } 928 dst = append(dst, h.Extra...) 929 930 return 931 } 932 933 // UnmarshalSSZ ssz unmarshals the Header object 934 func (h *Header) UnmarshalSSZ(buf []byte) error { 935 var err error 936 size := uint64(len(buf)) 937 if size < 664 { 938 return ssz.ErrSize 939 } 940 941 tail := buf 942 var o12 uint64 943 944 // Field (0) 'ParentHash' 945 if h.ParentHash == nil { 946 h.ParentHash = new(H256) 947 } 948 if err = h.ParentHash.UnmarshalSSZ(buf[0:32]); err != nil { 949 return err 950 } 951 952 // Field (1) 'Coinbase' 953 if h.Coinbase == nil { 954 h.Coinbase = new(H160) 955 } 956 if err = h.Coinbase.UnmarshalSSZ(buf[32:52]); err != nil { 957 return err 958 } 959 960 // Field (2) 'Root' 961 if h.Root == nil { 962 h.Root = new(H256) 963 } 964 if err = h.Root.UnmarshalSSZ(buf[52:84]); err != nil { 965 return err 966 } 967 968 // Field (3) 'TxHash' 969 if h.TxHash == nil { 970 h.TxHash = new(H256) 971 } 972 if err = h.TxHash.UnmarshalSSZ(buf[84:116]); err != nil { 973 return err 974 } 975 976 // Field (4) 'ReceiptHash' 977 if h.ReceiptHash == nil { 978 h.ReceiptHash = new(H256) 979 } 980 if err = h.ReceiptHash.UnmarshalSSZ(buf[116:148]); err != nil { 981 return err 982 } 983 984 // Field (5) 'Difficulty' 985 if h.Difficulty == nil { 986 h.Difficulty = new(H256) 987 } 988 if err = h.Difficulty.UnmarshalSSZ(buf[148:180]); err != nil { 989 return err 990 } 991 992 // Field (6) 'Number' 993 if h.Number == nil { 994 h.Number = new(H256) 995 } 996 if err = h.Number.UnmarshalSSZ(buf[180:212]); err != nil { 997 return err 998 } 999 1000 // Field (7) 'GasLimit' 1001 h.GasLimit = ssz.UnmarshallUint64(buf[212:220]) 1002 1003 // Field (8) 'GasUsed' 1004 h.GasUsed = ssz.UnmarshallUint64(buf[220:228]) 1005 1006 // Field (9) 'Time' 1007 h.Time = ssz.UnmarshallUint64(buf[228:236]) 1008 1009 // Field (10) 'Nonce' 1010 h.Nonce = ssz.UnmarshallUint64(buf[236:244]) 1011 1012 // Field (11) 'BaseFee' 1013 if h.BaseFee == nil { 1014 h.BaseFee = new(H256) 1015 } 1016 if err = h.BaseFee.UnmarshalSSZ(buf[244:276]); err != nil { 1017 return err 1018 } 1019 1020 // Offset (12) 'Extra' 1021 if o12 = ssz.ReadOffset(buf[276:280]); o12 > size { 1022 return ssz.ErrOffset 1023 } 1024 1025 if o12 < 664 { 1026 return ssz.ErrInvalidVariableOffset 1027 } 1028 1029 // Field (13) 'Signature' 1030 if h.Signature == nil { 1031 h.Signature = new(H768) 1032 } 1033 if err = h.Signature.UnmarshalSSZ(buf[280:376]); err != nil { 1034 return err 1035 } 1036 1037 // Field (14) 'Bloom' 1038 if h.Bloom == nil { 1039 h.Bloom = new(H2048) 1040 } 1041 if err = h.Bloom.UnmarshalSSZ(buf[376:632]); err != nil { 1042 return err 1043 } 1044 1045 // Field (15) 'MixDigest' 1046 if h.MixDigest == nil { 1047 h.MixDigest = new(H256) 1048 } 1049 if err = h.MixDigest.UnmarshalSSZ(buf[632:664]); err != nil { 1050 return err 1051 } 1052 1053 // Field (12) 'Extra' 1054 { 1055 buf = tail[o12:] 1056 if len(buf) > 117 { 1057 return ssz.ErrBytesLength 1058 } 1059 if cap(h.Extra) == 0 { 1060 h.Extra = make([]byte, 0, len(buf)) 1061 } 1062 h.Extra = append(h.Extra, buf...) 1063 } 1064 return err 1065 } 1066 1067 // SizeSSZ returns the ssz encoded size in bytes for the Header object 1068 func (h *Header) SizeSSZ() (size int) { 1069 size = 664 1070 1071 // Field (12) 'Extra' 1072 size += len(h.Extra) 1073 1074 return 1075 } 1076 1077 // HashTreeRoot ssz hashes the Header object 1078 func (h *Header) HashTreeRoot() ([32]byte, error) { 1079 return ssz.HashWithDefaultHasher(h) 1080 } 1081 1082 // HashTreeRootWith ssz hashes the Header object with a hasher 1083 func (h *Header) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1084 indx := hh.Index() 1085 1086 // Field (0) 'ParentHash' 1087 if err = h.ParentHash.HashTreeRootWith(hh); err != nil { 1088 return 1089 } 1090 1091 // Field (1) 'Coinbase' 1092 if err = h.Coinbase.HashTreeRootWith(hh); err != nil { 1093 return 1094 } 1095 1096 // Field (2) 'Root' 1097 if err = h.Root.HashTreeRootWith(hh); err != nil { 1098 return 1099 } 1100 1101 // Field (3) 'TxHash' 1102 if err = h.TxHash.HashTreeRootWith(hh); err != nil { 1103 return 1104 } 1105 1106 // Field (4) 'ReceiptHash' 1107 if err = h.ReceiptHash.HashTreeRootWith(hh); err != nil { 1108 return 1109 } 1110 1111 // Field (5) 'Difficulty' 1112 if err = h.Difficulty.HashTreeRootWith(hh); err != nil { 1113 return 1114 } 1115 1116 // Field (6) 'Number' 1117 if err = h.Number.HashTreeRootWith(hh); err != nil { 1118 return 1119 } 1120 1121 // Field (7) 'GasLimit' 1122 hh.PutUint64(h.GasLimit) 1123 1124 // Field (8) 'GasUsed' 1125 hh.PutUint64(h.GasUsed) 1126 1127 // Field (9) 'Time' 1128 hh.PutUint64(h.Time) 1129 1130 // Field (10) 'Nonce' 1131 hh.PutUint64(h.Nonce) 1132 1133 // Field (11) 'BaseFee' 1134 if err = h.BaseFee.HashTreeRootWith(hh); err != nil { 1135 return 1136 } 1137 1138 // Field (12) 'Extra' 1139 { 1140 elemIndx := hh.Index() 1141 byteLen := uint64(len(h.Extra)) 1142 if byteLen > 117 { 1143 err = ssz.ErrIncorrectListSize 1144 return 1145 } 1146 hh.PutBytes(h.Extra) 1147 if ssz.EnableVectorizedHTR { 1148 hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (117+31)/32) 1149 } else { 1150 hh.MerkleizeWithMixin(elemIndx, byteLen, (117+31)/32) 1151 } 1152 } 1153 1154 // Field (13) 'Signature' 1155 if err = h.Signature.HashTreeRootWith(hh); err != nil { 1156 return 1157 } 1158 1159 // Field (14) 'Bloom' 1160 if err = h.Bloom.HashTreeRootWith(hh); err != nil { 1161 return 1162 } 1163 1164 // Field (15) 'MixDigest' 1165 if err = h.MixDigest.HashTreeRootWith(hh); err != nil { 1166 return 1167 } 1168 1169 if ssz.EnableVectorizedHTR { 1170 hh.MerkleizeVectorizedHTR(indx) 1171 } else { 1172 hh.Merkleize(indx) 1173 } 1174 return 1175 } 1176 1177 // MarshalSSZ ssz marshals the Verifier object 1178 func (v *Verifier) MarshalSSZ() ([]byte, error) { 1179 return ssz.MarshalSSZ(v) 1180 } 1181 1182 // MarshalSSZTo ssz marshals the Verifier object to a target array 1183 func (v *Verifier) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1184 dst = buf 1185 1186 // Field (0) 'PublicKey' 1187 if v.PublicKey == nil { 1188 v.PublicKey = new(H384) 1189 } 1190 if dst, err = v.PublicKey.MarshalSSZTo(dst); err != nil { 1191 return 1192 } 1193 1194 // Field (1) 'Address' 1195 if v.Address == nil { 1196 v.Address = new(H160) 1197 } 1198 if dst, err = v.Address.MarshalSSZTo(dst); err != nil { 1199 return 1200 } 1201 1202 return 1203 } 1204 1205 // UnmarshalSSZ ssz unmarshals the Verifier object 1206 func (v *Verifier) UnmarshalSSZ(buf []byte) error { 1207 var err error 1208 size := uint64(len(buf)) 1209 if size != 68 { 1210 return ssz.ErrSize 1211 } 1212 1213 // Field (0) 'PublicKey' 1214 if v.PublicKey == nil { 1215 v.PublicKey = new(H384) 1216 } 1217 if err = v.PublicKey.UnmarshalSSZ(buf[0:48]); err != nil { 1218 return err 1219 } 1220 1221 // Field (1) 'Address' 1222 if v.Address == nil { 1223 v.Address = new(H160) 1224 } 1225 if err = v.Address.UnmarshalSSZ(buf[48:68]); err != nil { 1226 return err 1227 } 1228 1229 return err 1230 } 1231 1232 // SizeSSZ returns the ssz encoded size in bytes for the Verifier object 1233 func (v *Verifier) SizeSSZ() (size int) { 1234 size = 68 1235 return 1236 } 1237 1238 // HashTreeRoot ssz hashes the Verifier object 1239 func (v *Verifier) HashTreeRoot() ([32]byte, error) { 1240 return ssz.HashWithDefaultHasher(v) 1241 } 1242 1243 // HashTreeRootWith ssz hashes the Verifier object with a hasher 1244 func (v *Verifier) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1245 indx := hh.Index() 1246 1247 // Field (0) 'PublicKey' 1248 if err = v.PublicKey.HashTreeRootWith(hh); err != nil { 1249 return 1250 } 1251 1252 // Field (1) 'Address' 1253 if err = v.Address.HashTreeRootWith(hh); err != nil { 1254 return 1255 } 1256 1257 if ssz.EnableVectorizedHTR { 1258 hh.MerkleizeVectorizedHTR(indx) 1259 } else { 1260 hh.Merkleize(indx) 1261 } 1262 return 1263 } 1264 1265 // MarshalSSZ ssz marshals the Reward object 1266 func (r *Reward) MarshalSSZ() ([]byte, error) { 1267 return ssz.MarshalSSZ(r) 1268 } 1269 1270 // MarshalSSZTo ssz marshals the Reward object to a target array 1271 func (r *Reward) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1272 dst = buf 1273 1274 // Field (0) 'Amount' 1275 if r.Amount == nil { 1276 r.Amount = new(H256) 1277 } 1278 if dst, err = r.Amount.MarshalSSZTo(dst); err != nil { 1279 return 1280 } 1281 1282 // Field (1) 'Address' 1283 if r.Address == nil { 1284 r.Address = new(H160) 1285 } 1286 if dst, err = r.Address.MarshalSSZTo(dst); err != nil { 1287 return 1288 } 1289 1290 return 1291 } 1292 1293 // UnmarshalSSZ ssz unmarshals the Reward object 1294 func (r *Reward) UnmarshalSSZ(buf []byte) error { 1295 var err error 1296 size := uint64(len(buf)) 1297 if size != 52 { 1298 return ssz.ErrSize 1299 } 1300 1301 // Field (0) 'Amount' 1302 if r.Amount == nil { 1303 r.Amount = new(H256) 1304 } 1305 if err = r.Amount.UnmarshalSSZ(buf[0:32]); err != nil { 1306 return err 1307 } 1308 1309 // Field (1) 'Address' 1310 if r.Address == nil { 1311 r.Address = new(H160) 1312 } 1313 if err = r.Address.UnmarshalSSZ(buf[32:52]); err != nil { 1314 return err 1315 } 1316 1317 return err 1318 } 1319 1320 // SizeSSZ returns the ssz encoded size in bytes for the Reward object 1321 func (r *Reward) SizeSSZ() (size int) { 1322 size = 52 1323 return 1324 } 1325 1326 // HashTreeRoot ssz hashes the Reward object 1327 func (r *Reward) HashTreeRoot() ([32]byte, error) { 1328 return ssz.HashWithDefaultHasher(r) 1329 } 1330 1331 // HashTreeRootWith ssz hashes the Reward object with a hasher 1332 func (r *Reward) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1333 indx := hh.Index() 1334 1335 // Field (0) 'Amount' 1336 if err = r.Amount.HashTreeRootWith(hh); err != nil { 1337 return 1338 } 1339 1340 // Field (1) 'Address' 1341 if err = r.Address.HashTreeRootWith(hh); err != nil { 1342 return 1343 } 1344 1345 if ssz.EnableVectorizedHTR { 1346 hh.MerkleizeVectorizedHTR(indx) 1347 } else { 1348 hh.Merkleize(indx) 1349 } 1350 return 1351 } 1352 1353 // MarshalSSZ ssz marshals the Body object 1354 func (b *Body) MarshalSSZ() ([]byte, error) { 1355 return ssz.MarshalSSZ(b) 1356 } 1357 1358 // MarshalSSZTo ssz marshals the Body object to a target array 1359 func (b *Body) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1360 dst = buf 1361 offset := int(12) 1362 1363 // Offset (0) 'Txs' 1364 dst = ssz.WriteOffset(dst, offset) 1365 for ii := 0; ii < len(b.Txs); ii++ { 1366 offset += 4 1367 offset += b.Txs[ii].SizeSSZ() 1368 } 1369 1370 // Offset (1) 'Verifiers' 1371 dst = ssz.WriteOffset(dst, offset) 1372 offset += len(b.Verifiers) * 68 1373 1374 // Offset (2) 'Rewards' 1375 dst = ssz.WriteOffset(dst, offset) 1376 offset += len(b.Rewards) * 52 1377 1378 // Field (0) 'Txs' 1379 if size := len(b.Txs); size > 104857600 { 1380 err = ssz.ErrListTooBigFn("--.Txs", size, 104857600) 1381 return 1382 } 1383 { 1384 offset = 4 * len(b.Txs) 1385 for ii := 0; ii < len(b.Txs); ii++ { 1386 dst = ssz.WriteOffset(dst, offset) 1387 offset += b.Txs[ii].SizeSSZ() 1388 } 1389 } 1390 for ii := 0; ii < len(b.Txs); ii++ { 1391 if dst, err = b.Txs[ii].MarshalSSZTo(dst); err != nil { 1392 return 1393 } 1394 } 1395 1396 // Field (1) 'Verifiers' 1397 if size := len(b.Verifiers); size > 104857600 { 1398 err = ssz.ErrListTooBigFn("--.Verifiers", size, 104857600) 1399 return 1400 } 1401 for ii := 0; ii < len(b.Verifiers); ii++ { 1402 if dst, err = b.Verifiers[ii].MarshalSSZTo(dst); err != nil { 1403 return 1404 } 1405 } 1406 1407 // Field (2) 'Rewards' 1408 if size := len(b.Rewards); size > 104857600 { 1409 err = ssz.ErrListTooBigFn("--.Rewards", size, 104857600) 1410 return 1411 } 1412 for ii := 0; ii < len(b.Rewards); ii++ { 1413 if dst, err = b.Rewards[ii].MarshalSSZTo(dst); err != nil { 1414 return 1415 } 1416 } 1417 1418 return 1419 } 1420 1421 // UnmarshalSSZ ssz unmarshals the Body object 1422 func (b *Body) UnmarshalSSZ(buf []byte) error { 1423 var err error 1424 size := uint64(len(buf)) 1425 if size < 12 { 1426 return ssz.ErrSize 1427 } 1428 1429 tail := buf 1430 var o0, o1, o2 uint64 1431 1432 // Offset (0) 'Txs' 1433 if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { 1434 return ssz.ErrOffset 1435 } 1436 1437 if o0 < 12 { 1438 return ssz.ErrInvalidVariableOffset 1439 } 1440 1441 // Offset (1) 'Verifiers' 1442 if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { 1443 return ssz.ErrOffset 1444 } 1445 1446 // Offset (2) 'Rewards' 1447 if o2 = ssz.ReadOffset(buf[8:12]); o2 > size || o1 > o2 { 1448 return ssz.ErrOffset 1449 } 1450 1451 // Field (0) 'Txs' 1452 { 1453 buf = tail[o0:o1] 1454 num, err := ssz.DecodeDynamicLength(buf, 104857600) 1455 if err != nil { 1456 return err 1457 } 1458 b.Txs = make([]*Transaction, num) 1459 err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { 1460 if b.Txs[indx] == nil { 1461 b.Txs[indx] = new(Transaction) 1462 } 1463 if err = b.Txs[indx].UnmarshalSSZ(buf); err != nil { 1464 return err 1465 } 1466 return nil 1467 }) 1468 if err != nil { 1469 return err 1470 } 1471 } 1472 1473 // Field (1) 'Verifiers' 1474 { 1475 buf = tail[o1:o2] 1476 num, err := ssz.DivideInt2(len(buf), 68, 104857600) 1477 if err != nil { 1478 return err 1479 } 1480 b.Verifiers = make([]*Verifier, num) 1481 for ii := 0; ii < num; ii++ { 1482 if b.Verifiers[ii] == nil { 1483 b.Verifiers[ii] = new(Verifier) 1484 } 1485 if err = b.Verifiers[ii].UnmarshalSSZ(buf[ii*68 : (ii+1)*68]); err != nil { 1486 return err 1487 } 1488 } 1489 } 1490 1491 // Field (2) 'Rewards' 1492 { 1493 buf = tail[o2:] 1494 num, err := ssz.DivideInt2(len(buf), 52, 104857600) 1495 if err != nil { 1496 return err 1497 } 1498 b.Rewards = make([]*Reward, num) 1499 for ii := 0; ii < num; ii++ { 1500 if b.Rewards[ii] == nil { 1501 b.Rewards[ii] = new(Reward) 1502 } 1503 if err = b.Rewards[ii].UnmarshalSSZ(buf[ii*52 : (ii+1)*52]); err != nil { 1504 return err 1505 } 1506 } 1507 } 1508 return err 1509 } 1510 1511 // SizeSSZ returns the ssz encoded size in bytes for the Body object 1512 func (b *Body) SizeSSZ() (size int) { 1513 size = 12 1514 1515 // Field (0) 'Txs' 1516 for ii := 0; ii < len(b.Txs); ii++ { 1517 size += 4 1518 size += b.Txs[ii].SizeSSZ() 1519 } 1520 1521 // Field (1) 'Verifiers' 1522 size += len(b.Verifiers) * 68 1523 1524 // Field (2) 'Rewards' 1525 size += len(b.Rewards) * 52 1526 1527 return 1528 } 1529 1530 // HashTreeRoot ssz hashes the Body object 1531 func (b *Body) HashTreeRoot() ([32]byte, error) { 1532 return ssz.HashWithDefaultHasher(b) 1533 } 1534 1535 // HashTreeRootWith ssz hashes the Body object with a hasher 1536 func (b *Body) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1537 indx := hh.Index() 1538 1539 // Field (0) 'Txs' 1540 { 1541 subIndx := hh.Index() 1542 num := uint64(len(b.Txs)) 1543 if num > 104857600 { 1544 err = ssz.ErrIncorrectListSize 1545 return 1546 } 1547 for _, elem := range b.Txs { 1548 if err = elem.HashTreeRootWith(hh); err != nil { 1549 return 1550 } 1551 } 1552 if ssz.EnableVectorizedHTR { 1553 hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 104857600) 1554 } else { 1555 hh.MerkleizeWithMixin(subIndx, num, 104857600) 1556 } 1557 } 1558 1559 // Field (1) 'Verifiers' 1560 { 1561 subIndx := hh.Index() 1562 num := uint64(len(b.Verifiers)) 1563 if num > 104857600 { 1564 err = ssz.ErrIncorrectListSize 1565 return 1566 } 1567 for _, elem := range b.Verifiers { 1568 if err = elem.HashTreeRootWith(hh); err != nil { 1569 return 1570 } 1571 } 1572 if ssz.EnableVectorizedHTR { 1573 hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 104857600) 1574 } else { 1575 hh.MerkleizeWithMixin(subIndx, num, 104857600) 1576 } 1577 } 1578 1579 // Field (2) 'Rewards' 1580 { 1581 subIndx := hh.Index() 1582 num := uint64(len(b.Rewards)) 1583 if num > 104857600 { 1584 err = ssz.ErrIncorrectListSize 1585 return 1586 } 1587 for _, elem := range b.Rewards { 1588 if err = elem.HashTreeRootWith(hh); err != nil { 1589 return 1590 } 1591 } 1592 if ssz.EnableVectorizedHTR { 1593 hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 104857600) 1594 } else { 1595 hh.MerkleizeWithMixin(subIndx, num, 104857600) 1596 } 1597 } 1598 1599 if ssz.EnableVectorizedHTR { 1600 hh.MerkleizeVectorizedHTR(indx) 1601 } else { 1602 hh.Merkleize(indx) 1603 } 1604 return 1605 } 1606 1607 // MarshalSSZ ssz marshals the Transaction object 1608 func (t *Transaction) MarshalSSZ() ([]byte, error) { 1609 return ssz.MarshalSSZ(t) 1610 } 1611 1612 // MarshalSSZTo ssz marshals the Transaction object to a target array 1613 func (t *Transaction) MarshalSSZTo(buf []byte) (dst []byte, err error) { 1614 dst = buf 1615 offset := int(336) 1616 1617 // Field (0) 'Type' 1618 dst = ssz.MarshalUint64(dst, t.Type) 1619 1620 // Field (1) 'Nonce' 1621 dst = ssz.MarshalUint64(dst, t.Nonce) 1622 1623 // Field (2) 'GasPrice' 1624 if t.GasPrice == nil { 1625 t.GasPrice = new(H256) 1626 } 1627 if dst, err = t.GasPrice.MarshalSSZTo(dst); err != nil { 1628 return 1629 } 1630 1631 // Field (3) 'Gas' 1632 dst = ssz.MarshalUint64(dst, t.Gas) 1633 1634 // Field (4) 'FeePerGas' 1635 if t.FeePerGas == nil { 1636 t.FeePerGas = new(H256) 1637 } 1638 if dst, err = t.FeePerGas.MarshalSSZTo(dst); err != nil { 1639 return 1640 } 1641 1642 // Field (5) 'PriorityFeePerGas' 1643 if t.PriorityFeePerGas == nil { 1644 t.PriorityFeePerGas = new(H256) 1645 } 1646 if dst, err = t.PriorityFeePerGas.MarshalSSZTo(dst); err != nil { 1647 return 1648 } 1649 1650 // Field (6) 'Value' 1651 if t.Value == nil { 1652 t.Value = new(H256) 1653 } 1654 if dst, err = t.Value.MarshalSSZTo(dst); err != nil { 1655 return 1656 } 1657 1658 // Offset (7) 'Data' 1659 dst = ssz.WriteOffset(dst, offset) 1660 offset += len(t.Data) 1661 1662 // Offset (8) 'Sign' 1663 dst = ssz.WriteOffset(dst, offset) 1664 offset += len(t.Sign) 1665 1666 // Field (9) 'To' 1667 if t.To == nil { 1668 t.To = new(H160) 1669 } 1670 if dst, err = t.To.MarshalSSZTo(dst); err != nil { 1671 return 1672 } 1673 1674 // Field (10) 'From' 1675 if t.From == nil { 1676 t.From = new(H160) 1677 } 1678 if dst, err = t.From.MarshalSSZTo(dst); err != nil { 1679 return 1680 } 1681 1682 // Field (11) 'ChainID' 1683 dst = ssz.MarshalUint64(dst, t.ChainID) 1684 1685 // Field (12) 'Hash' 1686 if t.Hash == nil { 1687 t.Hash = new(H256) 1688 } 1689 if dst, err = t.Hash.MarshalSSZTo(dst); err != nil { 1690 return 1691 } 1692 1693 // Field (13) 'R' 1694 if t.R == nil { 1695 t.R = new(H256) 1696 } 1697 if dst, err = t.R.MarshalSSZTo(dst); err != nil { 1698 return 1699 } 1700 1701 // Field (14) 'S' 1702 if t.S == nil { 1703 t.S = new(H256) 1704 } 1705 if dst, err = t.S.MarshalSSZTo(dst); err != nil { 1706 return 1707 } 1708 1709 // Field (15) 'V' 1710 if t.V == nil { 1711 t.V = new(H256) 1712 } 1713 if dst, err = t.V.MarshalSSZTo(dst); err != nil { 1714 return 1715 } 1716 1717 // Field (7) 'Data' 1718 if size := len(t.Data); size > 104857600 { 1719 err = ssz.ErrBytesLengthFn("--.Data", size, 104857600) 1720 return 1721 } 1722 dst = append(dst, t.Data...) 1723 1724 // Field (8) 'Sign' 1725 if size := len(t.Sign); size > 104857600 { 1726 err = ssz.ErrBytesLengthFn("--.Sign", size, 104857600) 1727 return 1728 } 1729 dst = append(dst, t.Sign...) 1730 1731 return 1732 } 1733 1734 // UnmarshalSSZ ssz unmarshals the Transaction object 1735 func (t *Transaction) UnmarshalSSZ(buf []byte) error { 1736 var err error 1737 size := uint64(len(buf)) 1738 if size < 336 { 1739 return ssz.ErrSize 1740 } 1741 1742 tail := buf 1743 var o7, o8 uint64 1744 1745 // Field (0) 'Type' 1746 t.Type = ssz.UnmarshallUint64(buf[0:8]) 1747 1748 // Field (1) 'Nonce' 1749 t.Nonce = ssz.UnmarshallUint64(buf[8:16]) 1750 1751 // Field (2) 'GasPrice' 1752 if t.GasPrice == nil { 1753 t.GasPrice = new(H256) 1754 } 1755 if err = t.GasPrice.UnmarshalSSZ(buf[16:48]); err != nil { 1756 return err 1757 } 1758 1759 // Field (3) 'Gas' 1760 t.Gas = ssz.UnmarshallUint64(buf[48:56]) 1761 1762 // Field (4) 'FeePerGas' 1763 if t.FeePerGas == nil { 1764 t.FeePerGas = new(H256) 1765 } 1766 if err = t.FeePerGas.UnmarshalSSZ(buf[56:88]); err != nil { 1767 return err 1768 } 1769 1770 // Field (5) 'PriorityFeePerGas' 1771 if t.PriorityFeePerGas == nil { 1772 t.PriorityFeePerGas = new(H256) 1773 } 1774 if err = t.PriorityFeePerGas.UnmarshalSSZ(buf[88:120]); err != nil { 1775 return err 1776 } 1777 1778 // Field (6) 'Value' 1779 if t.Value == nil { 1780 t.Value = new(H256) 1781 } 1782 if err = t.Value.UnmarshalSSZ(buf[120:152]); err != nil { 1783 return err 1784 } 1785 1786 // Offset (7) 'Data' 1787 if o7 = ssz.ReadOffset(buf[152:156]); o7 > size { 1788 return ssz.ErrOffset 1789 } 1790 1791 if o7 < 336 { 1792 return ssz.ErrInvalidVariableOffset 1793 } 1794 1795 // Offset (8) 'Sign' 1796 if o8 = ssz.ReadOffset(buf[156:160]); o8 > size || o7 > o8 { 1797 return ssz.ErrOffset 1798 } 1799 1800 // Field (9) 'To' 1801 if t.To == nil { 1802 t.To = new(H160) 1803 } 1804 if err = t.To.UnmarshalSSZ(buf[160:180]); err != nil { 1805 return err 1806 } 1807 1808 // Field (10) 'From' 1809 if t.From == nil { 1810 t.From = new(H160) 1811 } 1812 if err = t.From.UnmarshalSSZ(buf[180:200]); err != nil { 1813 return err 1814 } 1815 1816 // Field (11) 'ChainID' 1817 t.ChainID = ssz.UnmarshallUint64(buf[200:208]) 1818 1819 // Field (12) 'Hash' 1820 if t.Hash == nil { 1821 t.Hash = new(H256) 1822 } 1823 if err = t.Hash.UnmarshalSSZ(buf[208:240]); err != nil { 1824 return err 1825 } 1826 1827 // Field (13) 'R' 1828 if t.R == nil { 1829 t.R = new(H256) 1830 } 1831 if err = t.R.UnmarshalSSZ(buf[240:272]); err != nil { 1832 return err 1833 } 1834 1835 // Field (14) 'S' 1836 if t.S == nil { 1837 t.S = new(H256) 1838 } 1839 if err = t.S.UnmarshalSSZ(buf[272:304]); err != nil { 1840 return err 1841 } 1842 1843 // Field (15) 'V' 1844 if t.V == nil { 1845 t.V = new(H256) 1846 } 1847 if err = t.V.UnmarshalSSZ(buf[304:336]); err != nil { 1848 return err 1849 } 1850 1851 // Field (7) 'Data' 1852 { 1853 buf = tail[o7:o8] 1854 if len(buf) > 104857600 { 1855 return ssz.ErrBytesLength 1856 } 1857 if cap(t.Data) == 0 { 1858 t.Data = make([]byte, 0, len(buf)) 1859 } 1860 t.Data = append(t.Data, buf...) 1861 } 1862 1863 // Field (8) 'Sign' 1864 { 1865 buf = tail[o8:] 1866 if len(buf) > 104857600 { 1867 return ssz.ErrBytesLength 1868 } 1869 if cap(t.Sign) == 0 { 1870 t.Sign = make([]byte, 0, len(buf)) 1871 } 1872 t.Sign = append(t.Sign, buf...) 1873 } 1874 return err 1875 } 1876 1877 // SizeSSZ returns the ssz encoded size in bytes for the Transaction object 1878 func (t *Transaction) SizeSSZ() (size int) { 1879 size = 336 1880 1881 // Field (7) 'Data' 1882 size += len(t.Data) 1883 1884 // Field (8) 'Sign' 1885 size += len(t.Sign) 1886 1887 return 1888 } 1889 1890 // HashTreeRoot ssz hashes the Transaction object 1891 func (t *Transaction) HashTreeRoot() ([32]byte, error) { 1892 return ssz.HashWithDefaultHasher(t) 1893 } 1894 1895 // HashTreeRootWith ssz hashes the Transaction object with a hasher 1896 func (t *Transaction) HashTreeRootWith(hh *ssz.Hasher) (err error) { 1897 indx := hh.Index() 1898 1899 // Field (0) 'Type' 1900 hh.PutUint64(t.Type) 1901 1902 // Field (1) 'Nonce' 1903 hh.PutUint64(t.Nonce) 1904 1905 // Field (2) 'GasPrice' 1906 if err = t.GasPrice.HashTreeRootWith(hh); err != nil { 1907 return 1908 } 1909 1910 // Field (3) 'Gas' 1911 hh.PutUint64(t.Gas) 1912 1913 // Field (4) 'FeePerGas' 1914 if err = t.FeePerGas.HashTreeRootWith(hh); err != nil { 1915 return 1916 } 1917 1918 // Field (5) 'PriorityFeePerGas' 1919 if err = t.PriorityFeePerGas.HashTreeRootWith(hh); err != nil { 1920 return 1921 } 1922 1923 // Field (6) 'Value' 1924 if err = t.Value.HashTreeRootWith(hh); err != nil { 1925 return 1926 } 1927 1928 // Field (7) 'Data' 1929 { 1930 elemIndx := hh.Index() 1931 byteLen := uint64(len(t.Data)) 1932 if byteLen > 104857600 { 1933 err = ssz.ErrIncorrectListSize 1934 return 1935 } 1936 hh.PutBytes(t.Data) 1937 if ssz.EnableVectorizedHTR { 1938 hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (104857600+31)/32) 1939 } else { 1940 hh.MerkleizeWithMixin(elemIndx, byteLen, (104857600+31)/32) 1941 } 1942 } 1943 1944 // Field (8) 'Sign' 1945 { 1946 elemIndx := hh.Index() 1947 byteLen := uint64(len(t.Sign)) 1948 if byteLen > 104857600 { 1949 err = ssz.ErrIncorrectListSize 1950 return 1951 } 1952 hh.PutBytes(t.Sign) 1953 if ssz.EnableVectorizedHTR { 1954 hh.MerkleizeWithMixinVectorizedHTR(elemIndx, byteLen, (104857600+31)/32) 1955 } else { 1956 hh.MerkleizeWithMixin(elemIndx, byteLen, (104857600+31)/32) 1957 } 1958 } 1959 1960 // Field (9) 'To' 1961 if err = t.To.HashTreeRootWith(hh); err != nil { 1962 return 1963 } 1964 1965 // Field (10) 'From' 1966 if err = t.From.HashTreeRootWith(hh); err != nil { 1967 return 1968 } 1969 1970 // Field (11) 'ChainID' 1971 hh.PutUint64(t.ChainID) 1972 1973 // Field (12) 'Hash' 1974 if err = t.Hash.HashTreeRootWith(hh); err != nil { 1975 return 1976 } 1977 1978 // Field (13) 'R' 1979 if err = t.R.HashTreeRootWith(hh); err != nil { 1980 return 1981 } 1982 1983 // Field (14) 'S' 1984 if err = t.S.HashTreeRootWith(hh); err != nil { 1985 return 1986 } 1987 1988 // Field (15) 'V' 1989 if err = t.V.HashTreeRootWith(hh); err != nil { 1990 return 1991 } 1992 1993 if ssz.EnableVectorizedHTR { 1994 hh.MerkleizeVectorizedHTR(indx) 1995 } else { 1996 hh.Merkleize(indx) 1997 } 1998 return 1999 }