THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

stage20-concurrent-requests.py

TEXT FILE

883 B · Public source code for developers, search crawlers and AI agents

Download / RawBack to folder
Python · 23 lines
1from concurrent.futures import ThreadPoolExecutor
2from time import perf_counter_ns
3
4def run(read, expected, count=200, workers=8):
5    if count < 1 or workers < 1:
6        raise ValueError("invalid workload")
7    def check(i):
8        start = perf_counter_ns()
9        try:
10            valid = read(i) == expected
11        except Exception:
12            valid = False
13        return valid, perf_counter_ns()-start
14    with ThreadPoolExecutor(max_workers=workers) as pool:
15        results = list(pool.map(check, range(count)))
16    return {"requests": count, "mismatches": sum(not ok for ok, _ in results),
17            "max_ns": max(t for _, t in results)}
18
19if __name__ == "__main__":
20    snapshot = ("test", 12000)
21    assert run(lambda _: snapshot, snapshot)["mismatches"] == 0
22    assert run(lambda _: None, snapshot)["mismatches"] == 200
23    print(run(lambda _: snapshot, snapshot))
Read-only source · Select a line number to link directly · Raw download above

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects