mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 18:07:58 +00:00
import-blocks: Do not read stdin to memory (#11072)
* import-blocks: Do not read `stdin` to memory This fixes a bug with `import-blocks` reading the entire `stdin` before starting to import the blocks. However, for huge files that uses quite a lot of memory. We can just read from `stdin` step by step as we do it with a file. This ensures that we don't read the entire input at once into memory. * FMT * Fix warning
This commit is contained in:
@@ -72,13 +72,9 @@ impl ImportBlocksCmd {
|
||||
B: BlockT + for<'de> serde::Deserialize<'de>,
|
||||
IQ: sc_service::ImportQueue<B> + 'static,
|
||||
{
|
||||
let file: Box<dyn ReadPlusSeek + Send> = match &self.input {
|
||||
let file: Box<dyn Read + Send> = match &self.input {
|
||||
Some(filename) => Box::new(fs::File::open(filename)?),
|
||||
None => {
|
||||
let mut buffer = Vec::new();
|
||||
io::stdin().read_to_end(&mut buffer)?;
|
||||
Box::new(io::Cursor::new(buffer))
|
||||
},
|
||||
None => Box::new(io::stdin()),
|
||||
};
|
||||
|
||||
import_blocks(client, import_queue, file, false, self.binary)
|
||||
|
||||
Reference in New Issue
Block a user