fn build_pairs<Header, I>(
	cht_size: u64,
	cht_num: Header::Number,
	hashes: I
) -> ClientResult<Vec<(Vec<u8>, Vec<u8>)>>
	where
		Header: HeaderT,
		I: IntoIterator<Item=ClientResult<Option<Header::Hash>>>,
{
	let start_num = start_number(cht_size, cht_num);
	let mut pairs = Vec::new();
	let mut hash_number = start_num;
	for hash in hashes.into_iter().take(cht_size as usize) {
		let hash = hash?.ok_or_else(|| ClientError::from(
			ClientErrorKind::MissingHashRequiredForCHT(cht_num.as_(), hash_number.as_())
		))?;
		pairs.push((
			encode_cht_key(hash_number).to_vec(),
			encode_cht_value(hash)
		));
		hash_number += Header::Number::one();
	}

	if pairs.len() as u64 == cht_size {
		Ok(pairs)
	} else {
		Err(ClientErrorKind::MissingHashRequiredForCHT(cht_num.as_(), hash_number.as_()).into())
	}
}
/// Build pairs for computing CHT.
Build pairs for computing CHT.
Build pairs for computing CHT .
fn build_pairs<Header, I>(
	cht_size: u64,
	cht_num: Header::Number,
	hashes: I
) -> ClientResult<Vec<(Vec<u8>, Vec<u8>)>>
	where
		Header: HeaderT,
		I: IntoIterator<Item=ClientResult<Option<Header::Hash>>>,
{
	let start_num = start_number(cht_size, cht_num);
	let mut pairs = Vec::new();
	let mut hash_number = start_num;
	for hash in hashes.into_iter().take(cht_size as usize) {
		let hash = hash?.ok_or_else(|| ClientError::from(
			ClientErrorKind::MissingHashRequiredForCHT(cht_num.as_(), hash_number.as_())
		))?;
		pairs.push((
			encode_cht_key(hash_number).to_vec(),
			encode_cht_value(hash)
		));
		hash_number += Header::Number::one();
	}
	if pairs.len() as u64 == cht_size {
		Ok(pairs)
	} else {
		Err(ClientErrorKind::MissingHashRequiredForCHT(cht_num.as_(), hash_number.as_()).into())
	}
}
fn build_pairs < Header , I > ( cht_size : u64 , cht_num : Header :: Number , hashes : I ) -> ClientResult < Vec < ( Vec < u8 > , Vec < u8 > ) > > where Header : HeaderT , I : IntoIterator < Item = ClientResult < Option < Header :: Hash > > > , { let start_num = start_number ( cht_size , cht_num ) ; let mut pairs = Vec :: new ( ) ; let mut hash_number = start_num ; for hash in hashes . into_iter ( ) . take ( cht_size as usize ) { let hash = hash ? . ok_or_else ( | | ClientError :: from ( ClientErrorKind :: MissingHashRequiredForCHT ( cht_num . as_ ( ) , hash_number . as_ ( ) ) ) ) ? ; pairs . push ( ( encode_cht_key ( hash_number ) . to_vec ( ) , encode_cht_value ( hash ) ) ) ; hash_number += Header :: Number :: one ( ) ; } if pairs . len ( ) as u64 == cht_size { Ok ( pairs ) } else { Err ( ClientErrorKind :: MissingHashRequiredForCHT ( cht_num . as_ ( ) , hash_number . as_ ( ) ) . into ( ) ) } }
Build pairs for computing CHT.
Build pairs for computing CHT .
cht_size
u64
cht_num
Header::Number
hashes
I
cht_size
u64
cht_num
Header::Number
hashes
I