Backport commits to beta (#1763)
* Don't try to sync to ancient blocks * Parallel block body download * Fixed reading chunked EIP8 handshake (#1712) * Fixed reading chunked EIP8 handshake * Added missing break * Disconnect peers on a fork * Updated json-ipc-server * Combine mining queue and enabled into single locked datum (#1749) * Combine mining queue and enabled into single locked datum Additional tracing. * Fix bug uncovered by test. * Fix typo * Remove unneeded log initialisation in test. * fix failing test (#1756) * Fixed test * Suicides tracing (#1688) * tracing suicide * fixed #1635 * fixed typo * Stackoverflow #1686 (#1698) * flat trace serialization * tracing finds transaction which creates contract * flatten traces before inserting them to the db * Trace other types of calls (#1727) * Trace through DELEGATECALL and CALLCODE Add them to the JSON output and RLP database store. * Fix tests. * Fix all tests. * Fix one more test. * filtering transactions toAddress includes contract creation (#1697) * tracing finds transaction which creates contract * comma cleanup Remove when following `}`s, add to final entries. * Various improvements to tracing & diagnostics. (#1707) * Various improvements to tracing & diagnostics. - Manage possibility of `Account` not having code for `PodAccount` - New RPC: `trace_sendRawTransaction` - See raw transaction dump when inspecting over RPC * Fix test * Remove one of the dupe error messages * Remove unneeded `&`s * Reformat and extremely minor optimisation * Minor optimisation * Remove unneeded let * Fix tests. * Additional fix. * Minor rename. * Bowing to the pressure. * Stackoverflow fix (#1742) * executive tracer builds flat traces without intermediate struct * temporarilt commented out tests for traces * fixed new way of building trace address * fixed new way of building trace address * updating state tests with flat tracing in progress * fixed flat tracing tests * fixed compiling ethcore-rpc with new flat traces * removed warnings from ethcore module * remove unused data structures
This commit is contained in:
committed by
Gav Wood
parent
429c83f92f
commit
8017daf47c
@@ -139,6 +139,74 @@ impl<R: BinaryConvertable, E: BinaryConvertable> BinaryConvertable for Result<R,
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> BinaryConvertable for VecDeque<T> where T: BinaryConvertable {
|
||||
fn size(&self) -> usize {
|
||||
match T::len_params() {
|
||||
0 => mem::size_of::<T>() * self.len(),
|
||||
_ => self.iter().fold(0usize, |acc, t| acc + t.size()),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_bytes(&self, buffer: &mut [u8], length_stack: &mut VecDeque<usize>) -> Result<(), BinaryConvertError> {
|
||||
let mut offset = 0usize;
|
||||
for item in self.iter() {
|
||||
let next_size = match T::len_params() {
|
||||
0 => mem::size_of::<T>(),
|
||||
_ => { let size = item.size(); length_stack.push_back(size); size },
|
||||
};
|
||||
if next_size > 0 {
|
||||
let item_end = offset + next_size;
|
||||
try!(item.to_bytes(&mut buffer[offset..item_end], length_stack));
|
||||
offset = item_end;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn from_bytes(buffer: &[u8], length_stack: &mut VecDeque<usize>) -> Result<Self, BinaryConvertError> {
|
||||
let mut index = 0;
|
||||
let mut result = Self::with_capacity(
|
||||
match T::len_params() {
|
||||
0 => buffer.len() / mem::size_of::<T>(),
|
||||
_ => 128,
|
||||
});
|
||||
|
||||
if buffer.len() == 0 { return Ok(result); }
|
||||
|
||||
loop {
|
||||
let next_size = match T::len_params() {
|
||||
0 => mem::size_of::<T>(),
|
||||
_ => try!(length_stack.pop_front().ok_or(BinaryConvertError)),
|
||||
};
|
||||
let item = if next_size == 0 {
|
||||
try!(T::from_empty_bytes())
|
||||
}
|
||||
else {
|
||||
try!(T::from_bytes(&buffer[index..index+next_size], length_stack))
|
||||
};
|
||||
result.push_back(item);
|
||||
|
||||
index = index + next_size;
|
||||
if index == buffer.len() { break; }
|
||||
if index + next_size > buffer.len() {
|
||||
return Err(BinaryConvertError)
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn from_empty_bytes() -> Result<Self, BinaryConvertError> {
|
||||
Ok(Self::new())
|
||||
}
|
||||
|
||||
fn len_params() -> usize {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
impl<T> BinaryConvertable for Vec<T> where T: BinaryConvertable {
|
||||
fn size(&self) -> usize {
|
||||
match T::len_params() {
|
||||
|
||||
Reference in New Issue
Block a user