Skip to content

Instantly share code, notes, and snippets.

View jnewbery's full-sized avatar
🥟

John Newbery jnewbery

🥟
View GitHub Profile
#!/usr/bin/env python3
"""Search for blocks where the BIP34 indicated coinbase height is > block height.
Uses Bitcoin Core's test framework."""
import time
from authproxy import AuthServiceProxy
from script import CScript
a = AuthServiceProxy("http://<user>:<password>@<ip>:<port>")
-----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 March 13, 2021 09:50
Simulate the number of expected number of duplicate nonces in the Bitcoin block chain
#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 / file_descriptors_bitcoin_core.md
Last active February 23, 2021 06:00
File Descriptors in Bitcoin Core

Overview

  • We use leveldb for multiple databases: block index, chainstate and (optionally) txindex. block index is very small, but chainstate and txindex can grow to many hundreds of files.
  • Each database has a limit on number of 'open files'. This limit includes both mmapped files (which ldb takes the fd for, opens and then closes, returning the fd) and files which ldb opens and holds the fd for. There's a default in the leveldb code here. This is the per-database max_open_files limit.
@jnewbery
jnewbery / BitcoinCoreReviewClub.md
Last active October 20, 2020 09:12
Bitcoin Core PR Review Club
@jnewbery
jnewbery / labitcoin_schnorr_notes.md
Last active July 8, 2020 19:02
Labitconf schnorr/taproot presentation links and notes
@jnewbery
jnewbery / shared_ptr.cpp
Created April 18, 2020 15:42
Passing shared pointers
#include <iostream>
#include <memory>
struct Base
{
Base() { std::cout << " Base::Base()\n"; }
~Base() { std::cout << " Base::~Base()\n"; }
};
struct TraceByVal