Code Review)Rust block-chain

DongSub_Joung·2022년 1월 19일
0

code review

목록 보기
2/2
post-thumbnail

눈 정화용 짤방

Reference

https://github.com/tensor-programming/Rust_block_chain
https://www.youtube.com/watch?v=U8GGZ4TqlQs&t=894s

main.rs

use) std::Write;

fn write(&mut self, buf: &[u8]) -> Result

  • The write method will attempt to write some data into the object, returning how many bytes were successfully written.

  • 완벽한 트렌잭션을 보장하지 않음. 도중 에러 시, 작업 중단이고, 버퍼의 크기 보다 같거나 작음. // Ok(n)

  • ErrorKind::Interrupted

fn flush(&mut self) -> Result<()>

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(())
}

inside

  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);

loop

match

// 0
 process::exit(0);

blockchain.rs

https://github.com/tensor-programming/Rust_block_chain/blob/master/src/blockchain.rs

0개의 댓글