mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-28 18:02:44 +02:00
refactor: move helper random_bytes
to util library
Can be easily reviewed with `--color-moved=dimmed-zebra`.
This commit is contained in:
@@ -12,6 +12,7 @@ import inspect
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import time
|
||||
import unittest
|
||||
@@ -286,6 +287,13 @@ def sha256sum_file(filename):
|
||||
d = f.read(4096)
|
||||
return h.digest()
|
||||
|
||||
|
||||
# TODO: Remove and use random.randbytes(n) instead, available in Python 3.9
|
||||
def random_bytes(n):
|
||||
"""Return a random bytes object of length n."""
|
||||
return bytes(random.getrandbits(8) for i in range(n))
|
||||
|
||||
|
||||
# RPC/P2P connection constants and functions
|
||||
############################################
|
||||
|
||||
|
Reference in New Issue
Block a user