pub fn parse_log(&self, log: RawLog) -> Result<Log> {
		let topics = log.topics;
		let data = log.data;
		let topics_len = topics.len();
		// obtains all params info
		let topic_params = self.indexed_params(true);
		let data_params = self.indexed_params(false);
		// then take first topic if event is not anonymous
		let to_skip = if self.anonymous {
			0
		} else {
			// verify
			let event_signature = topics.get(0).ok_or(ErrorKind::InvalidData)?;
			if event_signature != &self.signature() {
				return Err(ErrorKind::InvalidData.into());
			}
			1
		};

		let topic_types = topic_params.iter()
			.map(|p| p.kind.clone())
			.collect::<Vec<ParamType>>();

		let flat_topics = topics.into_iter()
			.skip(to_skip)
			.flat_map(|t| t.as_ref().to_vec())
			.collect::<Vec<u8>>();

		let topic_tokens = try!(decode(&topic_types, &flat_topics));

		// topic may be only a 32 bytes encoded token
		if topic_tokens.len() != topics_len - to_skip {
			return Err(ErrorKind::InvalidData.into());
		}

		let topics_named_tokens = topic_params.into_iter()
			.map(|p| p.name)
			.zip(topic_tokens.into_iter());

		let data_types = data_params.iter()
			.map(|p| p.kind.clone())
			.collect::<Vec<ParamType>>();

		let data_tokens = try!(decode(&data_types, &data));

		let data_named_tokens = data_params.into_iter()
			.map(|p| p.name)
			.zip(data_tokens.into_iter());

		let named_tokens = topics_named_tokens
			.chain(data_named_tokens)
			.collect::<HashMap<String, Token>>();

		let decoded_params = self.params_names()
			.into_iter()
			.map(|name| LogParam {
				name: name.clone(),
				value: named_tokens[&name].clone()
			})
			.collect();

		let result = Log {
			params: decoded_params,
		};

		Ok(result)
	}
/// Parses `RawLog` and retrieves all log params from it.
Parses `RawLog` and retrieves all log params from it.
Parses ` RawLog ` and retrieves all log params from it .
pub fn parse_log(&self, log: RawLog) -> Result<Log> {
		let topics = log.topics;
		let data = log.data;
		let topics_len = topics.len();
		// obtains all params info
		let topic_params = self.indexed_params(true);
		let data_params = self.indexed_params(false);
		// then take first topic if event is not anonymous
		let to_skip = if self.anonymous {
			0
		} else {
			// verify
			let event_signature = topics.get(0).ok_or(ErrorKind::InvalidData)?;
			if event_signature != &self.signature() {
				return Err(ErrorKind::InvalidData.into());
			}
			1
		};
		let topic_types = topic_params.iter()
			.map(|p| p.kind.clone())
			.collect::<Vec<ParamType>>();
		let flat_topics = topics.into_iter()
			.skip(to_skip)
			.flat_map(|t| t.as_ref().to_vec())
			.collect::<Vec<u8>>();
		let topic_tokens = try!(decode(&topic_types, &flat_topics));
		// topic may be only a 32 bytes encoded token
		if topic_tokens.len() != topics_len - to_skip {
			return Err(ErrorKind::InvalidData.into());
		}
		let topics_named_tokens = topic_params.into_iter()
			.map(|p| p.name)
			.zip(topic_tokens.into_iter());
		let data_types = data_params.iter()
			.map(|p| p.kind.clone())
			.collect::<Vec<ParamType>>();
		let data_tokens = try!(decode(&data_types, &data));
		let data_named_tokens = data_params.into_iter()
			.map(|p| p.name)
			.zip(data_tokens.into_iter());
		let named_tokens = topics_named_tokens
			.chain(data_named_tokens)
			.collect::<HashMap<String, Token>>();
		let decoded_params = self.params_names()
			.into_iter()
			.map(|name| LogParam {
				name: name.clone(),
				value: named_tokens[&name].clone()
			})
			.collect();
		let result = Log {
			params: decoded_params,
		};
		Ok(result)
	}
pub fn parse_log ( & self , log : RawLog ) -> Result < Log > { let topics = log . topics ; let data = log . data ; let topics_len = topics . len ( ) ; // obtains all params info let topic_params = self . indexed_params ( true ) ; let data_params = self . indexed_params ( false ) ; // then take first topic if event is not anonymous let to_skip = if self . anonymous { 0 } else { // verify let event_signature = topics . get ( 0 ) . ok_or ( ErrorKind :: InvalidData ) ? ; if event_signature != & self . signature ( ) { return Err ( ErrorKind :: InvalidData . into ( ) ) ; } 1 } ; let topic_types = topic_params . iter ( ) . map ( | p | p . kind . clone ( ) ) . collect :: < Vec < ParamType > > ( ) ; let flat_topics = topics . into_iter ( ) . skip ( to_skip ) . flat_map ( | t | t . as_ref ( ) . to_vec ( ) ) . collect :: < Vec < u8 > > ( ) ; let topic_tokens = try ! ( decode ( topic_types flat_topics ) ) ; // topic may be only a 32 bytes encoded token if topic_tokens . len ( ) != topics_len - to_skip { return Err ( ErrorKind :: InvalidData . into ( ) ) ; } let topics_named_tokens = topic_params . into_iter ( ) . map ( | p | p . name ) . zip ( topic_tokens . into_iter ( ) ) ; let data_types = data_params . iter ( ) . map ( | p | p . kind . clone ( ) ) . collect :: < Vec < ParamType > > ( ) ; let data_tokens = try ! ( decode ( data_types data ) ) ; let data_named_tokens = data_params . into_iter ( ) . map ( | p | p . name ) . zip ( data_tokens . into_iter ( ) ) ; let named_tokens = topics_named_tokens . chain ( data_named_tokens ) . collect :: < HashMap < String , Token > > ( ) ; let decoded_params = self . params_names ( ) . into_iter ( ) . map ( | name | LogParam { name : name . clone ( ) , value : named_tokens [ & name ] . clone ( ) } ) . collect ( ) ; let result = Log { params : decoded_params , } ; Ok ( result ) }
Parses `RawLog` and retrieves all log params from it.
Parses ` RawLog ` and retrieves all log params from it .
&self
log
RawLog
&self
log
RawLog