Example #1
0
 int CarryBlockMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_vint32(expire_blocks_);
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_vint32(remove_blocks_);
   }
   if (common::TFS_SUCCESS == ret)
   {
     ret = input.get_vint32(new_blocks_);
   }
   return ret;
 }
Example #2
0
 int RespHeartMessage::deserialize(common::Stream& input)
 {
   int32_t iret = input.get_int32(&status_);
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_int32(&heart_interval_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_vint32(expire_blocks_);
   }
   if (common::TFS_SUCCESS == iret)
   {
     iret = input.get_vint32(new_blocks_);
   }
   return iret;
 }
Example #3
0
 int BatchGetBlockInfoMessage::deserialize(common::Stream& input)
 {
   int32_t ret = input.get_int32(&mode_);
   if (common::TFS_SUCCESS == ret)
   {
     if (mode_ & common::T_READ)
     {
       ret = input.get_vint32(block_ids_);
     }
     else
     {
       ret = input.get_int32(&block_count_);
     }
   }
   return ret;
 }
Example #4
0
    int RespListBlockMessage::deserialize(common::Stream& input)
    {
      int32_t ret = input.get_int32(&status_type_);
      if (common::TFS_SUCCESS == ret)
      {
        need_free_ = 1;
        if (status_type_ & common::LB_BLOCK)//blocks
        {
          ret = input.get_vint64(blocks_);
        }

        if (common::TFS_SUCCESS == ret
          && status_type_ & common::LB_PAIRS)//pairs
        {
          int32_t size = 0;
          ret = input.get_int32(&size);
          if (common::TFS_SUCCESS == ret)
          {
            std::vector<int32_t> tmp;
            uint64_t block_id = 0;
            for (int32_t i = 0; i < size; ++i)
            {
              ret = input.get_int64(reinterpret_cast<int64_t*> (&block_id));
              if (common::TFS_SUCCESS == ret)
              {
                tmp.clear();
                ret = input.get_vint32(tmp);
                if (common::TFS_SUCCESS == ret)
                {
                  block_pairs_.insert(std::map<uint64_t, std::vector<int32_t> >::value_type(block_id, tmp));
                }
                else
                {
                  break;
                }
              }
              else
              {
                break;
              }
            }
          }
        }

        if (common::TFS_SUCCESS == ret
          && status_type_ & common::LB_INFOS)
        {
          int32_t size = 0;
          ret = input.get_int32(&size);
          if (common::TFS_SUCCESS == ret)
          {
            int64_t pos = 0;
            common::BlockInfoV2 info;
            for (int32_t i = 0; i < size; ++i)
            {
              pos = 0;
              ret = info.deserialize(input.get_data(), input.get_data_length(), pos);
              if (common::TFS_SUCCESS == ret)
              {
                input.drain(info.length());
                block_infos_.push_back(info);
              }
              else
              {
                break;
              }
            }
          }
        }
      }
      return ret;
    }
Example #5
0
 int NewBlockMessage::deserialize(common::Stream& input)
 {
   return input.get_vint32(new_blocks_);
 }