new Blockchain()
This class is the representation of 'blockchain'
Blockchain class stores and manages all blocks and transactions
Its the most important aspect of blockchain network
- Source:
Members
listOfId
Returns id list of all blocks in blockchain
- Source:
Methods
(static) createGenesisBlock() → {Block}
This function creates the genesis block
- Source:
Returns:
- Type
- Block
addTransaction(transaction)
This function checks and add transaction to an array
Parameters:
Name | Type | Description |
---|---|---|
transaction |
Transaction to add |
- Source:
calculateSignature() → {hash}
This function return unique SHA256 signature of current block
- Source:
Returns:
- Type
- hash
checkChain() → {boolean}
This function check the validity of the blockchain.
It check if all the blocks are valid and also checks their transaction
- Source:
Returns:
- Type
- boolean
getBalanceOfAddress(address) → {number}
It returns the balacne of given wallet
Parameters:
Name | Type | Description |
---|---|---|
address |
Wallet addres |
- Source:
Returns:
Amount of coins in wallet
- Type
- number
getBlock(index) → {Block}
Returns with given index
Parameters:
Name | Type | Description |
---|---|---|
index |
- Source:
Returns:
- Type
- Block
insertReceivedBlock(index, blockInfo)
Parameters:
Name | Type | Description |
---|---|---|
index |
||
blockInfo |
- Source:
mineBlock(block)
This functions add block to an array
Parameters:
Name | Type | Description |
---|---|---|
block |
- Source:
mineCurrentTransactions(rewardAddress)
This function is my implementation of 'mining'.
It takes the currentTransactions and 'mine it' using prof.js utility
Parameters:
Name | Type | Description |
---|---|---|
rewardAddress |
Wallet address of lucky receiver |
- Source: