Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3411 fix getblocktemplate request #3580

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import json
import logging
import random
import time
Expand Down Expand Up @@ -49,7 +50,11 @@ def _build_headers():
password = "bitcoin-password"
auth = base64.encodebytes((user + ":" + password).encode()).decode().strip()

return {"Authorization": f"Basic {auth}"}
return {
"Accept-Encoding": "identity",
"Authorization": f"Basic {auth}",
"Content-Type": "application/x-www-form-urlencoded",
}

def start(self):
logger.info("Starting Bitcoin mining network traffic simulator")
Expand All @@ -59,15 +64,17 @@ def start(self):
def send_bitcoin_mining_request(self):
url = f"http://{self._island_server_address}/"
failure_warning_msg = f"Failed to establish a connection with {url}"
body = BitcoinMiningNetworkTrafficSimulator._build_getblocktemplate_request_body()
body = json.dumps(
BitcoinMiningNetworkTrafficSimulator._build_getblocktemplate_request_body()
).encode()

logger.info(f"Sending Bitcoin mining request to {url}")

timestamp = time.time()
try:
requests.post(
url,
json=body,
data=body,
headers=self._headers,
timeout=MEDIUM_REQUEST_TIMEOUT,
)
Expand Down