rename try_to_finish -> note_appended

This commit is contained in:
debris 2015-11-30 11:29:30 +01:00
parent 94a5216513
commit 6ee5e1684b

View File

@ -559,7 +559,7 @@ impl RlpStream {
object.encode(&mut self.encoder); object.encode(&mut self.encoder);
// if list is finished, prepend the length // if list is finished, prepend the length
self.try_to_finish(1); self.note_appended(1);
// return chainable self // return chainable self
self self
@ -586,7 +586,7 @@ impl RlpStream {
0 => { 0 => {
// we may finish, if the appended list len is equal 0 // we may finish, if the appended list len is equal 0
self.encoder.bytes.push(0xc0u8); self.encoder.bytes.push(0xc0u8);
self.try_to_finish(1); self.note_appended(1);
} }
_ => self.unfinished_lists.push_back(ListInfo::new(position, len)), _ => self.unfinished_lists.push_back(ListInfo::new(position, len)),
} }
@ -613,7 +613,7 @@ impl RlpStream {
self.encoder.bytes.push(0x80); self.encoder.bytes.push(0x80);
// try to finish and prepend the length // try to finish and prepend the length
self.try_to_finish(1); self.note_appended(1);
// return chainable self // return chainable self
self self
@ -625,7 +625,7 @@ impl RlpStream {
self.encoder.bytes.extend(bytes); self.encoder.bytes.extend(bytes);
// try to finish and prepend the length // try to finish and prepend the length
self.try_to_finish(item_count); self.note_appended(item_count);
// return chainable self // return chainable self
self self
@ -652,7 +652,7 @@ impl RlpStream {
/// Streams out encoded bytes. /// Streams out encoded bytes.
/// ///
/// Returns an error if stream is not finished. /// panic! if stream is not finished.
pub fn out(self) -> Vec<u8> { pub fn out(self) -> Vec<u8> {
match self.is_finished() { match self.is_finished() {
true => self.encoder.out(), true => self.encoder.out(),
@ -660,8 +660,8 @@ impl RlpStream {
} }
} }
/// try to finish lists /// Try to finish lists
fn try_to_finish(&mut self, inserted_items: usize) -> () { fn note_appended(&mut self, inserted_items: usize) -> () {
let should_finish = match self.unfinished_lists.back_mut() { let should_finish = match self.unfinished_lists.back_mut() {
None => false, None => false,
Some(ref mut x) => { Some(ref mut x) => {
@ -677,7 +677,7 @@ impl RlpStream {
let x = self.unfinished_lists.pop_back().unwrap(); let x = self.unfinished_lists.pop_back().unwrap();
let len = self.encoder.bytes.len() - x.position; let len = self.encoder.bytes.len() - x.position;
self.encoder.insert_list_len_at_pos(len, x.position); self.encoder.insert_list_len_at_pos(len, x.position);
self.try_to_finish(1); self.note_appended(1);
} }
} }
} }