눈 정화용 짤방
https://github.com/tensor-programming/Rust_block_chain
https://www.youtube.com/watch?v=U8GGZ4TqlQs&t=894s
main.rs
The write method will attempt to write some data into the object, returning how many bytes were successfully written.
완벽한 트렌잭션을 보장하지 않음. 도중 에러 시, 작업 중단이고, 버퍼의 크기 보다 같거나 작음. // Ok(n)
ErrorKind::Interrupted
The flush method is useful for adapters and explicit buffers themselves for ensuring that all buffered data has been pushed out to the ‘true sink’.
use std::{fs::File, io::Write};
fn main() -> std::io::Result<()>{
let mut buf= File::create("foo.TXT")?;
buf.write(b" Some bytes")?;
buf.flush()?;
Ok(())
}
let mut miner_addr = String::new();
let mut difficulty = String::new();
let mut choice = String::new();
let mut chain = blockchain::Chain::new(miner_addr.trim().to_string(), diff);
// 0
process::exit(0);
blockchain.rs
https://github.com/tensor-programming/Rust_block_chain/blob/master/src/blockchain.rs