This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Block Chain should maintain only limited block nodes to satisfy the functions | |
// You should not have all the blocks added to the block chain in memory | |
// as it would cause a memory overflow. | |
import java.sql.Array; | |
import java.util.*; | |
import java.util.stream.Collectors; | |
import java.sql.Timestamp; | |
public class BlockChain { | |
public static final int CUT_OFF_AGE = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK - Source of Truth | |
class SourceOfTruth: ObservableObject { | |
@Published private(set) var value: Int = 0 | |
func increase() { value += 1 } | |
func decrease() { value -= 1 } | |
} | |
// MARK - View |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Primitives | |
typealias Address = String | |
typealias Signature = String | |
typealias Coins = String | |
// MARK: - Transaction | |
enum Transaction { | |
case coinbase(id: ID, outputs: [Output]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
public class TxHandler { | |
private UTXOPool utxoPool; | |
/** | |
* Creates a public ledger whose current UTXOPool (collection of unspent transaction outputs) is | |
* {@code utxoPool}. This should make a copy of utxoPool by using the UTXOPool(UTXOPool uPool) | |
* constructor. |