Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Add new line after writing block to hex file. (#10984)
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Nov 8, 2019
1 parent 1583e71 commit 4e76ccc
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 36 deletions.
36 changes: 19 additions & 17 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@

use std::cmp;
use std::collections::{HashSet, BTreeMap, VecDeque};
use std::io::{BufRead, BufReader};
use std::str::{FromStr, from_utf8};
use std::str::FromStr;
use std::str::from_utf8;
use std::convert::TryFrom;
use std::sync::atomic::{AtomicI64, AtomicBool, Ordering as AtomicOrdering};
use std::sync::atomic::{AtomicUsize, AtomicI64, AtomicBool, Ordering as AtomicOrdering};
use std::sync::{Arc, Weak};
use std::time::{Instant, Duration};
use std::io::{BufReader, BufRead};
use std::time::{Duration, Instant};

use blockchain::{BlockReceipts, BlockChain, BlockChainDB, BlockProvider, TreeRoute, ImportRoute, TransactionAddress, ExtrasInsert, BlockNumberKey};
use bytes::{Bytes, ToPretty};
use call_contract::{CallContract, RegistryInfo};
use ethcore_miner::pool::VerifiedTransaction;
use ethereum_types::{H256, H264, Address, U256};
use evm::Schedule;
use bytes::Bytes;
use bytes::ToPretty;
use error::Error;
use ethereum_types::{Address, H256, H264, U256};
use hash::keccak;
use io::IoChannel;
use call_contract::CallContract;
use ethcore_miner::pool::VerifiedTransaction;
use itertools::Itertools;
use journaldb;
use kvdb::{DBValue, KeyValueDB, DBTransaction};
use kvdb::{DBTransaction, DBValue, KeyValueDB};
use parking_lot::{Mutex, RwLock};
use rand::OsRng;
use rlp::PayloadInfo;
Expand All @@ -46,8 +46,8 @@ use types::filter::Filter;
use types::log_entry::LocalizedLogEntry;
use types::receipt::{Receipt, LocalizedReceipt};
use types::{BlockNumber, header::{Header, ExtendedHeader}};
use types::data_format::DataFormat;
use vm::{EnvInfo, LastHashes};
use types::data_format::DataFormat;

use block::{LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock};
use client::ancient_import::AncientVerifier;
Expand All @@ -56,7 +56,7 @@ use client::{
ReopenBlock, PrepareOpenBlock, ScheduleInfo, ImportSealedBlock,
BroadcastProposalBlock, ImportBlock, StateOrBlock, StateInfo, StateClient, Call,
AccountData, BlockChain as BlockChainTrait, BlockProducer, SealedBlockImporter,
ClientIoMessage, BlockChainReset, ImportExportBlocks,
ClientIoMessage, BlockChainReset, ImportExportBlocks
};
use client::{
BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient,
Expand Down Expand Up @@ -85,7 +85,9 @@ use verification::queue::kind::blocks::Unverified;
use verification::{PreverifiedBlock, Verifier, BlockQueue};
use verification;
use ansi_term::Colour;

use call_contract::RegistryInfo;
use io::IoChannel;
use vm::Schedule;
// re-export
pub use types::blockchain_info::BlockChainInfo;
pub use types::block_status::BlockStatus;
Expand Down Expand Up @@ -2634,9 +2636,9 @@ impl ImportExportBlocks for Client {
let number = block.header.number();
while self.queue_info().is_full() { std::thread::sleep(Duration::from_secs(1)); }
match self.import_block(block) {
Err(EthcoreError(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
Err(Error(EthcoreErrorKind::Import(ImportErrorKind::AlreadyInChain), _)) => {
trace!("Skipping block #{}: already in chain.", number);
},
}
Err(e) => {
return Err(format!("Cannot import block #{}: {:?}", number, e));
},
Expand Down
20 changes: 10 additions & 10 deletions ethcore/src/client/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,17 +481,17 @@ pub trait BlockChainReset {

/// Provides a method for importing/exporting blocks
pub trait ImportExportBlocks {
/// Export blocks to destination, with the given from, to and format argument.
/// destination could be a file or stdout.
/// If the format is hex, each block is written on a new line.
/// For binary exports, all block data is written to the same line.
/// Export blocks to destination, with the given from, to and format argument.
/// destination could be a file or stdout.
/// If the format is hex, each block is written on a new line.
/// For binary exports, all block data is written to the same line.
fn export_blocks<'a>(
&self,
destination: Box<dyn std::io::Write + 'a>,
from: BlockId,
to: BlockId,
format: Option<DataFormat>
) -> Result<(), String>;
&self,
destination: Box<dyn std::io::Write + 'a>,
from: BlockId,
to: BlockId,
format: Option<DataFormat>
) -> Result<(), String>;

/// Import blocks from destination, with the given format argument
/// Source could be a file or stdout.
Expand Down
22 changes: 15 additions & 7 deletions ethcore/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ use ethkey::KeyPair;
use hash::keccak;
use io::IoChannel;
use tempdir::TempDir;
use types::transaction::{PendingTransaction, Transaction, Action, Condition};
use types::filter::Filter;
use types::view;
use types::views::BlockView;
use types::data_format::DataFormat;
use client::{BlockChainClient, BlockChainReset, Client, ClientConfig, BlockId, ChainInfo, BlockInfo, PrepareOpenBlock, ImportSealedBlock, ImportBlock, ImportExportBlocks};
use types::{
data_format::DataFormat,
ids::BlockId,
transaction::{PendingTransaction, Transaction, Action, Condition},
filter::Filter,
view,
views::BlockView,
};
use verification::queue::kind::blocks::Unverified;
use client::{Client, ClientConfig, PrepareOpenBlock, ImportSealedBlock};
use client::traits::{
BlockInfo, BlockChainClient, BlockChainReset, ChainInfo,
ImportExportBlocks, ImportBlock
};
use spec;
use ethereum;
use executive::{Executive, TransactOptions};
use miner::{Miner, PendingOrdering, MinerService};
Expand All @@ -38,7 +47,6 @@ use test_helpers::{
generate_dummy_client, push_blocks_to_client, get_test_client_with_blocks, get_good_dummy_block_seq,
generate_dummy_client_with_data, get_good_dummy_block, get_bad_state_dummy_block
};
use verification::queue::kind::blocks::Unverified;
use rustc_hex::ToHex;

#[test]
Expand Down
4 changes: 2 additions & 2 deletions parity/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.

use std::str::{FromStr, from_utf8};
use std::str::from_utf8;
use std::{io, fs};
use std::io::{BufReader, BufRead};
use std::time::{Instant, Duration};
Expand All @@ -29,6 +29,7 @@ use rlp::PayloadInfo;
use ethcore::client::{
Mode, DatabaseCompactionProfile, VMType, Nonce, Balance, BlockChainClient, BlockId, BlockInfo, ImportBlock, BlockChainReset, ImportExportBlocks
};
use types::data_format::DataFormat;
use ethcore::error::{ImportErrorKind, ErrorKind as EthcoreErrorKind, Error as EthcoreError};
use ethcore::miner::Miner;
use ethcore::verification::queue::VerifierSettings;
Expand All @@ -43,7 +44,6 @@ use user_defaults::UserDefaults;
use ethcore_private_tx;
use db;
use ansi_term::Colour;
use types::data_format::DataFormat;

#[derive(Debug, PartialEq)]
pub enum BlockchainCmd {
Expand Down

0 comments on commit 4e76ccc

Please sign in to comment.