Skip to content
Snippets Groups Projects
Commit 736f5174 authored by zhihua0322's avatar zhihua0322
Browse files

ready for demo

parent 584b596d
Branches master
No related tags found
No related merge requests found
......@@ -68,7 +68,7 @@ impl Blockchain {
let old_sender_value = new_state.get_value(sender);
let old_recipient_value = new_state.get_value(recipient);
let old_recipient_nonce = new_state.get_nonce(recipient);
println!("value is {}, account_nonce is {}", value, account_nonce);
// println!("value is {}, account_nonce is {}", value, account_nonce);
new_state.put_entry(sender, (account_nonce, old_sender_value - value));
new_state.put_entry(recipient, (old_recipient_nonce, old_recipient_value + value));
}
......@@ -86,13 +86,13 @@ impl Blockchain {
let sender = t.get_sender();
// let recipient = t.get_recipient();
let value = t.get_value();
let account_nonce = t.get_nonce();
// let account_nonce = t.get_nonce();
let old_sender_value = parent_state.get_value(sender);
// let old_recipient_value = parent_state.get_value(recipient);
let old_sender_nonce = parent_state.get_nonce(sender);
// let old_sender_nonce = parent_state.get_nonce(sender);
// let old_recipient_nonce = parent_state.get_nonce(recipient);
if !verify_withbytes(&t, pub_key, signature_bytes) || old_sender_value < value || old_sender_nonce != account_nonce - 1 {
if !verify_withbytes(&t, pub_key, signature_bytes) || old_sender_value < value {
// if !verify_withbytes(&t, pub_key, signature_bytes) {
is_valid = false;
break;
......
......@@ -56,7 +56,7 @@ impl Generator {
// println!("index is {}", index);
let signed_t = generate_transaction(&self.self_key, self.address, nonce, *recipients.get(index as usize).unwrap());
mempool.add(&signed_t);
println!("size of mempool is {}", mempool.len());
// println!("size of mempool is {}", mempool.len());
let mut transaction_vec = Vec::new();
transaction_vec.push(signed_t.hash());
let msg: Message = Message::NewTransactionHashes(transaction_vec);
......
......@@ -152,13 +152,13 @@ impl Context {
debug!("Pong: {}", nonce);
}
Message::Address(account) => {
println!("receive Addr");
// println!("receive Addr");
let mut blockchain = self.mut_blockchain.lock().unwrap();
let tip = blockchain.tip();
let old_state = blockchain.get_state(tip);
let mut new_state = old_state.clone();
new_state.put_entry(account, (0, 10000));
println!("current length of state is {}", new_state.get_len());
// println!("current length of state is {}", new_state.get_len());
blockchain.put_state(tip, new_state);
}
Message::NewBlockHashes(block_hash) => {
......@@ -194,7 +194,7 @@ impl Context {
// println!("receive getBlocks");
let blockchain = self.mut_blockchain.lock().unwrap();
let blocks = blockchain.get_block(not_exist_hash);
println!("not_exist_hash {}", blocks.len());
// println!("not_exist_hash {}", blocks.len());
if blocks.len() > 0 {
peer.write(Message::Blocks(blocks));
}
......@@ -206,7 +206,7 @@ impl Context {
// thread::spawn(move || {
// println!("receive Blocks");
let mut blockchain = self.mut_blockchain.lock().unwrap();
println!("blocks size {}", blocks.len());
// println!("blocks size {}", blocks.len());
let mut new_hash:Vec<H256> = Vec::new();
let mut not_exist_hash:Vec<H256> = Vec::new();
for block in blocks {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment