Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pieces::Stack methods private. #1202

Merged
merged 1 commit into from
Jul 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions filecoin-proofs/src/pieces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,31 +142,31 @@ struct Stack(Vec<PieceInfo>);

impl Stack {
/// Creates a new stack.
pub fn new() -> Self {
fn new() -> Self {
Stack(Vec::new())
}

/// Pushes a single element onto the stack.
pub fn shift(&mut self, el: PieceInfo) {
fn shift(&mut self, el: PieceInfo) {
self.0.push(el)
}

/// Look at the last element of the stack.
pub fn peek(&self) -> &PieceInfo {
fn peek(&self) -> &PieceInfo {
&self.0[self.0.len() - 1]
}

/// Look at the second to last element of the stack.
pub fn peek2(&self) -> &PieceInfo {
fn peek2(&self) -> &PieceInfo {
&self.0[self.0.len() - 2]
}

/// Pop the last element of the stack.
pub fn pop(&mut self) -> Result<PieceInfo> {
fn pop(&mut self) -> Result<PieceInfo> {
self.0.pop().context("empty stack popped")
}

pub fn reduce1(&mut self) -> Result<bool> {
fn reduce1(&mut self) -> Result<bool> {
if self.len() < 2 {
return Ok(false);
}
Expand All @@ -182,17 +182,17 @@ impl Stack {
Ok(false)
}

pub fn reduce(&mut self) -> Result<()> {
fn reduce(&mut self) -> Result<()> {
while self.reduce1()? {}
Ok(())
}

pub fn shift_reduce(&mut self, piece: PieceInfo) -> Result<()> {
fn shift_reduce(&mut self, piece: PieceInfo) -> Result<()> {
self.shift(piece);
self.reduce()
}

pub fn len(&self) -> usize {
fn len(&self) -> usize {
self.0.len()
}
}
Expand Down