| 635 | } |
| 636 | |
| 637 | void serialize_node_to_buffer( |
| 638 | unsigned char *write_pos, unsigned bytes_to_append, Node const &node, |
| 639 | uint32_t const disk_size, unsigned const offset) |
| 640 | { |
| 641 | MONAD_ASSERT(disk_size > 0 && disk_size <= Node::max_disk_size); |
| 642 | if (offset < Node::disk_size_bytes) { // serialize node disk size |
| 643 | MONAD_ASSERT(bytes_to_append <= disk_size - offset); |
| 644 | unsigned const written = |
| 645 | std::min(bytes_to_append, Node::disk_size_bytes - offset); |
| 646 | memcpy(write_pos, (unsigned char *)&disk_size + offset, written); |
| 647 | bytes_to_append -= written; |
| 648 | write_pos += written; |
| 649 | } |
| 650 | |
| 651 | if (bytes_to_append) { // serialize node |
| 652 | unsigned const offset_within_node = offset >= Node::disk_size_bytes |
| 653 | ? offset - Node::disk_size_bytes |
| 654 | : 0; |
| 655 | memcpy( |
| 656 | write_pos, |
| 657 | (unsigned char *)&node + offset_within_node, |
| 658 | bytes_to_append); |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | int64_t calc_min_version(Node const &node) |
| 663 | { |
no test coverage detected