Skip to content

Commit

Permalink
Patch 0.14.5
Browse files Browse the repository at this point in the history
Fix some bugs
  • Loading branch information
nguyenphuminh authored Jul 25, 2022
1 parent 0964192 commit a59f810
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/core/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class Block {

balances[transaction.sender] = senderBalance - transaction.amount - transaction.gas - (transaction.additionalData.contractGas || 0);
} else {
balances[transaction.sender] -= transaction.amount + transaction.gas;
balances[transaction.sender] -= transaction.amount + transaction.gas + (transaction.additionalData.contractGas || 0);
}
gas += transaction.gas += (transaction.additionalData.contractGas || 0);
gas += transaction.gas + (transaction.additionalData.contractGas || 0);
} else {
reward = transaction.amount;
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/txPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ async function addTransaction(transaction, txPool, stateDB) {
// Fetch sender's state object
const dataFromSender = await stateDB.get(transaction.sender);
// Get sender's balance
let balance = dataFromSender.balance - transaction.amount - transaction.gas;
let balance = dataFromSender.balance - transaction.amount - transaction.gas - (transaction.additionalData.contractGas || 0);

txPool.forEach(tx => {
if (tx.sender === transaction.sender) {
balance -= tx.amount + tx.gas;
balance -= tx.amount + tx.gas + (tx.additionalData.contractGas || 0);
}
});

Expand All @@ -29,6 +29,8 @@ async function addTransaction(transaction, txPool, stateDB) {
) {
txPool.push(transaction);
}

console.log("LOG :: Sent one transaction, added transaction to pool.");
}

module.exports = addTransaction;
4 changes: 1 addition & 3 deletions src/node/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async function startServer(options) {

chainInfo.transactionPool.push(transaction);
// Broadcast the transaction
sendTransaction(transaction);
sendMessage(produceMessage("TYPE_CREATE_TRANSACTION", transaction), opened);
}

break;
Expand Down Expand Up @@ -419,8 +419,6 @@ async function sendTransaction(transaction) {
sendMessage(produceMessage("TYPE_CREATE_TRANSACTION", transaction), opened);

await addTransaction(transaction, chainInfo.transactionPool, stateDB);

console.log("LOG :: Sent one transaction, added transaction to pool.");
}

function mine(publicKey, ENABLE_LOGGING) {
Expand Down

0 comments on commit a59f810

Please sign in to comment.