message: [accumulator] fix bug for find common ancestor
diff: use super::KeyPrefixName;
  use crate::memory_storage::MemoryStorage;
  use crate::storage::{CodecStorage, KeyCodec, Repository, ValueCodec};
  -use anyhow::{bail, Error, Result};
  +use anyhow::{bail, ensure, Error, Result};
  use byteorder::{BigEndian, ReadBytesExt};
  use crypto::hash::CryptoHash;
  use crypto::HashValue;
  @@ -208,33 +208,54 @@ impl BlockStore {
  block_id1: HashValue,
  block_id2: HashValue,
  ) -> Result<Option<HashValue>> {
  - let mut temp_block_id = block_id1;
  + let mut parent_id1 = block_id1;
  + let mut parent_id2 = block_id2;
  let mut found = false;
  + println!("block1: {}, block2: {}", block_id1, block_id2);
  loop {
  - println!("block_id: {}", temp_block_id.to_hex());
  + println!("block_id: {}", parent_id1.to_hex());
  //get header by block_id
  - match self.get_block_header_by_hash(temp_block_id)? {
  + match self.get_block_header_by_hash(parent_id1)? {
  Some(header) => {
  - temp_block_id = header.parent_hash();
  - match self.get_sons(temp_block_id) {
  - Ok(sons) => {
  - println!(" sons:{:?}", sons);
  - if sons.len() > 1 {
  - if sons.contains(&block_id2) {
  - //find ancestor
  + parent_id1 = header.parent_hash();
  + ensure!(parent_id1 != HashValue::zero(), "invaild block id is zero.");
  + match self.get_sons(parent_id1) {
  + Ok(sons1) => {
  + println!(" sons:{:?}", sons1);
  + if sons1.len() > 1 {
  + // get parent2 from block2
  + loop {
  + println!("parent2 : {}", parent_id2);
  + ensure!(
  + parent_id2 != HashValue::zero(),
  + "invaild block id is zero."
  + );
  + match self.get_block_header_by_hash(parent_id2)? {
  + Some(header2) => {
  + parent_id2 = header2.parent_hash();
  + if sons1.contains(&parent_id2) {
  found = true;
  break;
  }
  }
  + None => {
  + bail!("Error: can not find block2 {:?}", parent_id2)
  + }
  + }
  + }
  + if found {
  + break;
  + }
  + }
  }
  Err(err) => bail!("get sons Error: {:?}", err),
  }
  }
  - None => bail!("Error: can not find block {:?}", temp_block_id),
  + None => bail!("Error: can not find block {:?}", parent_id1),
  }
  }
  if found {
  - Ok(Some(temp_block_id))
  + Ok(Some(parent_id1))
  } else {
  bail!("not find common ancestor");
  Ok(None)
  