Skip to content

Instantly share code, notes, and snippets.

Avatar
🥟

John Newbery jnewbery

🥟
View GitHub Profile
View pubkey.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGIbpwgBEAC9s2c6g9jAMvOM3mrBoKm0cCQPxjSvXGuic3MhJn9S1jentZJI
X3jeEku3Q42YUu7pXUUxAZuTYUHV56N/lfaFJ+Pf5nUckAE1afrpzOwHBgCvhE+g
IbPstp/8M+MQWTKo7V10UZE/c3F+wPPE2DcBYem8pYcnbx4JZhKXTbHenU3sQKwD
/uckcpZi9EYNAj3+K3h2KbjYVnxSdRaq7PJ8QtAv2eM2HM3BJUK/oy1imrEdeSle
gkNSFdXZ978zdGHS3XZ0jaPKxfEq4UIRkW+FxDnrwV5EOay8LqbQzg+ASgo8xFPY
D13YSrMRSIa4C3drL5pwpr8ACWL250/DbwYbYoG6CTOzoGGnnXXEP/uYjdv84Bux
jzfHf6dg5gox/+918hGMMBIzFwD0umf1GVhQTNkEzJ6ydxGoKb2vOcrtogupZlgy
KE3sIgajD6Wu0SsJSFUZgejd0nAEpjH7WtAHFmUqHHcz6fDLrp69XOTQVN54Y0iS
@jnewbery
jnewbery / duplicates.cpp
Created Mar 13, 2021
Simulate the number of expected number of duplicate nonces in the Bitcoin block chain
View duplicates.cpp
#include <algorithm>
#include <iostream>
#include <random>
constexpr uint16_t REPEATS{100};
constexpr uint32_t BLOCK_HEIGHT{674293};
uint16_t run(int seed)
{
std::seed_seq seq{seed};
@jnewbery
jnewbery / shared_ptr.cpp
Created Apr 18, 2020
Passing shared pointers
View shared_ptr.cpp
#include <iostream>
#include <memory>
struct Base
{
Base() { std::cout << " Base::Base()\n"; }
~Base() { std::cout << " Base::~Base()\n"; }
};
struct TraceByVal
@jnewbery
jnewbery / labitcoin_schnorr_notes.md
Last active Jul 8, 2020
Labitconf schnorr/taproot presentation links and notes
@jnewbery
jnewbery / tx_relay_peer_prioritization.md
Last active Jul 17, 2019
P2P peer prioritization logic for tx relay
View tx_relay_peer_prioritization.md

Scenario

Bitcoin nodes relay txs to each other over the P2P network. If a node receives a valid tx from a peer, it adds it to the mempool and relays it to its other peers. If it receives an invalid tx from a peer, it must decide what action to take. We distinguish three cases:

  1. a transaction which is valid according to consensus rules, but invalid according to the node's policy rules.
  2. a transaction which is valid according to long-established consensus rules,
View git-br.py
#!/usr/bin/env python3
import subprocess
import os
if os.name == 'posix':
RED = "\033[1;31m"
BLUE = "\033[0;34m"
CYAN = "\033[0;36m"
GREEN = "\033[0;32m"
RESET = "\033[0;0m"