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

chain/state: use tendermint-rs consensus::State serializers #232

Merged
Merged
Show file tree
Hide file tree
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
23 changes: 10 additions & 13 deletions src/chain/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
//!
//! Double-signing protection is the primary purpose of this code (for now).

mod encoding;
mod error;
pub mod hook;

pub use self::error::{StateError, StateErrorKind};

use self::encoding::EncodedState;
use crate::{
error::{Error, ErrorKind::*},
prelude::*,
Expand All @@ -36,18 +34,17 @@ impl State {
{
match fs::read_to_string(path.as_ref()) {
Ok(state_json) => {
let consensus_state: EncodedState =
serde_json::from_str(&state_json).map_err(|e| {
format_err!(
ParseError,
"error parsing {}: {}",
path.as_ref().display(),
e
)
})?;
let consensus_state = serde_json::from_str(&state_json).map_err(|e| {
format_err!(
ParseError,
"error parsing {}: {}",
path.as_ref().display(),
e
)
})?;

Ok(Self {
consensus_state: consensus_state.into(),
consensus_state,
state_file_path: path.as_ref().to_owned(),
})
}
Expand Down Expand Up @@ -189,7 +186,7 @@ impl State {
&self.consensus_state
);

let json = serde_json::to_string(&EncodedState::from(self.consensus_state.clone()))?;
let json = serde_json::to_string(&self.consensus_state)?;

let state_file_dir = self.state_file_path.parent().unwrap_or_else(|| {
panic!("state file cannot be root directory");
Expand Down
50 changes: 0 additions & 50 deletions src/chain/state/encoding.rs

This file was deleted.