458 {
459 pair<branch_type,branch_type> result;
460 auto first_branch = (first == root->id) ? root :
get_block_impl(first);
462
463 SYS_ASSERT(first_branch, fork_db_block_not_found,
"block ${id} does not exist", (
"id", first));
464 SYS_ASSERT(second_branch, fork_db_block_not_found,
"block ${id} does not exist", (
"id", second));
465
466 while( first_branch->block_num > second_branch->block_num )
467 {
468 result.first.push_back(first_branch);
469 const auto& prev = first_branch->header.previous;
470 first_branch = (prev == root->id) ? root :
get_block_impl( prev );
471 SYS_ASSERT( first_branch, fork_db_block_not_found,
472 "block ${id} does not exist",
473 ("id", prev)
474 );
475 }
476
477 while( second_branch->block_num > first_branch->block_num )
478 {
479 result.second.push_back( second_branch );
480 const auto& prev = second_branch->header.previous;
481 second_branch = (prev == root->id) ? root :
get_block_impl( prev );
482 SYS_ASSERT( second_branch, fork_db_block_not_found,
483 "block ${id} does not exist",
484 ("id", prev)
485 );
486 }
487
488 if (first_branch->id == second_branch->id) return result;
489
490 while( first_branch->header.previous != second_branch->header.previous )
491 {
492 result.first.push_back(first_branch);
493 result.second.push_back(second_branch);
494 const auto &first_prev = first_branch->header.previous;
496 const auto &second_prev = second_branch->header.previous;
498 SYS_ASSERT( first_branch, fork_db_block_not_found,
499 "block ${id} does not exist",
500 ("id", first_prev)
501 );
502 SYS_ASSERT( second_branch, fork_db_block_not_found,
503 "block ${id} does not exist",
504 ("id", second_prev)
505 );
506 }
507
508 if( first_branch && second_branch )
509 {
510 result.first.push_back(first_branch);
511 result.second.push_back(second_branch);
512 }
513 return result;
514 }