Skip to content

Instantly share code, notes, and snippets.

// 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;
// MARK - Source of Truth
class SourceOfTruth: ObservableObject {
@Published private(set) var value: Int = 0
func increase() { value += 1 }
func decrease() { value -= 1 }
}
// MARK - View
@yvetterowe
yvetterowe / ValidateBTCTransaction.swift
Last active May 2, 2020 17:50
Toy BTC transaction verification
// MARK: - Primitives
typealias Address = String
typealias Signature = String
typealias Coins = String
// MARK: - Transaction
enum Transaction {
case coinbase(id: ID, outputs: [Output])
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.