Skip to content

Conversation

@achow101
Copy link
Member

This PR adds the a datadir option to the linearize configuration file to allow linearize-hashes to look for and use the RPC cookie file in the datadir. It will still allow rpcuser and rpcpassword to be specified and those options will take precendence if both rpcuser/pass and datadir config options are set.

closes #10103

@jonasschnelli
Copy link
Contributor

Nice.
utACK 476c6d4c8dcf41f9e3accf5be1b84fdd4718046b

@laanwj
Copy link
Member

laanwj commented Mar 29, 2017

Makes sense, utACK

@laanwj
Copy link
Member

laanwj commented Mar 29, 2017

@pstratem can you confirm that this implements what you requested in #10103?

@maflcko
Copy link
Member

maflcko commented Mar 29, 2017

utACK 476c6d4

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open(os.path.join(os.path.expanduser(settings['datadir']), '/.cookie'), 'r')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@achow101 achow101 force-pushed the linearize-use-cookie branch from 476c6d4 to 2c4bbed Compare March 29, 2017 18:55
@pstratem
Copy link
Contributor

@achow101 need to import os.path

@pstratem
Copy link
Contributor

pstratem commented Mar 29, 2017

my bad

diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py
index 721d204..db8eb70 100755
--- a/contrib/linearize/linearize-hashes.py
+++ b/contrib/linearize/linearize-hashes.py
@@ -16,6 +16,8 @@ import json
 import re
 import base64
 import sys
+import os
+import os.path
 
 settings = {}
 
@@ -93,9 +95,9 @@ def get_block_hashes(settings, max_blocks_per_call=10000):
 
                height += num_blocks
 
-def get_rpc_cookie(settings):
+def get_rpc_cookie():
        # Open the cookie file
-       with open(os.path.join(os.path.expanduser(settings['datadir']), '/.cookie'), 'r') as f:
+       with open(os.path.join(os.path.expanduser(settings['datadir']), '.cookie'), 'r') as f:
                combined = f.readline()
                combined_split = combined.split(":")
                settings['rpcuser'] = combined_split[0]
@@ -150,6 +152,6 @@ if __name__ == '__main__':
 
        # Get the rpc user and pass from the cookie if the datadir is set
        if use_datadir:
-               get_rpc_cookie(settings)
+               get_rpc_cookie()
 
        get_block_hashes(settings)

@achow101 achow101 force-pushed the linearize-use-cookie branch from 2c4bbed to 1285f3a Compare March 30, 2017 00:11
Adds a datadir configuration option to the linearize scripts to allow the script to use the RPC cookie instead of requiring the user to set a rpcuser and rpcpassword for the rpc server.
@achow101 achow101 force-pushed the linearize-use-cookie branch from 1285f3a to bd41d98 Compare March 30, 2017 00:13
@achow101
Copy link
Member Author

achow101 commented Mar 30, 2017

@pstratem Now is it right?

@laanwj laanwj merged commit bd41d98 into bitcoin:master Apr 5, 2017
laanwj added a commit that referenced this pull request Apr 5, 2017
bd41d98 Datadir option in linearize scripts (Andrew Chow)

Tree-SHA512: 0d11866b574986c087ec962a8a9fc0b6dfee8175ae20ef827f8b4a143f657c5bffc9f9696e9dabf29b68002003a5b6a7d8ac473231b5c9c81c3a4fa0318f5bd0
@achow101 achow101 deleted the linearize-use-cookie branch April 5, 2017 14:30
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request May 20, 2019
bd41d98 Datadir option in linearize scripts (Andrew Chow)

Tree-SHA512: 0d11866b574986c087ec962a8a9fc0b6dfee8175ae20ef827f8b4a143f657c5bffc9f9696e9dabf29b68002003a5b6a7d8ac473231b5c9c81c3a4fa0318f5bd0
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linearize script does not use rpc cookie

5 participants