Skip to content

Instantly share code, notes, and snippets.

@termslang
Last active March 26, 2019 09:27
Show Gist options
  • Save termslang/1b10ab43bf94733fc4102e0845dc48bb to your computer and use it in GitHub Desktop.
Save termslang/1b10ab43bf94733fc4102e0845dc48bb to your computer and use it in GitHub Desktop.
module Transaction = struct
type t = tx_signed
module KEY = struct
type t = tx_signed
let compare a b = String.compare a.data.sender b.data.sender
end
(* TODO move implementation here *)
let is_valid ~tx = false
let make ~sender ~receiver ~amount =
let nonce = (Address.Ledger.get sender).nonce in
let data = {sender; receiver; amount; nonce} in
(* TODO sign tx data *)
{signature = ""; data}
module Pool = struct
module TxSet = Set.Make (KEY)
let data = ref TxSet.empty
let add ~tx =
match is_valid ~tx with
| false -> ()
| true -> data := TxSet.add tx !data
let remove ~tx = data := TxSet.remove tx !data
let mem ~tx = TxSet.mem tx !data
let elements = TxSet.elements !data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment