Skip to content

Commit

Permalink
Update block.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 21, 2024
1 parent 5012ae2 commit 6fe3b4a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions core/sidra-chain/block.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { Transaction } from './transaction';

class Block {
constructor(transactions, previousBlockHash) {
constructor(index, previousHash, transactions, timestamp) {
this.index = index;
this.previousHash = previousHash;
this.transactions = transactions;
this.previousBlockHash = previousBlockHash;
this.timestamp = timestamp;
this.hash = this.calculateHash();
}

calculateHash() {
// Calculate the block's hash using a cryptographic algorithm
}

validate() {
// Validate the block and ensure it meets the protocol's requirements
validateTransactions() {
// Validate each transaction in the block
}

process() {
// Process the block and update the chain state
addTransaction(transaction) {
// Add a new transaction to the block
}
}

Expand Down

0 comments on commit 6fe3b4a

Please sign in to comment.