id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
230,500 | blockstack/blockstack-core | blockstack/blockstackd.py | get_logfile_path | def get_logfile_path(working_dir):
"""
Get the logfile path for our service endpoint.
"""
logfile_filename = virtualchain_hooks.get_virtual_chain_name() + ".log"
return os.path.join( working_dir, logfile_filename ) | python | def get_logfile_path(working_dir):
"""
Get the logfile path for our service endpoint.
"""
logfile_filename = virtualchain_hooks.get_virtual_chain_name() + ".log"
return os.path.join( working_dir, logfile_filename ) | [
"def",
"get_logfile_path",
"(",
"working_dir",
")",
":",
"logfile_filename",
"=",
"virtualchain_hooks",
".",
"get_virtual_chain_name",
"(",
")",
"+",
"\".log\"",
"return",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"logfile_filename",
")"
] | Get the logfile path for our service endpoint. | [
"Get",
"the",
"logfile",
"path",
"for",
"our",
"service",
"endpoint",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L155-L160 |
230,501 | blockstack/blockstack-core | blockstack/blockstackd.py | get_index_range | def get_index_range(working_dir):
"""
Get the bitcoin block index range.
Mask connection failures with timeouts.
Always try to reconnect.
The last block will be the last block to search for names.
This will be NUM_CONFIRMATIONS behind the actual last-block the
cryptocurrency node knows abou... | python | def get_index_range(working_dir):
"""
Get the bitcoin block index range.
Mask connection failures with timeouts.
Always try to reconnect.
The last block will be the last block to search for names.
This will be NUM_CONFIRMATIONS behind the actual last-block the
cryptocurrency node knows abou... | [
"def",
"get_index_range",
"(",
"working_dir",
")",
":",
"bitcoind_session",
"=",
"get_bitcoind",
"(",
"new",
"=",
"True",
")",
"assert",
"bitcoind_session",
"is",
"not",
"None",
"first_block",
"=",
"None",
"last_block",
"=",
"None",
"wait",
"=",
"1.0",
"while"... | Get the bitcoin block index range.
Mask connection failures with timeouts.
Always try to reconnect.
The last block will be the last block to search for names.
This will be NUM_CONFIRMATIONS behind the actual last-block the
cryptocurrency node knows about. | [
"Get",
"the",
"bitcoin",
"block",
"index",
"range",
".",
"Mask",
"connection",
"failures",
"with",
"timeouts",
".",
"Always",
"try",
"to",
"reconnect",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L163-L197 |
230,502 | blockstack/blockstack-core | blockstack/blockstackd.py | rpc_start | def rpc_start( working_dir, port, subdomain_index=None, thread=True ):
"""
Start the global RPC server thread
Returns the RPC server thread
"""
rpc_srv = BlockstackdRPCServer( working_dir, port, subdomain_index=subdomain_index )
log.debug("Starting RPC on port {}".format(port))
if thread:
... | python | def rpc_start( working_dir, port, subdomain_index=None, thread=True ):
"""
Start the global RPC server thread
Returns the RPC server thread
"""
rpc_srv = BlockstackdRPCServer( working_dir, port, subdomain_index=subdomain_index )
log.debug("Starting RPC on port {}".format(port))
if thread:
... | [
"def",
"rpc_start",
"(",
"working_dir",
",",
"port",
",",
"subdomain_index",
"=",
"None",
",",
"thread",
"=",
"True",
")",
":",
"rpc_srv",
"=",
"BlockstackdRPCServer",
"(",
"working_dir",
",",
"port",
",",
"subdomain_index",
"=",
"subdomain_index",
")",
"log",... | Start the global RPC server thread
Returns the RPC server thread | [
"Start",
"the",
"global",
"RPC",
"server",
"thread",
"Returns",
"the",
"RPC",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2079-L2090 |
230,503 | blockstack/blockstack-core | blockstack/blockstackd.py | rpc_chain_sync | def rpc_chain_sync(server_state, new_block_height, finish_time):
"""
Flush the global RPC server cache, and tell the rpc server that we've
reached the given block height at the given time.
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
rpc_srv.cache_flush()
rpc_srv.set... | python | def rpc_chain_sync(server_state, new_block_height, finish_time):
"""
Flush the global RPC server cache, and tell the rpc server that we've
reached the given block height at the given time.
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
rpc_srv.cache_flush()
rpc_srv.set... | [
"def",
"rpc_chain_sync",
"(",
"server_state",
",",
"new_block_height",
",",
"finish_time",
")",
":",
"rpc_srv",
"=",
"server_state",
"[",
"'rpc'",
"]",
"if",
"rpc_srv",
"is",
"not",
"None",
":",
"rpc_srv",
".",
"cache_flush",
"(",
")",
"rpc_srv",
".",
"set_l... | Flush the global RPC server cache, and tell the rpc server that we've
reached the given block height at the given time. | [
"Flush",
"the",
"global",
"RPC",
"server",
"cache",
"and",
"tell",
"the",
"rpc",
"server",
"that",
"we",
"ve",
"reached",
"the",
"given",
"block",
"height",
"at",
"the",
"given",
"time",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2093-L2101 |
230,504 | blockstack/blockstack-core | blockstack/blockstackd.py | rpc_stop | def rpc_stop(server_state):
"""
Stop the global RPC server thread
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
log.info("Shutting down RPC")
rpc_srv.stop_server()
rpc_srv.join()
log.info("RPC joined")
else:
log.info("RPC already joined")
... | python | def rpc_stop(server_state):
"""
Stop the global RPC server thread
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
log.info("Shutting down RPC")
rpc_srv.stop_server()
rpc_srv.join()
log.info("RPC joined")
else:
log.info("RPC already joined")
... | [
"def",
"rpc_stop",
"(",
"server_state",
")",
":",
"rpc_srv",
"=",
"server_state",
"[",
"'rpc'",
"]",
"if",
"rpc_srv",
"is",
"not",
"None",
":",
"log",
".",
"info",
"(",
"\"Shutting down RPC\"",
")",
"rpc_srv",
".",
"stop_server",
"(",
")",
"rpc_srv",
".",
... | Stop the global RPC server thread | [
"Stop",
"the",
"global",
"RPC",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2104-L2119 |
230,505 | blockstack/blockstack-core | blockstack/blockstackd.py | gc_stop | def gc_stop():
"""
Stop a the optimistic GC thread
"""
global gc_thread
if gc_thread:
log.info("Shutting down GC thread")
gc_thread.signal_stop()
gc_thread.join()
log.info("GC thread joined")
gc_thread = None
else:
log.info("GC thread already ... | python | def gc_stop():
"""
Stop a the optimistic GC thread
"""
global gc_thread
if gc_thread:
log.info("Shutting down GC thread")
gc_thread.signal_stop()
gc_thread.join()
log.info("GC thread joined")
gc_thread = None
else:
log.info("GC thread already ... | [
"def",
"gc_stop",
"(",
")",
":",
"global",
"gc_thread",
"if",
"gc_thread",
":",
"log",
".",
"info",
"(",
"\"Shutting down GC thread\"",
")",
"gc_thread",
".",
"signal_stop",
"(",
")",
"gc_thread",
".",
"join",
"(",
")",
"log",
".",
"info",
"(",
"\"GC threa... | Stop a the optimistic GC thread | [
"Stop",
"a",
"the",
"optimistic",
"GC",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2133-L2146 |
230,506 | blockstack/blockstack-core | blockstack/blockstackd.py | api_start | def api_start(working_dir, host, port, thread=True):
"""
Start the global API server
Returns the API server thread
"""
api_srv = BlockstackdAPIServer( working_dir, host, port )
log.info("Starting API server on port {}".format(port))
if thread:
api_srv.start()
return api_srv | python | def api_start(working_dir, host, port, thread=True):
"""
Start the global API server
Returns the API server thread
"""
api_srv = BlockstackdAPIServer( working_dir, host, port )
log.info("Starting API server on port {}".format(port))
if thread:
api_srv.start()
return api_srv | [
"def",
"api_start",
"(",
"working_dir",
",",
"host",
",",
"port",
",",
"thread",
"=",
"True",
")",
":",
"api_srv",
"=",
"BlockstackdAPIServer",
"(",
"working_dir",
",",
"host",
",",
"port",
")",
"log",
".",
"info",
"(",
"\"Starting API server on port {}\"",
... | Start the global API server
Returns the API server thread | [
"Start",
"the",
"global",
"API",
"server",
"Returns",
"the",
"API",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2157-L2167 |
230,507 | blockstack/blockstack-core | blockstack/blockstackd.py | api_stop | def api_stop(server_state):
"""
Stop the global API server thread
"""
api_srv = server_state['api']
if api_srv is not None:
log.info("Shutting down API")
api_srv.stop_server()
api_srv.join()
log.info("API server joined")
else:
log.info("API already joined... | python | def api_stop(server_state):
"""
Stop the global API server thread
"""
api_srv = server_state['api']
if api_srv is not None:
log.info("Shutting down API")
api_srv.stop_server()
api_srv.join()
log.info("API server joined")
else:
log.info("API already joined... | [
"def",
"api_stop",
"(",
"server_state",
")",
":",
"api_srv",
"=",
"server_state",
"[",
"'api'",
"]",
"if",
"api_srv",
"is",
"not",
"None",
":",
"log",
".",
"info",
"(",
"\"Shutting down API\"",
")",
"api_srv",
".",
"stop_server",
"(",
")",
"api_srv",
".",
... | Stop the global API server thread | [
"Stop",
"the",
"global",
"API",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2170-L2184 |
230,508 | blockstack/blockstack-core | blockstack/blockstackd.py | atlas_init | def atlas_init(blockstack_opts, db, recover=False, port=None):
"""
Start up atlas functionality
"""
if port is None:
port = blockstack_opts['rpc_port']
# start atlas node
atlas_state = None
if is_atlas_enabled(blockstack_opts):
atlas_seed_peers = filter( lambda x: len(x) > 0... | python | def atlas_init(blockstack_opts, db, recover=False, port=None):
"""
Start up atlas functionality
"""
if port is None:
port = blockstack_opts['rpc_port']
# start atlas node
atlas_state = None
if is_atlas_enabled(blockstack_opts):
atlas_seed_peers = filter( lambda x: len(x) > 0... | [
"def",
"atlas_init",
"(",
"blockstack_opts",
",",
"db",
",",
"recover",
"=",
"False",
",",
"port",
"=",
"None",
")",
":",
"if",
"port",
"is",
"None",
":",
"port",
"=",
"blockstack_opts",
"[",
"'rpc_port'",
"]",
"# start atlas node",
"atlas_state",
"=",
"No... | Start up atlas functionality | [
"Start",
"up",
"atlas",
"functionality"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2187-L2208 |
230,509 | blockstack/blockstack-core | blockstack/blockstackd.py | read_pid_file | def read_pid_file(pidfile_path):
"""
Read the PID from the PID file
"""
try:
fin = open(pidfile_path, "r")
except Exception, e:
return None
else:
pid_data = fin.read().strip()
fin.close()
try:
pid = int(pid_data)
return pid
... | python | def read_pid_file(pidfile_path):
"""
Read the PID from the PID file
"""
try:
fin = open(pidfile_path, "r")
except Exception, e:
return None
else:
pid_data = fin.read().strip()
fin.close()
try:
pid = int(pid_data)
return pid
... | [
"def",
"read_pid_file",
"(",
"pidfile_path",
")",
":",
"try",
":",
"fin",
"=",
"open",
"(",
"pidfile_path",
",",
"\"r\"",
")",
"except",
"Exception",
",",
"e",
":",
"return",
"None",
"else",
":",
"pid_data",
"=",
"fin",
".",
"read",
"(",
")",
".",
"s... | Read the PID from the PID file | [
"Read",
"the",
"PID",
"from",
"the",
"PID",
"file"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2220-L2238 |
230,510 | blockstack/blockstack-core | blockstack/blockstackd.py | check_server_running | def check_server_running(pid):
"""
Determine if the given process is running
"""
if pid == os.getpid():
# special case--we're in Docker or some other kind of container
# (or we got really unlucky and got the same PID twice).
# this PID does not correspond to another running serve... | python | def check_server_running(pid):
"""
Determine if the given process is running
"""
if pid == os.getpid():
# special case--we're in Docker or some other kind of container
# (or we got really unlucky and got the same PID twice).
# this PID does not correspond to another running serve... | [
"def",
"check_server_running",
"(",
"pid",
")",
":",
"if",
"pid",
"==",
"os",
".",
"getpid",
"(",
")",
":",
"# special case--we're in Docker or some other kind of container",
"# (or we got really unlucky and got the same PID twice).",
"# this PID does not correspond to another runn... | Determine if the given process is running | [
"Determine",
"if",
"the",
"given",
"process",
"is",
"running"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2241-L2258 |
230,511 | blockstack/blockstack-core | blockstack/blockstackd.py | stop_server | def stop_server( working_dir, clean=False, kill=False ):
"""
Stop the blockstackd server.
"""
timeout = 1.0
dead = False
for i in xrange(0, 5):
# try to kill the main supervisor
pid_file = get_pidfile_path(working_dir)
if not os.path.exists(pid_file):
dead =... | python | def stop_server( working_dir, clean=False, kill=False ):
"""
Stop the blockstackd server.
"""
timeout = 1.0
dead = False
for i in xrange(0, 5):
# try to kill the main supervisor
pid_file = get_pidfile_path(working_dir)
if not os.path.exists(pid_file):
dead =... | [
"def",
"stop_server",
"(",
"working_dir",
",",
"clean",
"=",
"False",
",",
"kill",
"=",
"False",
")",
":",
"timeout",
"=",
"1.0",
"dead",
"=",
"False",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"5",
")",
":",
"# try to kill the main supervisor",
"pid_fi... | Stop the blockstackd server. | [
"Stop",
"the",
"blockstackd",
"server",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2261-L2340 |
230,512 | blockstack/blockstack-core | blockstack/blockstackd.py | genesis_block_load | def genesis_block_load(module_path=None):
"""
Make sure the genesis block is good to go.
Load and instantiate it.
"""
if os.environ.get('BLOCKSTACK_GENESIS_BLOCK_PATH') is not None:
log.warning('Using envar-given genesis block')
module_path = os.environ['BLOCKSTACK_GENESIS_BLOCK_PATH... | python | def genesis_block_load(module_path=None):
"""
Make sure the genesis block is good to go.
Load and instantiate it.
"""
if os.environ.get('BLOCKSTACK_GENESIS_BLOCK_PATH') is not None:
log.warning('Using envar-given genesis block')
module_path = os.environ['BLOCKSTACK_GENESIS_BLOCK_PATH... | [
"def",
"genesis_block_load",
"(",
"module_path",
"=",
"None",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'BLOCKSTACK_GENESIS_BLOCK_PATH'",
")",
"is",
"not",
"None",
":",
"log",
".",
"warning",
"(",
"'Using envar-given genesis block'",
")",
"module_p... | Make sure the genesis block is good to go.
Load and instantiate it. | [
"Make",
"sure",
"the",
"genesis",
"block",
"is",
"good",
"to",
"go",
".",
"Load",
"and",
"instantiate",
"it",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2431-L2484 |
230,513 | blockstack/blockstack-core | blockstack/blockstackd.py | server_setup | def server_setup(working_dir, port=None, api_port=None, indexer_enabled=None, indexer_url=None, api_enabled=None, recover=False):
"""
Set up the server.
Start all subsystems, write pid file, set up signal handlers, set up DB.
Returns a server instance.
"""
if not is_genesis_block_instantiated():... | python | def server_setup(working_dir, port=None, api_port=None, indexer_enabled=None, indexer_url=None, api_enabled=None, recover=False):
"""
Set up the server.
Start all subsystems, write pid file, set up signal handlers, set up DB.
Returns a server instance.
"""
if not is_genesis_block_instantiated():... | [
"def",
"server_setup",
"(",
"working_dir",
",",
"port",
"=",
"None",
",",
"api_port",
"=",
"None",
",",
"indexer_enabled",
"=",
"None",
",",
"indexer_url",
"=",
"None",
",",
"api_enabled",
"=",
"None",
",",
"recover",
"=",
"False",
")",
":",
"if",
"not",... | Set up the server.
Start all subsystems, write pid file, set up signal handlers, set up DB.
Returns a server instance. | [
"Set",
"up",
"the",
"server",
".",
"Start",
"all",
"subsystems",
"write",
"pid",
"file",
"set",
"up",
"signal",
"handlers",
"set",
"up",
"DB",
".",
"Returns",
"a",
"server",
"instance",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2487-L2599 |
230,514 | blockstack/blockstack-core | blockstack/blockstackd.py | server_shutdown | def server_shutdown(server_state):
"""
Shut down server subsystems.
Remove PID file.
"""
set_running( False )
# stop API servers
rpc_stop(server_state)
api_stop(server_state)
# stop atlas node
server_atlas_shutdown(server_state)
# stopping GC
gc_stop()
# clear PID... | python | def server_shutdown(server_state):
"""
Shut down server subsystems.
Remove PID file.
"""
set_running( False )
# stop API servers
rpc_stop(server_state)
api_stop(server_state)
# stop atlas node
server_atlas_shutdown(server_state)
# stopping GC
gc_stop()
# clear PID... | [
"def",
"server_shutdown",
"(",
"server_state",
")",
":",
"set_running",
"(",
"False",
")",
"# stop API servers",
"rpc_stop",
"(",
"server_state",
")",
"api_stop",
"(",
"server_state",
")",
"# stop atlas node",
"server_atlas_shutdown",
"(",
"server_state",
")",
"# stop... | Shut down server subsystems.
Remove PID file. | [
"Shut",
"down",
"server",
"subsystems",
".",
"Remove",
"PID",
"file",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2614-L2638 |
230,515 | blockstack/blockstack-core | blockstack/blockstackd.py | run_server | def run_server(working_dir, foreground=False, expected_snapshots=GENESIS_SNAPSHOT, port=None, api_port=None, use_api=None, use_indexer=None, indexer_url=None, recover=False):
"""
Run blockstackd. Optionally daemonize.
Return 0 on success
Return negative on error
"""
global rpc_server
global... | python | def run_server(working_dir, foreground=False, expected_snapshots=GENESIS_SNAPSHOT, port=None, api_port=None, use_api=None, use_indexer=None, indexer_url=None, recover=False):
"""
Run blockstackd. Optionally daemonize.
Return 0 on success
Return negative on error
"""
global rpc_server
global... | [
"def",
"run_server",
"(",
"working_dir",
",",
"foreground",
"=",
"False",
",",
"expected_snapshots",
"=",
"GENESIS_SNAPSHOT",
",",
"port",
"=",
"None",
",",
"api_port",
"=",
"None",
",",
"use_api",
"=",
"None",
",",
"use_indexer",
"=",
"None",
",",
"indexer_... | Run blockstackd. Optionally daemonize.
Return 0 on success
Return negative on error | [
"Run",
"blockstackd",
".",
"Optionally",
"daemonize",
".",
"Return",
"0",
"on",
"success",
"Return",
"negative",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2641-L2716 |
230,516 | blockstack/blockstack-core | blockstack/blockstackd.py | setup | def setup(working_dir, interactive=False):
"""
Do one-time initialization.
Call this to set up global state.
"""
# set up our implementation
log.debug("Working dir: {}".format(working_dir))
if not os.path.exists( working_dir ):
os.makedirs( working_dir, 0700 )
node_config = load... | python | def setup(working_dir, interactive=False):
"""
Do one-time initialization.
Call this to set up global state.
"""
# set up our implementation
log.debug("Working dir: {}".format(working_dir))
if not os.path.exists( working_dir ):
os.makedirs( working_dir, 0700 )
node_config = load... | [
"def",
"setup",
"(",
"working_dir",
",",
"interactive",
"=",
"False",
")",
":",
"# set up our implementation",
"log",
".",
"debug",
"(",
"\"Working dir: {}\"",
".",
"format",
"(",
"working_dir",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
... | Do one-time initialization.
Call this to set up global state. | [
"Do",
"one",
"-",
"time",
"initialization",
".",
"Call",
"this",
"to",
"set",
"up",
"global",
"state",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2719-L2734 |
230,517 | blockstack/blockstack-core | blockstack/blockstackd.py | reconfigure | def reconfigure(working_dir):
"""
Reconfigure blockstackd.
"""
configure(working_dir, force=True, interactive=True)
print "Blockstack successfully reconfigured."
sys.exit(0) | python | def reconfigure(working_dir):
"""
Reconfigure blockstackd.
"""
configure(working_dir, force=True, interactive=True)
print "Blockstack successfully reconfigured."
sys.exit(0) | [
"def",
"reconfigure",
"(",
"working_dir",
")",
":",
"configure",
"(",
"working_dir",
",",
"force",
"=",
"True",
",",
"interactive",
"=",
"True",
")",
"print",
"\"Blockstack successfully reconfigured.\"",
"sys",
".",
"exit",
"(",
"0",
")"
] | Reconfigure blockstackd. | [
"Reconfigure",
"blockstackd",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2737-L2743 |
230,518 | blockstack/blockstack-core | blockstack/blockstackd.py | verify_database | def verify_database(trusted_consensus_hash, consensus_block_height, untrusted_working_dir, trusted_working_dir, start_block=None, expected_snapshots={}):
"""
Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not
"""
db = BlockstackDB... | python | def verify_database(trusted_consensus_hash, consensus_block_height, untrusted_working_dir, trusted_working_dir, start_block=None, expected_snapshots={}):
"""
Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not
"""
db = BlockstackDB... | [
"def",
"verify_database",
"(",
"trusted_consensus_hash",
",",
"consensus_block_height",
",",
"untrusted_working_dir",
",",
"trusted_working_dir",
",",
"start_block",
"=",
"None",
",",
"expected_snapshots",
"=",
"{",
"}",
")",
":",
"db",
"=",
"BlockstackDB",
".",
"ge... | Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not | [
"Verify",
"that",
"a",
"database",
"is",
"consistent",
"with",
"a",
"known",
"-",
"good",
"consensus",
"hash",
".",
"Return",
"True",
"if",
"valid",
".",
"Return",
"False",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2746-L2755 |
230,519 | blockstack/blockstack-core | blockstack/blockstackd.py | check_and_set_envars | def check_and_set_envars( argv ):
"""
Go through argv and find any special command-line flags
that set environment variables that affect multiple modules.
If any of them are given, then set them in this process's
environment and re-exec the process without the CLI flags.
argv should be like sy... | python | def check_and_set_envars( argv ):
"""
Go through argv and find any special command-line flags
that set environment variables that affect multiple modules.
If any of them are given, then set them in this process's
environment and re-exec the process without the CLI flags.
argv should be like sy... | [
"def",
"check_and_set_envars",
"(",
"argv",
")",
":",
"special_flags",
"=",
"{",
"'--debug'",
":",
"{",
"'arg'",
":",
"False",
",",
"'envar'",
":",
"'BLOCKSTACK_DEBUG'",
",",
"'exec'",
":",
"True",
",",
"}",
",",
"'--verbose'",
":",
"{",
"'arg'",
":",
"F... | Go through argv and find any special command-line flags
that set environment variables that affect multiple modules.
If any of them are given, then set them in this process's
environment and re-exec the process without the CLI flags.
argv should be like sys.argv: argv[0] is the binary
Does not r... | [
"Go",
"through",
"argv",
"and",
"find",
"any",
"special",
"command",
"-",
"line",
"flags",
"that",
"set",
"environment",
"variables",
"that",
"affect",
"multiple",
"modules",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2758-L2875 |
230,520 | blockstack/blockstack-core | blockstack/blockstackd.py | load_expected_snapshots | def load_expected_snapshots( snapshots_path ):
"""
Load expected consensus hashes from a .snapshots file.
Return the snapshots as a dict on success
Return None on error
"""
# use snapshots?
snapshots_path = os.path.expanduser(snapshots_path)
expected_snapshots = {}
# legacy chainsta... | python | def load_expected_snapshots( snapshots_path ):
"""
Load expected consensus hashes from a .snapshots file.
Return the snapshots as a dict on success
Return None on error
"""
# use snapshots?
snapshots_path = os.path.expanduser(snapshots_path)
expected_snapshots = {}
# legacy chainsta... | [
"def",
"load_expected_snapshots",
"(",
"snapshots_path",
")",
":",
"# use snapshots?",
"snapshots_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"snapshots_path",
")",
"expected_snapshots",
"=",
"{",
"}",
"# legacy chainstate?",
"try",
":",
"with",
"open",
... | Load expected consensus hashes from a .snapshots file.
Return the snapshots as a dict on success
Return None on error | [
"Load",
"expected",
"consensus",
"hashes",
"from",
"a",
".",
"snapshots",
"file",
".",
"Return",
"the",
"snapshots",
"as",
"a",
"dict",
"on",
"success",
"Return",
"None",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2878-L2923 |
230,521 | blockstack/blockstack-core | blockstack/blockstackd.py | do_genesis_block_audit | def do_genesis_block_audit(genesis_block_path=None, key_id=None):
"""
Loads and audits the genesis block, optionally using an alternative key
"""
signing_keys = GENESIS_BLOCK_SIGNING_KEYS
if genesis_block_path is not None:
# alternative genesis block
genesis_block_load(genesis_block_... | python | def do_genesis_block_audit(genesis_block_path=None, key_id=None):
"""
Loads and audits the genesis block, optionally using an alternative key
"""
signing_keys = GENESIS_BLOCK_SIGNING_KEYS
if genesis_block_path is not None:
# alternative genesis block
genesis_block_load(genesis_block_... | [
"def",
"do_genesis_block_audit",
"(",
"genesis_block_path",
"=",
"None",
",",
"key_id",
"=",
"None",
")",
":",
"signing_keys",
"=",
"GENESIS_BLOCK_SIGNING_KEYS",
"if",
"genesis_block_path",
"is",
"not",
"None",
":",
"# alternative genesis block",
"genesis_block_load",
"... | Loads and audits the genesis block, optionally using an alternative key | [
"Loads",
"and",
"audits",
"the",
"genesis",
"block",
"optionally",
"using",
"an",
"alternative",
"key"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2926-L2952 |
230,522 | blockstack/blockstack-core | blockstack/blockstackd.py | setup_recovery | def setup_recovery(working_dir):
"""
Set up the recovery metadata so we can fully recover secondary state,
like subdomains.
"""
db = get_db_state(working_dir)
bitcoind_session = get_bitcoind(new=True)
assert bitcoind_session is not None
_, current_block = virtualchain.get_index_range('b... | python | def setup_recovery(working_dir):
"""
Set up the recovery metadata so we can fully recover secondary state,
like subdomains.
"""
db = get_db_state(working_dir)
bitcoind_session = get_bitcoind(new=True)
assert bitcoind_session is not None
_, current_block = virtualchain.get_index_range('b... | [
"def",
"setup_recovery",
"(",
"working_dir",
")",
":",
"db",
"=",
"get_db_state",
"(",
"working_dir",
")",
"bitcoind_session",
"=",
"get_bitcoind",
"(",
"new",
"=",
"True",
")",
"assert",
"bitcoind_session",
"is",
"not",
"None",
"_",
",",
"current_block",
"=",... | Set up the recovery metadata so we can fully recover secondary state,
like subdomains. | [
"Set",
"up",
"the",
"recovery",
"metadata",
"so",
"we",
"can",
"fully",
"recover",
"secondary",
"state",
"like",
"subdomains",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2954-L2967 |
230,523 | blockstack/blockstack-core | blockstack/blockstackd.py | check_recovery | def check_recovery(working_dir):
"""
Do we need to recover on start-up?
"""
recovery_start_block, recovery_end_block = get_recovery_range(working_dir)
if recovery_start_block is not None and recovery_end_block is not None:
local_current_block = virtualchain_hooks.get_last_block(working_dir)
... | python | def check_recovery(working_dir):
"""
Do we need to recover on start-up?
"""
recovery_start_block, recovery_end_block = get_recovery_range(working_dir)
if recovery_start_block is not None and recovery_end_block is not None:
local_current_block = virtualchain_hooks.get_last_block(working_dir)
... | [
"def",
"check_recovery",
"(",
"working_dir",
")",
":",
"recovery_start_block",
",",
"recovery_end_block",
"=",
"get_recovery_range",
"(",
"working_dir",
")",
"if",
"recovery_start_block",
"is",
"not",
"None",
"and",
"recovery_end_block",
"is",
"not",
"None",
":",
"l... | Do we need to recover on start-up? | [
"Do",
"we",
"need",
"to",
"recover",
"on",
"start",
"-",
"up?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2970-L2987 |
230,524 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.success_response | def success_response(self, method_resp, **kw):
"""
Make a standard "success" response,
which contains some ancilliary data.
Also, detect if this node is too far behind the Bitcoin blockchain,
and if so, convert this into an error message.
"""
resp = {
... | python | def success_response(self, method_resp, **kw):
"""
Make a standard "success" response,
which contains some ancilliary data.
Also, detect if this node is too far behind the Bitcoin blockchain,
and if so, convert this into an error message.
"""
resp = {
... | [
"def",
"success_response",
"(",
"self",
",",
"method_resp",
",",
"*",
"*",
"kw",
")",
":",
"resp",
"=",
"{",
"'status'",
":",
"True",
",",
"'indexing'",
":",
"config",
".",
"is_indexing",
"(",
"self",
".",
"working_dir",
")",
",",
"'lastblock'",
":",
"... | Make a standard "success" response,
which contains some ancilliary data.
Also, detect if this node is too far behind the Bitcoin blockchain,
and if so, convert this into an error message. | [
"Make",
"a",
"standard",
"success",
"response",
"which",
"contains",
"some",
"ancilliary",
"data",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L515-L537 |
230,525 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.load_name_info | def load_name_info(self, db, name_record):
"""
Get some extra name information, given a db-loaded name record.
Return the updated name_record
"""
name = str(name_record['name'])
name_record = self.sanitize_rec(name_record)
namespace_id = get_namespace_from_name(n... | python | def load_name_info(self, db, name_record):
"""
Get some extra name information, given a db-loaded name record.
Return the updated name_record
"""
name = str(name_record['name'])
name_record = self.sanitize_rec(name_record)
namespace_id = get_namespace_from_name(n... | [
"def",
"load_name_info",
"(",
"self",
",",
"db",
",",
"name_record",
")",
":",
"name",
"=",
"str",
"(",
"name_record",
"[",
"'name'",
"]",
")",
"name_record",
"=",
"self",
".",
"sanitize_rec",
"(",
"name_record",
")",
"namespace_id",
"=",
"get_namespace_from... | Get some extra name information, given a db-loaded name record.
Return the updated name_record | [
"Get",
"some",
"extra",
"name",
"information",
"given",
"a",
"db",
"-",
"loaded",
"name",
"record",
".",
"Return",
"the",
"updated",
"name_record"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L574-L620 |
230,526 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_name_DID_info | def get_name_DID_info(self, name):
"""
Get a name's DID info
Returns None if not found
"""
db = get_db_state(self.working_dir)
did_info = db.get_name_DID_info(name)
if did_info is None:
return {'error': 'No such name', 'http_status': 404}
retu... | python | def get_name_DID_info(self, name):
"""
Get a name's DID info
Returns None if not found
"""
db = get_db_state(self.working_dir)
did_info = db.get_name_DID_info(name)
if did_info is None:
return {'error': 'No such name', 'http_status': 404}
retu... | [
"def",
"get_name_DID_info",
"(",
"self",
",",
"name",
")",
":",
"db",
"=",
"get_db_state",
"(",
"self",
".",
"working_dir",
")",
"did_info",
"=",
"db",
".",
"get_name_DID_info",
"(",
"name",
")",
"if",
"did_info",
"is",
"None",
":",
"return",
"{",
"'erro... | Get a name's DID info
Returns None if not found | [
"Get",
"a",
"name",
"s",
"DID",
"info",
"Returns",
"None",
"if",
"not",
"found"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L712-L722 |
230,527 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_name_DID | def rpc_get_name_DID(self, name, **con_info):
"""
Given a name or subdomain, return its DID.
"""
did_info = None
if check_name(name):
did_info = self.get_name_DID_info(name)
elif check_subdomain(name):
did_info = self.get_subdomain_DID_info(name)
... | python | def rpc_get_name_DID(self, name, **con_info):
"""
Given a name or subdomain, return its DID.
"""
did_info = None
if check_name(name):
did_info = self.get_name_DID_info(name)
elif check_subdomain(name):
did_info = self.get_subdomain_DID_info(name)
... | [
"def",
"rpc_get_name_DID",
"(",
"self",
",",
"name",
",",
"*",
"*",
"con_info",
")",
":",
"did_info",
"=",
"None",
"if",
"check_name",
"(",
"name",
")",
":",
"did_info",
"=",
"self",
".",
"get_name_DID_info",
"(",
"name",
")",
"elif",
"check_subdomain",
... | Given a name or subdomain, return its DID. | [
"Given",
"a",
"name",
"or",
"subdomain",
"return",
"its",
"DID",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L734-L750 |
230,528 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_DID_record | def rpc_get_DID_record(self, did, **con_info):
"""
Given a DID, return the name or subdomain it corresponds to
"""
if not isinstance(did, (str,unicode)):
return {'error': 'Invalid DID: not a string', 'http_status': 400}
try:
did_info = parse_DID(did)
... | python | def rpc_get_DID_record(self, did, **con_info):
"""
Given a DID, return the name or subdomain it corresponds to
"""
if not isinstance(did, (str,unicode)):
return {'error': 'Invalid DID: not a string', 'http_status': 400}
try:
did_info = parse_DID(did)
... | [
"def",
"rpc_get_DID_record",
"(",
"self",
",",
"did",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"isinstance",
"(",
"did",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid DID: not a string'",
",",
"'http_st... | Given a DID, return the name or subdomain it corresponds to | [
"Given",
"a",
"DID",
"return",
"the",
"name",
"or",
"subdomain",
"it",
"corresponds",
"to"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L805-L826 |
230,529 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_blockstack_ops_at | def rpc_get_blockstack_ops_at(self, block_id, offset, count, **con_info):
"""
Get the name operations that occured in the given block.
Does not include account operations.
Returns {'nameops': [...]} on success.
Returns {'error': ...} on error
"""
if not check_blo... | python | def rpc_get_blockstack_ops_at(self, block_id, offset, count, **con_info):
"""
Get the name operations that occured in the given block.
Does not include account operations.
Returns {'nameops': [...]} on success.
Returns {'error': ...} on error
"""
if not check_blo... | [
"def",
"rpc_get_blockstack_ops_at",
"(",
"self",
",",
"block_id",
",",
"offset",
",",
"count",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_block",
"(",
"block_id",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid block height'",
",",
"'http_st... | Get the name operations that occured in the given block.
Does not include account operations.
Returns {'nameops': [...]} on success.
Returns {'error': ...} on error | [
"Get",
"the",
"name",
"operations",
"that",
"occured",
"in",
"the",
"given",
"block",
".",
"Does",
"not",
"include",
"account",
"operations",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L976-L1005 |
230,530 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_blockstack_ops_hash_at | def rpc_get_blockstack_ops_hash_at( self, block_id, **con_info ):
"""
Get the hash over the sequence of names and namespaces altered at the given block.
Used by SNV clients.
Returns {'status': True, 'ops_hash': ops_hash} on success
Returns {'error': ...} on error
"""
... | python | def rpc_get_blockstack_ops_hash_at( self, block_id, **con_info ):
"""
Get the hash over the sequence of names and namespaces altered at the given block.
Used by SNV clients.
Returns {'status': True, 'ops_hash': ops_hash} on success
Returns {'error': ...} on error
"""
... | [
"def",
"rpc_get_blockstack_ops_hash_at",
"(",
"self",
",",
"block_id",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_block",
"(",
"block_id",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid block height'",
",",
"'http_status'",
":",
"400",
"}",
... | Get the hash over the sequence of names and namespaces altered at the given block.
Used by SNV clients.
Returns {'status': True, 'ops_hash': ops_hash} on success
Returns {'error': ...} on error | [
"Get",
"the",
"hash",
"over",
"the",
"sequence",
"of",
"names",
"and",
"namespaces",
"altered",
"at",
"the",
"given",
"block",
".",
"Used",
"by",
"SNV",
"clients",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1008-L1023 |
230,531 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_bitcoind_info | def get_bitcoind_info(self):
"""
Get bitcoind info. Try the cache, and on cache miss,
fetch from bitcoind and cache.
"""
cached_bitcoind_info = self.get_cached_bitcoind_info()
if cached_bitcoind_info:
return cached_bitcoind_info
bitcoind_opts = defa... | python | def get_bitcoind_info(self):
"""
Get bitcoind info. Try the cache, and on cache miss,
fetch from bitcoind and cache.
"""
cached_bitcoind_info = self.get_cached_bitcoind_info()
if cached_bitcoind_info:
return cached_bitcoind_info
bitcoind_opts = defa... | [
"def",
"get_bitcoind_info",
"(",
"self",
")",
":",
"cached_bitcoind_info",
"=",
"self",
".",
"get_cached_bitcoind_info",
"(",
")",
"if",
"cached_bitcoind_info",
":",
"return",
"cached_bitcoind_info",
"bitcoind_opts",
"=",
"default_bitcoind_opts",
"(",
"virtualchain",
".... | Get bitcoind info. Try the cache, and on cache miss,
fetch from bitcoind and cache. | [
"Get",
"bitcoind",
"info",
".",
"Try",
"the",
"cache",
"and",
"on",
"cache",
"miss",
"fetch",
"from",
"bitcoind",
"and",
"cache",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1078-L1102 |
230,532 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_consensus_info | def get_consensus_info(self):
"""
Get block height and consensus hash. Try the cache, and
on cache miss, fetch from the db
"""
cached_consensus_info = self.get_cached_consensus_info()
if cached_consensus_info:
return cached_consensus_info
db = get_db... | python | def get_consensus_info(self):
"""
Get block height and consensus hash. Try the cache, and
on cache miss, fetch from the db
"""
cached_consensus_info = self.get_cached_consensus_info()
if cached_consensus_info:
return cached_consensus_info
db = get_db... | [
"def",
"get_consensus_info",
"(",
"self",
")",
":",
"cached_consensus_info",
"=",
"self",
".",
"get_cached_consensus_info",
"(",
")",
"if",
"cached_consensus_info",
":",
"return",
"cached_consensus_info",
"db",
"=",
"get_db_state",
"(",
"self",
".",
"working_dir",
"... | Get block height and consensus hash. Try the cache, and
on cache miss, fetch from the db | [
"Get",
"block",
"height",
"and",
"consensus",
"hash",
".",
"Try",
"the",
"cache",
"and",
"on",
"cache",
"miss",
"fetch",
"from",
"the",
"db"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1105-L1121 |
230,533 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_tokens | def rpc_get_account_tokens(self, address, **con_info):
"""
Get the types of tokens that an account owns
Returns the list on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
# must be b58
if is_... | python | def rpc_get_account_tokens(self, address, **con_info):
"""
Get the types of tokens that an account owns
Returns the list on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
# must be b58
if is_... | [
"def",
"rpc_get_account_tokens",
"(",
"self",
",",
"address",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",
"400",
"}",
"# m... | Get the types of tokens that an account owns
Returns the list on success | [
"Get",
"the",
"types",
"of",
"tokens",
"that",
"an",
"account",
"owns",
"Returns",
"the",
"list",
"on",
"success"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1300-L1315 |
230,534 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_balance | def rpc_get_account_balance(self, address, token_type, **con_info):
"""
Get the balance of an address for a particular token type
Returns the value on success
Returns 0 if the balance is 0, or if there is no address
"""
if not check_account_address(address):
r... | python | def rpc_get_account_balance(self, address, token_type, **con_info):
"""
Get the balance of an address for a particular token type
Returns the value on success
Returns 0 if the balance is 0, or if there is no address
"""
if not check_account_address(address):
r... | [
"def",
"rpc_get_account_balance",
"(",
"self",
",",
"address",
",",
"token_type",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":"... | Get the balance of an address for a particular token type
Returns the value on success
Returns 0 if the balance is 0, or if there is no address | [
"Get",
"the",
"balance",
"of",
"an",
"address",
"for",
"a",
"particular",
"token",
"type",
"Returns",
"the",
"value",
"on",
"success",
"Returns",
"0",
"if",
"the",
"balance",
"is",
"0",
"or",
"if",
"there",
"is",
"no",
"address"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1318-L1344 |
230,535 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.export_account_state | def export_account_state(self, account_state):
"""
Make an account state presentable to external consumers
"""
return {
'address': account_state['address'],
'type': account_state['type'],
'credit_value': '{}'.format(account_state['credit_value']),
... | python | def export_account_state(self, account_state):
"""
Make an account state presentable to external consumers
"""
return {
'address': account_state['address'],
'type': account_state['type'],
'credit_value': '{}'.format(account_state['credit_value']),
... | [
"def",
"export_account_state",
"(",
"self",
",",
"account_state",
")",
":",
"return",
"{",
"'address'",
":",
"account_state",
"[",
"'address'",
"]",
",",
"'type'",
":",
"account_state",
"[",
"'type'",
"]",
",",
"'credit_value'",
":",
"'{}'",
".",
"format",
"... | Make an account state presentable to external consumers | [
"Make",
"an",
"account",
"state",
"presentable",
"to",
"external",
"consumers"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1347-L1360 |
230,536 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_record | def rpc_get_account_record(self, address, token_type, **con_info):
"""
Get the current state of an account
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_token_type(token_type):
return {'err... | python | def rpc_get_account_record(self, address, token_type, **con_info):
"""
Get the current state of an account
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_token_type(token_type):
return {'err... | [
"def",
"rpc_get_account_record",
"(",
"self",
",",
"address",
",",
"token_type",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",... | Get the current state of an account | [
"Get",
"the",
"current",
"state",
"of",
"an",
"account"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1363-L1385 |
230,537 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_at | def rpc_get_account_at(self, address, block_height, **con_info):
"""
Get the account's statuses at a particular block height.
Returns the sequence of history states on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status'... | python | def rpc_get_account_at(self, address, block_height, **con_info):
"""
Get the account's statuses at a particular block height.
Returns the sequence of history states on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status'... | [
"def",
"rpc_get_account_at",
"(",
"self",
",",
"address",
",",
"block_height",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",
... | Get the account's statuses at a particular block height.
Returns the sequence of history states on success | [
"Get",
"the",
"account",
"s",
"statuses",
"at",
"a",
"particular",
"block",
"height",
".",
"Returns",
"the",
"sequence",
"of",
"history",
"states",
"on",
"success"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1414-L1436 |
230,538 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_consensus_hashes | def rpc_get_consensus_hashes( self, block_id_list, **con_info ):
"""
Return the consensus hashes at multiple block numbers
Return a dict mapping each block ID to its consensus hash.
Returns {'status': True, 'consensus_hashes': dict} on success
Returns {'error': ...} on success
... | python | def rpc_get_consensus_hashes( self, block_id_list, **con_info ):
"""
Return the consensus hashes at multiple block numbers
Return a dict mapping each block ID to its consensus hash.
Returns {'status': True, 'consensus_hashes': dict} on success
Returns {'error': ...} on success
... | [
"def",
"rpc_get_consensus_hashes",
"(",
"self",
",",
"block_id_list",
",",
"*",
"*",
"con_info",
")",
":",
"if",
"type",
"(",
"block_id_list",
")",
"!=",
"list",
":",
"return",
"{",
"'error'",
":",
"'Invalid block heights'",
",",
"'http_status'",
":",
"400",
... | Return the consensus hashes at multiple block numbers
Return a dict mapping each block ID to its consensus hash.
Returns {'status': True, 'consensus_hashes': dict} on success
Returns {'error': ...} on success | [
"Return",
"the",
"consensus",
"hashes",
"at",
"multiple",
"block",
"numbers",
"Return",
"a",
"dict",
"mapping",
"each",
"block",
"ID",
"to",
"its",
"consensus",
"hash",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1653-L1678 |
230,539 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_zonefile_data | def get_zonefile_data( self, zonefile_hash, zonefile_dir ):
"""
Get a zonefile by hash
Return the serialized zonefile on success
Return None on error
"""
# check cache
atlas_zonefile_data = get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=False )
... | python | def get_zonefile_data( self, zonefile_hash, zonefile_dir ):
"""
Get a zonefile by hash
Return the serialized zonefile on success
Return None on error
"""
# check cache
atlas_zonefile_data = get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=False )
... | [
"def",
"get_zonefile_data",
"(",
"self",
",",
"zonefile_hash",
",",
"zonefile_dir",
")",
":",
"# check cache",
"atlas_zonefile_data",
"=",
"get_atlas_zonefile_data",
"(",
"zonefile_hash",
",",
"zonefile_dir",
",",
"check",
"=",
"False",
")",
"if",
"atlas_zonefile_data... | Get a zonefile by hash
Return the serialized zonefile on success
Return None on error | [
"Get",
"a",
"zonefile",
"by",
"hash",
"Return",
"the",
"serialized",
"zonefile",
"on",
"success",
"Return",
"None",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1694-L1713 |
230,540 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_zonefiles_by_block | def rpc_get_zonefiles_by_block( self, from_block, to_block, offset, count, **con_info ):
"""
Get information about zonefiles announced in blocks [@from_block, @to_block]
@offset - offset into result set
@count - max records to return, must be <= 100
Returns {'status': True, 'last... | python | def rpc_get_zonefiles_by_block( self, from_block, to_block, offset, count, **con_info ):
"""
Get information about zonefiles announced in blocks [@from_block, @to_block]
@offset - offset into result set
@count - max records to return, must be <= 100
Returns {'status': True, 'last... | [
"def",
"rpc_get_zonefiles_by_block",
"(",
"self",
",",
"from_block",
",",
"to_block",
",",
"offset",
",",
"count",
",",
"*",
"*",
"con_info",
")",
":",
"conf",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_atlas_enabled",
"(",
"conf",
")",
":",
"r... | Get information about zonefiles announced in blocks [@from_block, @to_block]
@offset - offset into result set
@count - max records to return, must be <= 100
Returns {'status': True, 'lastblock' : blockNumber,
'zonefile_info' : [ { 'block_height' : 470000,
... | [
"Get",
"information",
"about",
"zonefiles",
"announced",
"in",
"blocks",
"["
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1845-L1875 |
230,541 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.peer_exchange | def peer_exchange(self, peer_host, peer_port):
"""
Exchange peers.
Add the given peer to the list of new peers to consider.
Return the list of healthy peers
"""
# get peers
peer_list = atlas_get_live_neighbors( "%s:%s" % (peer_host, peer_port) )
if len(pee... | python | def peer_exchange(self, peer_host, peer_port):
"""
Exchange peers.
Add the given peer to the list of new peers to consider.
Return the list of healthy peers
"""
# get peers
peer_list = atlas_get_live_neighbors( "%s:%s" % (peer_host, peer_port) )
if len(pee... | [
"def",
"peer_exchange",
"(",
"self",
",",
"peer_host",
",",
"peer_port",
")",
":",
"# get peers",
"peer_list",
"=",
"atlas_get_live_neighbors",
"(",
"\"%s:%s\"",
"%",
"(",
"peer_host",
",",
"peer_port",
")",
")",
"if",
"len",
"(",
"peer_list",
")",
">",
"atl... | Exchange peers.
Add the given peer to the list of new peers to consider.
Return the list of healthy peers | [
"Exchange",
"peers",
".",
"Add",
"the",
"given",
"peer",
"to",
"the",
"list",
"of",
"new",
"peers",
"to",
"consider",
".",
"Return",
"the",
"list",
"of",
"healthy",
"peers"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1878-L1894 |
230,542 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_atlas_peer_exchange | def rpc_atlas_peer_exchange(self, remote_peer, **con_info):
"""
Accept a remotely-given atlas peer, and return our list
of healthy peers. The remotely-given atlas peer will only
be considered if the caller is localhost; otherwise, the caller's
socket-given information will be us... | python | def rpc_atlas_peer_exchange(self, remote_peer, **con_info):
"""
Accept a remotely-given atlas peer, and return our list
of healthy peers. The remotely-given atlas peer will only
be considered if the caller is localhost; otherwise, the caller's
socket-given information will be us... | [
"def",
"rpc_atlas_peer_exchange",
"(",
"self",
",",
"remote_peer",
",",
"*",
"*",
"con_info",
")",
":",
"conf",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"conf",
".",
"get",
"(",
"'atlas'",
",",
"False",
")",
":",
"return",
"{",
"'error'",
":",
... | Accept a remotely-given atlas peer, and return our list
of healthy peers. The remotely-given atlas peer will only
be considered if the caller is localhost; otherwise, the caller's
socket-given information will be used. This is to prevent
a malicious node from filling up this node's pee... | [
"Accept",
"a",
"remotely",
"-",
"given",
"atlas",
"peer",
"and",
"return",
"our",
"list",
"of",
"healthy",
"peers",
".",
"The",
"remotely",
"-",
"given",
"atlas",
"peer",
"will",
"only",
"be",
"considered",
"if",
"the",
"caller",
"is",
"localhost",
";",
... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1917-L1957 |
230,543 | blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPCServer.stop_server | def stop_server(self):
"""
Stop serving. Also stops the thread.
"""
if self.rpc_server is not None:
try:
self.rpc_server.socket.shutdown(socket.SHUT_RDWR)
except:
log.warning("Failed to shut down server socket")
self.r... | python | def stop_server(self):
"""
Stop serving. Also stops the thread.
"""
if self.rpc_server is not None:
try:
self.rpc_server.socket.shutdown(socket.SHUT_RDWR)
except:
log.warning("Failed to shut down server socket")
self.r... | [
"def",
"stop_server",
"(",
"self",
")",
":",
"if",
"self",
".",
"rpc_server",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"rpc_server",
".",
"socket",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"except",
":",
"log",
".",
"warning",
... | Stop serving. Also stops the thread. | [
"Stop",
"serving",
".",
"Also",
"stops",
"the",
"thread",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2017-L2027 |
230,544 | blockstack/blockstack-core | blockstack/lib/nameset/virtualchain_hooks.py | get_last_block | def get_last_block(working_dir):
"""
Get the last block processed
Return the integer on success
Return None on error
"""
# make this usable even if we haven't explicitly configured virtualchain
impl = sys.modules[__name__]
return BlockstackDB.get_lastblock(impl, working_dir) | python | def get_last_block(working_dir):
"""
Get the last block processed
Return the integer on success
Return None on error
"""
# make this usable even if we haven't explicitly configured virtualchain
impl = sys.modules[__name__]
return BlockstackDB.get_lastblock(impl, working_dir) | [
"def",
"get_last_block",
"(",
"working_dir",
")",
":",
"# make this usable even if we haven't explicitly configured virtualchain ",
"impl",
"=",
"sys",
".",
"modules",
"[",
"__name__",
"]",
"return",
"BlockstackDB",
".",
"get_lastblock",
"(",
"impl",
",",
"working_dir",
... | Get the last block processed
Return the integer on success
Return None on error | [
"Get",
"the",
"last",
"block",
"processed",
"Return",
"the",
"integer",
"on",
"success",
"Return",
"None",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/virtualchain_hooks.py#L119-L128 |
230,545 | blockstack/blockstack-core | blockstack/lib/nameset/virtualchain_hooks.py | get_or_instantiate_db_state | def get_or_instantiate_db_state(working_dir):
"""
Get a read-only handle to the DB.
Instantiate it first if it doesn't exist.
DO NOT CALL WHILE INDEXING
Returns the handle on success
Raises on error
"""
# instantiates
new_db = BlockstackDB.borrow_readwrite_instance(working_dir, -1... | python | def get_or_instantiate_db_state(working_dir):
"""
Get a read-only handle to the DB.
Instantiate it first if it doesn't exist.
DO NOT CALL WHILE INDEXING
Returns the handle on success
Raises on error
"""
# instantiates
new_db = BlockstackDB.borrow_readwrite_instance(working_dir, -1... | [
"def",
"get_or_instantiate_db_state",
"(",
"working_dir",
")",
":",
"# instantiates",
"new_db",
"=",
"BlockstackDB",
".",
"borrow_readwrite_instance",
"(",
"working_dir",
",",
"-",
"1",
")",
"BlockstackDB",
".",
"release_readwrite_instance",
"(",
"new_db",
",",
"-",
... | Get a read-only handle to the DB.
Instantiate it first if it doesn't exist.
DO NOT CALL WHILE INDEXING
Returns the handle on success
Raises on error | [
"Get",
"a",
"read",
"-",
"only",
"handle",
"to",
"the",
"DB",
".",
"Instantiate",
"it",
"first",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/virtualchain_hooks.py#L162-L177 |
230,546 | blockstack/blockstack-core | blockstack/lib/nameset/virtualchain_hooks.py | check_quirks | def check_quirks(block_id, block_op, db_state):
"""
Check that all serialization compatibility quirks have been preserved.
Used primarily for testing.
"""
if op_get_opcode_name(block_op['op']) in OPCODE_NAME_NAMEOPS and op_get_opcode_name(block_op['op']) not in OPCODE_NAME_STATE_PREORDER:
as... | python | def check_quirks(block_id, block_op, db_state):
"""
Check that all serialization compatibility quirks have been preserved.
Used primarily for testing.
"""
if op_get_opcode_name(block_op['op']) in OPCODE_NAME_NAMEOPS and op_get_opcode_name(block_op['op']) not in OPCODE_NAME_STATE_PREORDER:
as... | [
"def",
"check_quirks",
"(",
"block_id",
",",
"block_op",
",",
"db_state",
")",
":",
"if",
"op_get_opcode_name",
"(",
"block_op",
"[",
"'op'",
"]",
")",
"in",
"OPCODE_NAME_NAMEOPS",
"and",
"op_get_opcode_name",
"(",
"block_op",
"[",
"'op'",
"]",
")",
"not",
"... | Check that all serialization compatibility quirks have been preserved.
Used primarily for testing. | [
"Check",
"that",
"all",
"serialization",
"compatibility",
"quirks",
"have",
"been",
"preserved",
".",
"Used",
"primarily",
"for",
"testing",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/virtualchain_hooks.py#L381-L393 |
230,547 | blockstack/blockstack-core | blockstack/lib/nameset/virtualchain_hooks.py | sync_blockchain | def sync_blockchain( working_dir, bt_opts, last_block, server_state, expected_snapshots={}, **virtualchain_args ):
"""
synchronize state with the blockchain.
Return True on success
Return False if we're supposed to stop indexing
Abort on error
"""
subdomain_index = server_state['subdoma... | python | def sync_blockchain( working_dir, bt_opts, last_block, server_state, expected_snapshots={}, **virtualchain_args ):
"""
synchronize state with the blockchain.
Return True on success
Return False if we're supposed to stop indexing
Abort on error
"""
subdomain_index = server_state['subdoma... | [
"def",
"sync_blockchain",
"(",
"working_dir",
",",
"bt_opts",
",",
"last_block",
",",
"server_state",
",",
"expected_snapshots",
"=",
"{",
"}",
",",
"*",
"*",
"virtualchain_args",
")",
":",
"subdomain_index",
"=",
"server_state",
"[",
"'subdomains'",
"]",
"atlas... | synchronize state with the blockchain.
Return True on success
Return False if we're supposed to stop indexing
Abort on error | [
"synchronize",
"state",
"with",
"the",
"blockchain",
".",
"Return",
"True",
"on",
"success",
"Return",
"False",
"if",
"we",
"re",
"supposed",
"to",
"stop",
"indexing",
"Abort",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/virtualchain_hooks.py#L576-L603 |
230,548 | blockstack/blockstack-core | blockstack/lib/util.py | url_protocol | def url_protocol(url, port=None):
"""
Get the protocol to use for a URL.
return 'http' or 'https' or None
"""
if not url.startswith('http://') and not url.startswith('https://'):
return None
urlinfo = urllib2.urlparse.urlparse(url)
assert urlinfo.scheme in ['http', 'https'], 'Invali... | python | def url_protocol(url, port=None):
"""
Get the protocol to use for a URL.
return 'http' or 'https' or None
"""
if not url.startswith('http://') and not url.startswith('https://'):
return None
urlinfo = urllib2.urlparse.urlparse(url)
assert urlinfo.scheme in ['http', 'https'], 'Invali... | [
"def",
"url_protocol",
"(",
"url",
",",
"port",
"=",
"None",
")",
":",
"if",
"not",
"url",
".",
"startswith",
"(",
"'http://'",
")",
"and",
"not",
"url",
".",
"startswith",
"(",
"'https://'",
")",
":",
"return",
"None",
"urlinfo",
"=",
"urllib2",
".",
... | Get the protocol to use for a URL.
return 'http' or 'https' or None | [
"Get",
"the",
"protocol",
"to",
"use",
"for",
"a",
"URL",
".",
"return",
"http",
"or",
"https",
"or",
"None"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/util.py#L242-L252 |
230,549 | blockstack/blockstack-core | blockstack/lib/util.py | make_DID | def make_DID(name_type, address, index):
"""
Standard way of making a DID.
name_type is "name" or "subdomain"
"""
if name_type not in ['name', 'subdomain']:
raise ValueError("Require 'name' or 'subdomain' for name_type")
if name_type == 'name':
address = virtualchain.address_ree... | python | def make_DID(name_type, address, index):
"""
Standard way of making a DID.
name_type is "name" or "subdomain"
"""
if name_type not in ['name', 'subdomain']:
raise ValueError("Require 'name' or 'subdomain' for name_type")
if name_type == 'name':
address = virtualchain.address_ree... | [
"def",
"make_DID",
"(",
"name_type",
",",
"address",
",",
"index",
")",
":",
"if",
"name_type",
"not",
"in",
"[",
"'name'",
",",
"'subdomain'",
"]",
":",
"raise",
"ValueError",
"(",
"\"Require 'name' or 'subdomain' for name_type\"",
")",
"if",
"name_type",
"==",... | Standard way of making a DID.
name_type is "name" or "subdomain" | [
"Standard",
"way",
"of",
"making",
"a",
"DID",
".",
"name_type",
"is",
"name",
"or",
"subdomain"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/util.py#L315-L336 |
230,550 | blockstack/blockstack-core | blockstack/lib/util.py | BoundedThreadingMixIn.process_request_thread | def process_request_thread(self, request, client_address):
"""
Same as in BaseServer but as a thread.
In addition, exception handling is done here.
"""
from ..blockstackd import get_gc_thread
try:
self.finish_request(request, client_address)
except Ex... | python | def process_request_thread(self, request, client_address):
"""
Same as in BaseServer but as a thread.
In addition, exception handling is done here.
"""
from ..blockstackd import get_gc_thread
try:
self.finish_request(request, client_address)
except Ex... | [
"def",
"process_request_thread",
"(",
"self",
",",
"request",
",",
"client_address",
")",
":",
"from",
".",
".",
"blockstackd",
"import",
"get_gc_thread",
"try",
":",
"self",
".",
"finish_request",
"(",
"request",
",",
"client_address",
")",
"except",
"Exception... | Same as in BaseServer but as a thread.
In addition, exception handling is done here. | [
"Same",
"as",
"in",
"BaseServer",
"but",
"as",
"a",
"thread",
".",
"In",
"addition",
"exception",
"handling",
"is",
"done",
"here",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/util.py#L91-L118 |
230,551 | blockstack/blockstack-core | blockstack/lib/util.py | BoundedThreadingMixIn.get_request | def get_request(self):
"""
Accept a request, up to the given number of allowed threads.
Defer to self.overloaded if there are already too many pending requests.
"""
# Note that this class must be mixed with another class that implements get_request()
request, client_addr ... | python | def get_request(self):
"""
Accept a request, up to the given number of allowed threads.
Defer to self.overloaded if there are already too many pending requests.
"""
# Note that this class must be mixed with another class that implements get_request()
request, client_addr ... | [
"def",
"get_request",
"(",
"self",
")",
":",
"# Note that this class must be mixed with another class that implements get_request()",
"request",
",",
"client_addr",
"=",
"super",
"(",
"BoundedThreadingMixIn",
",",
"self",
")",
".",
"get_request",
"(",
")",
"overload",
"="... | Accept a request, up to the given number of allowed threads.
Defer to self.overloaded if there are already too many pending requests. | [
"Accept",
"a",
"request",
"up",
"to",
"the",
"given",
"number",
"of",
"allowed",
"threads",
".",
"Defer",
"to",
"self",
".",
"overloaded",
"if",
"there",
"are",
"already",
"too",
"many",
"pending",
"requests",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/util.py#L126-L146 |
230,552 | blockstack/blockstack-core | blockstack/lib/config.py | get_epoch_config | def get_epoch_config( block_height ):
"""
Get the epoch constants for the given block height
"""
global EPOCHS
epoch_number = get_epoch_number( block_height )
if epoch_number < 0 or epoch_number >= len(EPOCHS):
log.error("FATAL: invalid epoch %s" % epoch_number)
os.abort()
... | python | def get_epoch_config( block_height ):
"""
Get the epoch constants for the given block height
"""
global EPOCHS
epoch_number = get_epoch_number( block_height )
if epoch_number < 0 or epoch_number >= len(EPOCHS):
log.error("FATAL: invalid epoch %s" % epoch_number)
os.abort()
... | [
"def",
"get_epoch_config",
"(",
"block_height",
")",
":",
"global",
"EPOCHS",
"epoch_number",
"=",
"get_epoch_number",
"(",
"block_height",
")",
"if",
"epoch_number",
"<",
"0",
"or",
"epoch_number",
">=",
"len",
"(",
"EPOCHS",
")",
":",
"log",
".",
"error",
... | Get the epoch constants for the given block height | [
"Get",
"the",
"epoch",
"constants",
"for",
"the",
"given",
"block",
"height"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L949-L960 |
230,553 | blockstack/blockstack-core | blockstack/lib/config.py | get_epoch_namespace_lifetime_multiplier | def get_epoch_namespace_lifetime_multiplier( block_height, namespace_id ):
"""
what's the namespace lifetime multipler for this epoch?
"""
epoch_config = get_epoch_config( block_height )
if epoch_config['namespaces'].has_key(namespace_id):
return epoch_config['namespaces'][namespace_id]['NAM... | python | def get_epoch_namespace_lifetime_multiplier( block_height, namespace_id ):
"""
what's the namespace lifetime multipler for this epoch?
"""
epoch_config = get_epoch_config( block_height )
if epoch_config['namespaces'].has_key(namespace_id):
return epoch_config['namespaces'][namespace_id]['NAM... | [
"def",
"get_epoch_namespace_lifetime_multiplier",
"(",
"block_height",
",",
"namespace_id",
")",
":",
"epoch_config",
"=",
"get_epoch_config",
"(",
"block_height",
")",
"if",
"epoch_config",
"[",
"'namespaces'",
"]",
".",
"has_key",
"(",
"namespace_id",
")",
":",
"r... | what's the namespace lifetime multipler for this epoch? | [
"what",
"s",
"the",
"namespace",
"lifetime",
"multipler",
"for",
"this",
"epoch?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L963-L971 |
230,554 | blockstack/blockstack-core | blockstack/lib/config.py | get_epoch_namespace_lifetime_grace_period | def get_epoch_namespace_lifetime_grace_period( block_height, namespace_id ):
"""
what's the namespace lifetime grace period for this epoch?
"""
epoch_config = get_epoch_config( block_height )
if epoch_config['namespaces'].has_key(namespace_id):
return epoch_config['namespaces'][namespace_id]... | python | def get_epoch_namespace_lifetime_grace_period( block_height, namespace_id ):
"""
what's the namespace lifetime grace period for this epoch?
"""
epoch_config = get_epoch_config( block_height )
if epoch_config['namespaces'].has_key(namespace_id):
return epoch_config['namespaces'][namespace_id]... | [
"def",
"get_epoch_namespace_lifetime_grace_period",
"(",
"block_height",
",",
"namespace_id",
")",
":",
"epoch_config",
"=",
"get_epoch_config",
"(",
"block_height",
")",
"if",
"epoch_config",
"[",
"'namespaces'",
"]",
".",
"has_key",
"(",
"namespace_id",
")",
":",
... | what's the namespace lifetime grace period for this epoch? | [
"what",
"s",
"the",
"namespace",
"lifetime",
"grace",
"period",
"for",
"this",
"epoch?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L974-L982 |
230,555 | blockstack/blockstack-core | blockstack/lib/config.py | get_epoch_namespace_prices | def get_epoch_namespace_prices( block_height, units ):
"""
get the list of namespace prices by block height
"""
assert units in ['BTC', TOKEN_TYPE_STACKS], 'Invalid unit {}'.format(units)
epoch_config = get_epoch_config( block_height )
if units == 'BTC':
return epoch_config['namespace_... | python | def get_epoch_namespace_prices( block_height, units ):
"""
get the list of namespace prices by block height
"""
assert units in ['BTC', TOKEN_TYPE_STACKS], 'Invalid unit {}'.format(units)
epoch_config = get_epoch_config( block_height )
if units == 'BTC':
return epoch_config['namespace_... | [
"def",
"get_epoch_namespace_prices",
"(",
"block_height",
",",
"units",
")",
":",
"assert",
"units",
"in",
"[",
"'BTC'",
",",
"TOKEN_TYPE_STACKS",
"]",
",",
"'Invalid unit {}'",
".",
"format",
"(",
"units",
")",
"epoch_config",
"=",
"get_epoch_config",
"(",
"blo... | get the list of namespace prices by block height | [
"get",
"the",
"list",
"of",
"namespace",
"prices",
"by",
"block",
"height"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1062-L1073 |
230,556 | blockstack/blockstack-core | blockstack/lib/config.py | op_get_opcode_name | def op_get_opcode_name(op_string):
"""
Get the name of an opcode, given the 'op' byte sequence of the operation.
"""
global OPCODE_NAMES
# special case...
if op_string == '{}:'.format(NAME_REGISTRATION):
return 'NAME_RENEWAL'
op = op_string[0]
if op not in OPCODE_NAMES:
... | python | def op_get_opcode_name(op_string):
"""
Get the name of an opcode, given the 'op' byte sequence of the operation.
"""
global OPCODE_NAMES
# special case...
if op_string == '{}:'.format(NAME_REGISTRATION):
return 'NAME_RENEWAL'
op = op_string[0]
if op not in OPCODE_NAMES:
... | [
"def",
"op_get_opcode_name",
"(",
"op_string",
")",
":",
"global",
"OPCODE_NAMES",
"# special case...",
"if",
"op_string",
"==",
"'{}:'",
".",
"format",
"(",
"NAME_REGISTRATION",
")",
":",
"return",
"'NAME_RENEWAL'",
"op",
"=",
"op_string",
"[",
"0",
"]",
"if",
... | Get the name of an opcode, given the 'op' byte sequence of the operation. | [
"Get",
"the",
"name",
"of",
"an",
"opcode",
"given",
"the",
"op",
"byte",
"sequence",
"of",
"the",
"operation",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1138-L1152 |
230,557 | blockstack/blockstack-core | blockstack/lib/config.py | get_announce_filename | def get_announce_filename( working_dir ):
"""
Get the path to the file that stores all of the announcements.
"""
announce_filepath = os.path.join( working_dir, get_default_virtualchain_impl().get_virtual_chain_name() ) + '.announce'
return announce_filepath | python | def get_announce_filename( working_dir ):
"""
Get the path to the file that stores all of the announcements.
"""
announce_filepath = os.path.join( working_dir, get_default_virtualchain_impl().get_virtual_chain_name() ) + '.announce'
return announce_filepath | [
"def",
"get_announce_filename",
"(",
"working_dir",
")",
":",
"announce_filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"get_default_virtualchain_impl",
"(",
")",
".",
"get_virtual_chain_name",
"(",
")",
")",
"+",
"'.announce'",
"return",
... | Get the path to the file that stores all of the announcements. | [
"Get",
"the",
"path",
"to",
"the",
"file",
"that",
"stores",
"all",
"of",
"the",
"announcements",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1168-L1173 |
230,558 | blockstack/blockstack-core | blockstack/lib/config.py | is_indexing | def is_indexing(working_dir):
"""
Is the blockstack daemon synchronizing with the blockchain?
"""
indexing_path = get_indexing_lockfile(working_dir)
if os.path.exists( indexing_path ):
return True
else:
return False | python | def is_indexing(working_dir):
"""
Is the blockstack daemon synchronizing with the blockchain?
"""
indexing_path = get_indexing_lockfile(working_dir)
if os.path.exists( indexing_path ):
return True
else:
return False | [
"def",
"is_indexing",
"(",
"working_dir",
")",
":",
"indexing_path",
"=",
"get_indexing_lockfile",
"(",
"working_dir",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"indexing_path",
")",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | Is the blockstack daemon synchronizing with the blockchain? | [
"Is",
"the",
"blockstack",
"daemon",
"synchronizing",
"with",
"the",
"blockchain?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1231-L1239 |
230,559 | blockstack/blockstack-core | blockstack/lib/config.py | set_indexing | def set_indexing(working_dir, flag):
"""
Set a flag in the filesystem as to whether or not we're indexing.
"""
indexing_path = get_indexing_lockfile(working_dir)
if flag:
try:
fd = open( indexing_path, "w+" )
fd.close()
return True
except:
... | python | def set_indexing(working_dir, flag):
"""
Set a flag in the filesystem as to whether or not we're indexing.
"""
indexing_path = get_indexing_lockfile(working_dir)
if flag:
try:
fd = open( indexing_path, "w+" )
fd.close()
return True
except:
... | [
"def",
"set_indexing",
"(",
"working_dir",
",",
"flag",
")",
":",
"indexing_path",
"=",
"get_indexing_lockfile",
"(",
"working_dir",
")",
"if",
"flag",
":",
"try",
":",
"fd",
"=",
"open",
"(",
"indexing_path",
",",
"\"w+\"",
")",
"fd",
".",
"close",
"(",
... | Set a flag in the filesystem as to whether or not we're indexing. | [
"Set",
"a",
"flag",
"in",
"the",
"filesystem",
"as",
"to",
"whether",
"or",
"not",
"we",
"re",
"indexing",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1242-L1260 |
230,560 | blockstack/blockstack-core | blockstack/lib/config.py | set_recovery_range | def set_recovery_range(working_dir, start_block, end_block):
"""
Set the recovery block range if we're restoring and reporcessing
transactions from a backup.
Writes the recovery range to the working directory if the working directory is given and persist is True
"""
recovery_range_path = os.pat... | python | def set_recovery_range(working_dir, start_block, end_block):
"""
Set the recovery block range if we're restoring and reporcessing
transactions from a backup.
Writes the recovery range to the working directory if the working directory is given and persist is True
"""
recovery_range_path = os.pat... | [
"def",
"set_recovery_range",
"(",
"working_dir",
",",
"start_block",
",",
"end_block",
")",
":",
"recovery_range_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"'.recovery'",
")",
"with",
"open",
"(",
"recovery_range_path",
",",
"'w'",
")... | Set the recovery block range if we're restoring and reporcessing
transactions from a backup.
Writes the recovery range to the working directory if the working directory is given and persist is True | [
"Set",
"the",
"recovery",
"block",
"range",
"if",
"we",
"re",
"restoring",
"and",
"reporcessing",
"transactions",
"from",
"a",
"backup",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1304-L1315 |
230,561 | blockstack/blockstack-core | blockstack/lib/config.py | clear_recovery_range | def clear_recovery_range(working_dir):
"""
Clear out our recovery hint
"""
recovery_range_path = os.path.join(working_dir, '.recovery')
if os.path.exists(recovery_range_path):
os.unlink(recovery_range_path) | python | def clear_recovery_range(working_dir):
"""
Clear out our recovery hint
"""
recovery_range_path = os.path.join(working_dir, '.recovery')
if os.path.exists(recovery_range_path):
os.unlink(recovery_range_path) | [
"def",
"clear_recovery_range",
"(",
"working_dir",
")",
":",
"recovery_range_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"'.recovery'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"recovery_range_path",
")",
":",
"os",
".",
"... | Clear out our recovery hint | [
"Clear",
"out",
"our",
"recovery",
"hint"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1318-L1324 |
230,562 | blockstack/blockstack-core | blockstack/lib/config.py | is_atlas_enabled | def is_atlas_enabled(blockstack_opts):
"""
Can we do atlas operations?
"""
if not blockstack_opts['atlas']:
log.debug("Atlas is disabled")
return False
if 'zonefiles' not in blockstack_opts:
log.debug("Atlas is disabled: no 'zonefiles' path set")
return False
if... | python | def is_atlas_enabled(blockstack_opts):
"""
Can we do atlas operations?
"""
if not blockstack_opts['atlas']:
log.debug("Atlas is disabled")
return False
if 'zonefiles' not in blockstack_opts:
log.debug("Atlas is disabled: no 'zonefiles' path set")
return False
if... | [
"def",
"is_atlas_enabled",
"(",
"blockstack_opts",
")",
":",
"if",
"not",
"blockstack_opts",
"[",
"'atlas'",
"]",
":",
"log",
".",
"debug",
"(",
"\"Atlas is disabled\"",
")",
"return",
"False",
"if",
"'zonefiles'",
"not",
"in",
"blockstack_opts",
":",
"log",
"... | Can we do atlas operations? | [
"Can",
"we",
"do",
"atlas",
"operations?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1327-L1343 |
230,563 | blockstack/blockstack-core | blockstack/lib/config.py | is_subdomains_enabled | def is_subdomains_enabled(blockstack_opts):
"""
Can we do subdomain operations?
"""
if not is_atlas_enabled(blockstack_opts):
log.debug("Subdomains are disabled")
return False
if 'subdomaindb_path' not in blockstack_opts:
log.debug("Subdomains are disabled: no 'subdomaindb_p... | python | def is_subdomains_enabled(blockstack_opts):
"""
Can we do subdomain operations?
"""
if not is_atlas_enabled(blockstack_opts):
log.debug("Subdomains are disabled")
return False
if 'subdomaindb_path' not in blockstack_opts:
log.debug("Subdomains are disabled: no 'subdomaindb_p... | [
"def",
"is_subdomains_enabled",
"(",
"blockstack_opts",
")",
":",
"if",
"not",
"is_atlas_enabled",
"(",
"blockstack_opts",
")",
":",
"log",
".",
"debug",
"(",
"\"Subdomains are disabled\"",
")",
"return",
"False",
"if",
"'subdomaindb_path'",
"not",
"in",
"blockstack... | Can we do subdomain operations? | [
"Can",
"we",
"do",
"subdomain",
"operations?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1346-L1358 |
230,564 | blockstack/blockstack-core | blockstack/lib/config.py | store_announcement | def store_announcement( working_dir, announcement_hash, announcement_text, force=False ):
"""
Store a new announcement locally, atomically.
"""
if not force:
# don't store unless we haven't seen it before
if announcement_hash in ANNOUNCEMENTS:
return
announce_filename = get_ann... | python | def store_announcement( working_dir, announcement_hash, announcement_text, force=False ):
"""
Store a new announcement locally, atomically.
"""
if not force:
# don't store unless we haven't seen it before
if announcement_hash in ANNOUNCEMENTS:
return
announce_filename = get_ann... | [
"def",
"store_announcement",
"(",
"working_dir",
",",
"announcement_hash",
",",
"announcement_text",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"force",
":",
"# don't store unless we haven't seen it before",
"if",
"announcement_hash",
"in",
"ANNOUNCEMENTS",
":",... | Store a new announcement locally, atomically. | [
"Store",
"a",
"new",
"announcement",
"locally",
"atomically",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1361-L1456 |
230,565 | blockstack/blockstack-core | blockstack/lib/config.py | default_blockstack_api_opts | def default_blockstack_api_opts(working_dir, config_file=None):
"""
Get our default blockstack RESTful API opts from a config file,
or from sane defaults.
"""
from .util import url_to_host_port, url_protocol
if config_file is None:
config_file = virtualchain.get_config_filename(get_default_vir... | python | def default_blockstack_api_opts(working_dir, config_file=None):
"""
Get our default blockstack RESTful API opts from a config file,
or from sane defaults.
"""
from .util import url_to_host_port, url_protocol
if config_file is None:
config_file = virtualchain.get_config_filename(get_default_vir... | [
"def",
"default_blockstack_api_opts",
"(",
"working_dir",
",",
"config_file",
"=",
"None",
")",
":",
"from",
".",
"util",
"import",
"url_to_host_port",
",",
"url_protocol",
"if",
"config_file",
"is",
"None",
":",
"config_file",
"=",
"virtualchain",
".",
"get_confi... | Get our default blockstack RESTful API opts from a config file,
or from sane defaults. | [
"Get",
"our",
"default",
"blockstack",
"RESTful",
"API",
"opts",
"from",
"a",
"config",
"file",
"or",
"from",
"sane",
"defaults",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1679-L1733 |
230,566 | blockstack/blockstack-core | blockstack/lib/config.py | interactive_prompt | def interactive_prompt(message, parameters, default_opts):
"""
Prompt the user for a series of parameters
Return a dict mapping the parameter name to the
user-given value.
"""
# pretty-print the message
lines = message.split('\n')
max_line_len = max([len(l) for l in lines])
print('... | python | def interactive_prompt(message, parameters, default_opts):
"""
Prompt the user for a series of parameters
Return a dict mapping the parameter name to the
user-given value.
"""
# pretty-print the message
lines = message.split('\n')
max_line_len = max([len(l) for l in lines])
print('... | [
"def",
"interactive_prompt",
"(",
"message",
",",
"parameters",
",",
"default_opts",
")",
":",
"# pretty-print the message",
"lines",
"=",
"message",
".",
"split",
"(",
"'\\n'",
")",
"max_line_len",
"=",
"max",
"(",
"[",
"len",
"(",
"l",
")",
"for",
"l",
"... | Prompt the user for a series of parameters
Return a dict mapping the parameter name to the
user-given value. | [
"Prompt",
"the",
"user",
"for",
"a",
"series",
"of",
"parameters",
"Return",
"a",
"dict",
"mapping",
"the",
"parameter",
"name",
"to",
"the",
"user",
"-",
"given",
"value",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1736-L1771 |
230,567 | blockstack/blockstack-core | blockstack/lib/config.py | find_missing | def find_missing(message, all_params, given_opts, default_opts, header=None, prompt_missing=True):
"""
Find and interactively prompt the user for missing parameters,
given the list of all valid parameters and a dict of known options.
Return the (updated dict of known options, missing, num_prompted), wi... | python | def find_missing(message, all_params, given_opts, default_opts, header=None, prompt_missing=True):
"""
Find and interactively prompt the user for missing parameters,
given the list of all valid parameters and a dict of known options.
Return the (updated dict of known options, missing, num_prompted), wi... | [
"def",
"find_missing",
"(",
"message",
",",
"all_params",
",",
"given_opts",
",",
"default_opts",
",",
"header",
"=",
"None",
",",
"prompt_missing",
"=",
"True",
")",
":",
"# are we missing anything?",
"missing_params",
"=",
"list",
"(",
"set",
"(",
"all_params"... | Find and interactively prompt the user for missing parameters,
given the list of all valid parameters and a dict of known options.
Return the (updated dict of known options, missing, num_prompted), with the user's input. | [
"Find",
"and",
"interactively",
"prompt",
"the",
"user",
"for",
"missing",
"parameters",
"given",
"the",
"list",
"of",
"all",
"valid",
"parameters",
"and",
"a",
"dict",
"of",
"known",
"options",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1774-L1805 |
230,568 | blockstack/blockstack-core | blockstack/lib/config.py | opt_strip | def opt_strip(prefix, opts):
"""
Given a dict of opts that start with prefix,
remove the prefix from each of them.
"""
ret = {}
for opt_name, opt_value in opts.items():
# remove prefix
if opt_name.startswith(prefix):
opt_name = opt_name[len(prefix):]
ret[opt... | python | def opt_strip(prefix, opts):
"""
Given a dict of opts that start with prefix,
remove the prefix from each of them.
"""
ret = {}
for opt_name, opt_value in opts.items():
# remove prefix
if opt_name.startswith(prefix):
opt_name = opt_name[len(prefix):]
ret[opt... | [
"def",
"opt_strip",
"(",
"prefix",
",",
"opts",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"opt_name",
",",
"opt_value",
"in",
"opts",
".",
"items",
"(",
")",
":",
"# remove prefix",
"if",
"opt_name",
".",
"startswith",
"(",
"prefix",
")",
":",
"opt_name",... | Given a dict of opts that start with prefix,
remove the prefix from each of them. | [
"Given",
"a",
"dict",
"of",
"opts",
"that",
"start",
"with",
"prefix",
"remove",
"the",
"prefix",
"from",
"each",
"of",
"them",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1808-L1822 |
230,569 | blockstack/blockstack-core | blockstack/lib/config.py | opt_restore | def opt_restore(prefix, opts):
"""
Given a dict of opts, add the given prefix to each key
"""
return {prefix + name: value for name, value in opts.items()} | python | def opt_restore(prefix, opts):
"""
Given a dict of opts, add the given prefix to each key
"""
return {prefix + name: value for name, value in opts.items()} | [
"def",
"opt_restore",
"(",
"prefix",
",",
"opts",
")",
":",
"return",
"{",
"prefix",
"+",
"name",
":",
"value",
"for",
"name",
",",
"value",
"in",
"opts",
".",
"items",
"(",
")",
"}"
] | Given a dict of opts, add the given prefix to each key | [
"Given",
"a",
"dict",
"of",
"opts",
"add",
"the",
"given",
"prefix",
"to",
"each",
"key"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1831-L1836 |
230,570 | blockstack/blockstack-core | blockstack/lib/config.py | default_bitcoind_opts | def default_bitcoind_opts(config_file=None, prefix=False):
"""
Get our default bitcoind options, such as from a config file,
or from sane defaults
"""
default_bitcoin_opts = virtualchain.get_bitcoind_config(config_file=config_file)
# drop dict values that are None
default_bitcoin_opts = {k... | python | def default_bitcoind_opts(config_file=None, prefix=False):
"""
Get our default bitcoind options, such as from a config file,
or from sane defaults
"""
default_bitcoin_opts = virtualchain.get_bitcoind_config(config_file=config_file)
# drop dict values that are None
default_bitcoin_opts = {k... | [
"def",
"default_bitcoind_opts",
"(",
"config_file",
"=",
"None",
",",
"prefix",
"=",
"False",
")",
":",
"default_bitcoin_opts",
"=",
"virtualchain",
".",
"get_bitcoind_config",
"(",
"config_file",
"=",
"config_file",
")",
"# drop dict values that are None",
"default_bit... | Get our default bitcoind options, such as from a config file,
or from sane defaults | [
"Get",
"our",
"default",
"bitcoind",
"options",
"such",
"as",
"from",
"a",
"config",
"file",
"or",
"from",
"sane",
"defaults"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1839-L1854 |
230,571 | blockstack/blockstack-core | blockstack/lib/config.py | default_working_dir | def default_working_dir():
"""
Get the default configuration directory for blockstackd
"""
import nameset.virtualchain_hooks as virtualchain_hooks
return os.path.expanduser('~/.{}'.format(virtualchain_hooks.get_virtual_chain_name())) | python | def default_working_dir():
"""
Get the default configuration directory for blockstackd
"""
import nameset.virtualchain_hooks as virtualchain_hooks
return os.path.expanduser('~/.{}'.format(virtualchain_hooks.get_virtual_chain_name())) | [
"def",
"default_working_dir",
"(",
")",
":",
"import",
"nameset",
".",
"virtualchain_hooks",
"as",
"virtualchain_hooks",
"return",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.{}'",
".",
"format",
"(",
"virtualchain_hooks",
".",
"get_virtual_chain_name",
"(",
"... | Get the default configuration directory for blockstackd | [
"Get",
"the",
"default",
"configuration",
"directory",
"for",
"blockstackd"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1857-L1862 |
230,572 | blockstack/blockstack-core | blockstack/lib/config.py | write_config_file | def write_config_file(opts, config_file):
"""
Write our config file with the given options dict.
Each key is a section name, and each value is the list of options.
If the file exists, do not remove unaffected sections. Instead,
merge the sections in opts into the file.
Return True on success
... | python | def write_config_file(opts, config_file):
"""
Write our config file with the given options dict.
Each key is a section name, and each value is the list of options.
If the file exists, do not remove unaffected sections. Instead,
merge the sections in opts into the file.
Return True on success
... | [
"def",
"write_config_file",
"(",
"opts",
",",
"config_file",
")",
":",
"parser",
"=",
"SafeConfigParser",
"(",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"config_file",
")",
":",
"parser",
".",
"read",
"(",
"config_file",
")",
"for",
"sec_name",
"... | Write our config file with the given options dict.
Each key is a section name, and each value is the list of options.
If the file exists, do not remove unaffected sections. Instead,
merge the sections in opts into the file.
Return True on success
Raise on error | [
"Write",
"our",
"config",
"file",
"with",
"the",
"given",
"options",
"dict",
".",
"Each",
"key",
"is",
"a",
"section",
"name",
"and",
"each",
"value",
"is",
"the",
"list",
"of",
"options",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L1976-L2009 |
230,573 | blockstack/blockstack-core | blockstack/lib/config.py | load_configuration | def load_configuration(working_dir):
"""
Load the system configuration and set global variables
Return the configuration of the node on success.
Return None on failure
"""
import nameset.virtualchain_hooks as virtualchain_hooks
# acquire configuration, and store it globally
opts = conf... | python | def load_configuration(working_dir):
"""
Load the system configuration and set global variables
Return the configuration of the node on success.
Return None on failure
"""
import nameset.virtualchain_hooks as virtualchain_hooks
# acquire configuration, and store it globally
opts = conf... | [
"def",
"load_configuration",
"(",
"working_dir",
")",
":",
"import",
"nameset",
".",
"virtualchain_hooks",
"as",
"virtualchain_hooks",
"# acquire configuration, and store it globally",
"opts",
"=",
"configure",
"(",
"working_dir",
")",
"blockstack_opts",
"=",
"opts",
".",... | Load the system configuration and set global variables
Return the configuration of the node on success.
Return None on failure | [
"Load",
"the",
"system",
"configuration",
"and",
"set",
"global",
"variables",
"Return",
"the",
"configuration",
"of",
"the",
"node",
"on",
"success",
".",
"Return",
"None",
"on",
"failure"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/config.py#L2075-L2106 |
230,574 | blockstack/blockstack-core | blockstack/lib/operations/namespaceready.py | check | def check( state_engine, nameop, block_id, checked_ops ):
"""
Verify the validity of a NAMESPACE_READY operation.
It is only valid if it has been imported by the same sender as
the corresponding NAMESPACE_REVEAL, and the namespace is still
in the process of being imported.
"""
namespace_id ... | python | def check( state_engine, nameop, block_id, checked_ops ):
"""
Verify the validity of a NAMESPACE_READY operation.
It is only valid if it has been imported by the same sender as
the corresponding NAMESPACE_REVEAL, and the namespace is still
in the process of being imported.
"""
namespace_id ... | [
"def",
"check",
"(",
"state_engine",
",",
"nameop",
",",
"block_id",
",",
"checked_ops",
")",
":",
"namespace_id",
"=",
"nameop",
"[",
"'namespace_id'",
"]",
"sender",
"=",
"nameop",
"[",
"'sender'",
"]",
"# must have been revealed",
"if",
"not",
"state_engine",... | Verify the validity of a NAMESPACE_READY operation.
It is only valid if it has been imported by the same sender as
the corresponding NAMESPACE_REVEAL, and the namespace is still
in the process of being imported. | [
"Verify",
"the",
"validity",
"of",
"a",
"NAMESPACE_READY",
"operation",
".",
"It",
"is",
"only",
"valid",
"if",
"it",
"has",
"been",
"imported",
"by",
"the",
"same",
"sender",
"as",
"the",
"corresponding",
"NAMESPACE_REVEAL",
"and",
"the",
"namespace",
"is",
... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/namespaceready.py#L52-L85 |
230,575 | blockstack/blockstack-core | blockstack/lib/b40.py | int_to_charset | def int_to_charset(val, charset):
""" Turn a non-negative integer into a string.
>>> int_to_charset(0, B40_CHARS)
'0'
>>> int_to_charset(658093, B40_CHARS)
'abcd'
>>> int_to_charset(40, B40_CHARS)
'10'
>>> int_to_charset(149190078205533, B40_CHARS)
'muneeb.id'
>>> int_to_charset... | python | def int_to_charset(val, charset):
""" Turn a non-negative integer into a string.
>>> int_to_charset(0, B40_CHARS)
'0'
>>> int_to_charset(658093, B40_CHARS)
'abcd'
>>> int_to_charset(40, B40_CHARS)
'10'
>>> int_to_charset(149190078205533, B40_CHARS)
'muneeb.id'
>>> int_to_charset... | [
"def",
"int_to_charset",
"(",
"val",
",",
"charset",
")",
":",
"if",
"val",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'\"val\" must be a non-negative integer.'",
")",
"if",
"val",
"==",
"0",
":",
"return",
"charset",
"[",
"0",
"]",
"output",
"=",
"\"\"",... | Turn a non-negative integer into a string.
>>> int_to_charset(0, B40_CHARS)
'0'
>>> int_to_charset(658093, B40_CHARS)
'abcd'
>>> int_to_charset(40, B40_CHARS)
'10'
>>> int_to_charset(149190078205533, B40_CHARS)
'muneeb.id'
>>> int_to_charset(-1, B40_CHARS)
Traceback (most recent... | [
"Turn",
"a",
"non",
"-",
"negative",
"integer",
"into",
"a",
"string",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/b40.py#L37-L65 |
230,576 | blockstack/blockstack-core | blockstack/lib/b40.py | charset_to_int | def charset_to_int(s, charset):
""" Turn a string into a non-negative integer.
>>> charset_to_int('0', B40_CHARS)
0
>>> charset_to_int('10', B40_CHARS)
40
>>> charset_to_int('abcd', B40_CHARS)
658093
>>> charset_to_int('', B40_CHARS)
0
>>> charset_to_int('muneeb.id', B40_CHARS)
... | python | def charset_to_int(s, charset):
""" Turn a string into a non-negative integer.
>>> charset_to_int('0', B40_CHARS)
0
>>> charset_to_int('10', B40_CHARS)
40
>>> charset_to_int('abcd', B40_CHARS)
658093
>>> charset_to_int('', B40_CHARS)
0
>>> charset_to_int('muneeb.id', B40_CHARS)
... | [
"def",
"charset_to_int",
"(",
"s",
",",
"charset",
")",
":",
"output",
"=",
"0",
"for",
"char",
"in",
"s",
":",
"output",
"=",
"output",
"*",
"len",
"(",
"charset",
")",
"+",
"charset",
".",
"index",
"(",
"char",
")",
"return",
"output"
] | Turn a string into a non-negative integer.
>>> charset_to_int('0', B40_CHARS)
0
>>> charset_to_int('10', B40_CHARS)
40
>>> charset_to_int('abcd', B40_CHARS)
658093
>>> charset_to_int('', B40_CHARS)
0
>>> charset_to_int('muneeb.id', B40_CHARS)
149190078205533
>>> charset_to_i... | [
"Turn",
"a",
"string",
"into",
"a",
"non",
"-",
"negative",
"integer",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/b40.py#L68-L90 |
230,577 | blockstack/blockstack-core | blockstack/lib/b40.py | change_charset | def change_charset(s, original_charset, target_charset):
""" Convert a string from one charset to another.
"""
if not isinstance(s, str):
raise ValueError('"s" must be a string.')
intermediate_integer = charset_to_int(s, original_charset)
output_string = int_to_charset(intermediate_integer,... | python | def change_charset(s, original_charset, target_charset):
""" Convert a string from one charset to another.
"""
if not isinstance(s, str):
raise ValueError('"s" must be a string.')
intermediate_integer = charset_to_int(s, original_charset)
output_string = int_to_charset(intermediate_integer,... | [
"def",
"change_charset",
"(",
"s",
",",
"original_charset",
",",
"target_charset",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"'\"s\" must be a string.'",
")",
"intermediate_integer",
"=",
"charset_to_int",
"... | Convert a string from one charset to another. | [
"Convert",
"a",
"string",
"from",
"one",
"charset",
"to",
"another",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/b40.py#L93-L101 |
230,578 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | autofill | def autofill(*autofill_fields):
"""
Decorator to automatically fill in extra useful fields
that aren't stored in the db.
"""
def wrap( reader ):
def wrapped_reader( *args, **kw ):
rec = reader( *args, **kw )
if rec is not None:
for field in autofill_fi... | python | def autofill(*autofill_fields):
"""
Decorator to automatically fill in extra useful fields
that aren't stored in the db.
"""
def wrap( reader ):
def wrapped_reader( *args, **kw ):
rec = reader( *args, **kw )
if rec is not None:
for field in autofill_fi... | [
"def",
"autofill",
"(",
"*",
"autofill_fields",
")",
":",
"def",
"wrap",
"(",
"reader",
")",
":",
"def",
"wrapped_reader",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"rec",
"=",
"reader",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"if",
... | Decorator to automatically fill in extra useful fields
that aren't stored in the db. | [
"Decorator",
"to",
"automatically",
"fill",
"in",
"extra",
"useful",
"fields",
"that",
"aren",
"t",
"stored",
"in",
"the",
"db",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L53-L71 |
230,579 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_readonly_instance | def get_readonly_instance(cls, working_dir, expected_snapshots={}):
"""
Get a read-only handle to the blockstack-specific name db.
Multiple read-only handles may exist.
Returns the handle on success.
Returns None on error
"""
import virtualchain_hooks
db_... | python | def get_readonly_instance(cls, working_dir, expected_snapshots={}):
"""
Get a read-only handle to the blockstack-specific name db.
Multiple read-only handles may exist.
Returns the handle on success.
Returns None on error
"""
import virtualchain_hooks
db_... | [
"def",
"get_readonly_instance",
"(",
"cls",
",",
"working_dir",
",",
"expected_snapshots",
"=",
"{",
"}",
")",
":",
"import",
"virtualchain_hooks",
"db_path",
"=",
"virtualchain",
".",
"get_db_filename",
"(",
"virtualchain_hooks",
",",
"working_dir",
")",
"db",
"=... | Get a read-only handle to the blockstack-specific name db.
Multiple read-only handles may exist.
Returns the handle on success.
Returns None on error | [
"Get",
"a",
"read",
"-",
"only",
"handle",
"to",
"the",
"blockstack",
"-",
"specific",
"name",
"db",
".",
"Multiple",
"read",
"-",
"only",
"handles",
"may",
"exist",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L133-L149 |
230,580 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.make_opfields | def make_opfields( cls ):
"""
Calculate the virtulachain-required opfields dict.
"""
# construct fields
opfields = {}
for opname in SERIALIZE_FIELDS.keys():
opcode = NAME_OPCODES[opname]
opfields[opcode] = SERIALIZE_FIELDS[opname]
return ... | python | def make_opfields( cls ):
"""
Calculate the virtulachain-required opfields dict.
"""
# construct fields
opfields = {}
for opname in SERIALIZE_FIELDS.keys():
opcode = NAME_OPCODES[opname]
opfields[opcode] = SERIALIZE_FIELDS[opname]
return ... | [
"def",
"make_opfields",
"(",
"cls",
")",
":",
"# construct fields ",
"opfields",
"=",
"{",
"}",
"for",
"opname",
"in",
"SERIALIZE_FIELDS",
".",
"keys",
"(",
")",
":",
"opcode",
"=",
"NAME_OPCODES",
"[",
"opname",
"]",
"opfields",
"[",
"opcode",
"]",
"=",
... | Calculate the virtulachain-required opfields dict. | [
"Calculate",
"the",
"virtulachain",
"-",
"required",
"opfields",
"dict",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L261-L271 |
230,581 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_state_paths | def get_state_paths(cls, impl, working_dir):
"""
Get the paths to the relevant db files to back up
"""
return super(BlockstackDB, cls).get_state_paths(impl, working_dir) + [
os.path.join(working_dir, 'atlas.db'),
os.path.join(working_dir, 'subdomains.db')... | python | def get_state_paths(cls, impl, working_dir):
"""
Get the paths to the relevant db files to back up
"""
return super(BlockstackDB, cls).get_state_paths(impl, working_dir) + [
os.path.join(working_dir, 'atlas.db'),
os.path.join(working_dir, 'subdomains.db')... | [
"def",
"get_state_paths",
"(",
"cls",
",",
"impl",
",",
"working_dir",
")",
":",
"return",
"super",
"(",
"BlockstackDB",
",",
"cls",
")",
".",
"get_state_paths",
"(",
"impl",
",",
"working_dir",
")",
"+",
"[",
"os",
".",
"path",
".",
"join",
"(",
"work... | Get the paths to the relevant db files to back up | [
"Get",
"the",
"paths",
"to",
"the",
"relevant",
"db",
"files",
"to",
"back",
"up"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L275-L283 |
230,582 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.close | def close( self ):
"""
Close the db and release memory
"""
if self.db is not None:
self.db.commit()
self.db.close()
self.db = None
return | python | def close( self ):
"""
Close the db and release memory
"""
if self.db is not None:
self.db.commit()
self.db.close()
self.db = None
return | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"db",
"is",
"not",
"None",
":",
"self",
".",
"db",
".",
"commit",
"(",
")",
"self",
".",
"db",
".",
"close",
"(",
")",
"self",
".",
"db",
"=",
"None",
"return"
] | Close the db and release memory | [
"Close",
"the",
"db",
"and",
"release",
"memory"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L293-L302 |
230,583 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_import_keychain_path | def get_import_keychain_path( cls, keychain_dir, namespace_id ):
"""
Get the path to the import keychain
"""
cached_keychain = os.path.join( keychain_dir, "{}.keychain".format(namespace_id) )
return cached_keychain | python | def get_import_keychain_path( cls, keychain_dir, namespace_id ):
"""
Get the path to the import keychain
"""
cached_keychain = os.path.join( keychain_dir, "{}.keychain".format(namespace_id) )
return cached_keychain | [
"def",
"get_import_keychain_path",
"(",
"cls",
",",
"keychain_dir",
",",
"namespace_id",
")",
":",
"cached_keychain",
"=",
"os",
".",
"path",
".",
"join",
"(",
"keychain_dir",
",",
"\"{}.keychain\"",
".",
"format",
"(",
"namespace_id",
")",
")",
"return",
"cac... | Get the path to the import keychain | [
"Get",
"the",
"path",
"to",
"the",
"import",
"keychain"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L341-L346 |
230,584 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.build_import_keychain | def build_import_keychain( cls, keychain_dir, namespace_id, pubkey_hex ):
"""
Generate all possible NAME_IMPORT addresses from the NAMESPACE_REVEAL public key
"""
pubkey_addr = virtualchain.BitcoinPublicKey(str(pubkey_hex)).address()
# do we have a cached one on disk?
c... | python | def build_import_keychain( cls, keychain_dir, namespace_id, pubkey_hex ):
"""
Generate all possible NAME_IMPORT addresses from the NAMESPACE_REVEAL public key
"""
pubkey_addr = virtualchain.BitcoinPublicKey(str(pubkey_hex)).address()
# do we have a cached one on disk?
c... | [
"def",
"build_import_keychain",
"(",
"cls",
",",
"keychain_dir",
",",
"namespace_id",
",",
"pubkey_hex",
")",
":",
"pubkey_addr",
"=",
"virtualchain",
".",
"BitcoinPublicKey",
"(",
"str",
"(",
"pubkey_hex",
")",
")",
".",
"address",
"(",
")",
"# do we have a cac... | Generate all possible NAME_IMPORT addresses from the NAMESPACE_REVEAL public key | [
"Generate",
"all",
"possible",
"NAME_IMPORT",
"addresses",
"from",
"the",
"NAMESPACE_REVEAL",
"public",
"key"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L350-L413 |
230,585 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.load_import_keychain | def load_import_keychain( cls, working_dir, namespace_id ):
"""
Get an import keychain from disk.
Return None if it doesn't exist.
"""
# do we have a cached one on disk?
cached_keychain = os.path.join(working_dir, "%s.keychain" % namespace_id)
if os.path.ex... | python | def load_import_keychain( cls, working_dir, namespace_id ):
"""
Get an import keychain from disk.
Return None if it doesn't exist.
"""
# do we have a cached one on disk?
cached_keychain = os.path.join(working_dir, "%s.keychain" % namespace_id)
if os.path.ex... | [
"def",
"load_import_keychain",
"(",
"cls",
",",
"working_dir",
",",
"namespace_id",
")",
":",
"# do we have a cached one on disk?",
"cached_keychain",
"=",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"\"%s.keychain\"",
"%",
"namespace_id",
")",
"if",
... | Get an import keychain from disk.
Return None if it doesn't exist. | [
"Get",
"an",
"import",
"keychain",
"from",
"disk",
".",
"Return",
"None",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L417-L447 |
230,586 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.commit_finished | def commit_finished( self, block_id ):
"""
Called when the block is finished.
Commits all data.
"""
self.db.commit()
# NOTE: tokens vest for the *next* block in order to make the immediately usable
assert block_id+1 in self.vesting, 'BUG: failed to vest at {}'.f... | python | def commit_finished( self, block_id ):
"""
Called when the block is finished.
Commits all data.
"""
self.db.commit()
# NOTE: tokens vest for the *next* block in order to make the immediately usable
assert block_id+1 in self.vesting, 'BUG: failed to vest at {}'.f... | [
"def",
"commit_finished",
"(",
"self",
",",
"block_id",
")",
":",
"self",
".",
"db",
".",
"commit",
"(",
")",
"# NOTE: tokens vest for the *next* block in order to make the immediately usable",
"assert",
"block_id",
"+",
"1",
"in",
"self",
".",
"vesting",
",",
"'BUG... | Called when the block is finished.
Commits all data. | [
"Called",
"when",
"the",
"block",
"is",
"finished",
".",
"Commits",
"all",
"data",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L458-L470 |
230,587 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.log_commit | def log_commit( self, block_id, vtxindex, op, opcode, op_data ):
"""
Log a committed operation
"""
debug_op = self.sanitize_op( op_data )
if 'history' in debug_op:
del debug_op['history']
log.debug("COMMIT %s (%s) at (%s, %s) data: %s", opcode, op, block_id... | python | def log_commit( self, block_id, vtxindex, op, opcode, op_data ):
"""
Log a committed operation
"""
debug_op = self.sanitize_op( op_data )
if 'history' in debug_op:
del debug_op['history']
log.debug("COMMIT %s (%s) at (%s, %s) data: %s", opcode, op, block_id... | [
"def",
"log_commit",
"(",
"self",
",",
"block_id",
",",
"vtxindex",
",",
"op",
",",
"opcode",
",",
"op_data",
")",
":",
"debug_op",
"=",
"self",
".",
"sanitize_op",
"(",
"op_data",
")",
"if",
"'history'",
"in",
"debug_op",
":",
"del",
"debug_op",
"[",
... | Log a committed operation | [
"Log",
"a",
"committed",
"operation"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L489-L501 |
230,588 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.log_reject | def log_reject( self, block_id, vtxindex, op, op_data ):
"""
Log a rejected operation
"""
debug_op = self.sanitize_op( op_data )
if 'history' in debug_op:
del debug_op['history']
log.debug("REJECT %s at (%s, %s) data: %s", op_get_opcode_name( op ), block_id,... | python | def log_reject( self, block_id, vtxindex, op, op_data ):
"""
Log a rejected operation
"""
debug_op = self.sanitize_op( op_data )
if 'history' in debug_op:
del debug_op['history']
log.debug("REJECT %s at (%s, %s) data: %s", op_get_opcode_name( op ), block_id,... | [
"def",
"log_reject",
"(",
"self",
",",
"block_id",
",",
"vtxindex",
",",
"op",
",",
"op_data",
")",
":",
"debug_op",
"=",
"self",
".",
"sanitize_op",
"(",
"op_data",
")",
"if",
"'history'",
"in",
"debug_op",
":",
"del",
"debug_op",
"[",
"'history'",
"]",... | Log a rejected operation | [
"Log",
"a",
"rejected",
"operation"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L504-L516 |
230,589 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.sanitize_op | def sanitize_op( self, op_data ):
"""
Remove unnecessary fields for an operation, i.e. prior to committing it.
This includes any invariant tags we've added with our invariant decorators
(such as @state_create or @state_transition).
TODO: less ad-hoc way to do this
... | python | def sanitize_op( self, op_data ):
"""
Remove unnecessary fields for an operation, i.e. prior to committing it.
This includes any invariant tags we've added with our invariant decorators
(such as @state_create or @state_transition).
TODO: less ad-hoc way to do this
... | [
"def",
"sanitize_op",
"(",
"self",
",",
"op_data",
")",
":",
"op_data",
"=",
"super",
"(",
"BlockstackDB",
",",
"self",
")",
".",
"sanitize_op",
"(",
"op_data",
")",
"# remove invariant tags (i.e. added by our invariant state_* decorators)",
"to_remove",
"=",
"get_sta... | Remove unnecessary fields for an operation, i.e. prior to committing it.
This includes any invariant tags we've added with our invariant decorators
(such as @state_create or @state_transition).
TODO: less ad-hoc way to do this | [
"Remove",
"unnecessary",
"fields",
"for",
"an",
"operation",
"i",
".",
"e",
".",
"prior",
"to",
"committing",
"it",
".",
"This",
"includes",
"any",
"invariant",
"tags",
"we",
"ve",
"added",
"with",
"our",
"invariant",
"decorators",
"(",
"such",
"as"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L519-L556 |
230,590 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.put_collisions | def put_collisions( self, block_id, collisions ):
"""
Put collision state for a particular block.
Any operations checked at this block_id that collide
with the given collision state will be rejected.
"""
self.collisions[ block_id ] = copy.deepcopy( collisions ) | python | def put_collisions( self, block_id, collisions ):
"""
Put collision state for a particular block.
Any operations checked at this block_id that collide
with the given collision state will be rejected.
"""
self.collisions[ block_id ] = copy.deepcopy( collisions ) | [
"def",
"put_collisions",
"(",
"self",
",",
"block_id",
",",
"collisions",
")",
":",
"self",
".",
"collisions",
"[",
"block_id",
"]",
"=",
"copy",
".",
"deepcopy",
"(",
"collisions",
")"
] | Put collision state for a particular block.
Any operations checked at this block_id that collide
with the given collision state will be rejected. | [
"Put",
"collision",
"state",
"for",
"a",
"particular",
"block",
".",
"Any",
"operations",
"checked",
"at",
"this",
"block_id",
"that",
"collide",
"with",
"the",
"given",
"collision",
"state",
"will",
"be",
"rejected",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L625-L631 |
230,591 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_namespace | def get_namespace( self, namespace_id, include_history=True ):
"""
Given a namespace ID, get the ready namespace op for it.
Return the dict with the parameters on success.
Return None if the namespace has not yet been revealed.
"""
cur = self.db.cursor()
return ... | python | def get_namespace( self, namespace_id, include_history=True ):
"""
Given a namespace ID, get the ready namespace op for it.
Return the dict with the parameters on success.
Return None if the namespace has not yet been revealed.
"""
cur = self.db.cursor()
return ... | [
"def",
"get_namespace",
"(",
"self",
",",
"namespace_id",
",",
"include_history",
"=",
"True",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_namespace_ready",
"(",
"cur",
",",
"namespace_id",
",",
"include_history",
... | Given a namespace ID, get the ready namespace op for it.
Return the dict with the parameters on success.
Return None if the namespace has not yet been revealed. | [
"Given",
"a",
"namespace",
"ID",
"get",
"the",
"ready",
"namespace",
"op",
"for",
"it",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L705-L714 |
230,592 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_DID_name | def get_DID_name(self, did):
"""
Given a DID, get the name
Return None if not found, or if the name was revoked
Raise if the DID is invalid
"""
did = str(did)
did_info = None
try:
did_info = parse_DID(did)
assert did_info['name_type... | python | def get_DID_name(self, did):
"""
Given a DID, get the name
Return None if not found, or if the name was revoked
Raise if the DID is invalid
"""
did = str(did)
did_info = None
try:
did_info = parse_DID(did)
assert did_info['name_type... | [
"def",
"get_DID_name",
"(",
"self",
",",
"did",
")",
":",
"did",
"=",
"str",
"(",
"did",
")",
"did_info",
"=",
"None",
"try",
":",
"did_info",
"=",
"parse_DID",
"(",
"did",
")",
"assert",
"did_info",
"[",
"'name_type'",
"]",
"==",
"'name'",
"except",
... | Given a DID, get the name
Return None if not found, or if the name was revoked
Raise if the DID is invalid | [
"Given",
"a",
"DID",
"get",
"the",
"name",
"Return",
"None",
"if",
"not",
"found",
"or",
"if",
"the",
"name",
"was",
"revoked",
"Raise",
"if",
"the",
"DID",
"is",
"invalid"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L788-L849 |
230,593 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_account_tokens | def get_account_tokens(self, address):
"""
Get the list of tokens that this address owns
"""
cur = self.db.cursor()
return namedb_get_account_tokens(cur, address) | python | def get_account_tokens(self, address):
"""
Get the list of tokens that this address owns
"""
cur = self.db.cursor()
return namedb_get_account_tokens(cur, address) | [
"def",
"get_account_tokens",
"(",
"self",
",",
"address",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_account_tokens",
"(",
"cur",
",",
"address",
")"
] | Get the list of tokens that this address owns | [
"Get",
"the",
"list",
"of",
"tokens",
"that",
"this",
"address",
"owns"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L852-L857 |
230,594 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_account | def get_account(self, address, token_type):
"""
Get the state of an account for a given token type
"""
cur = self.db.cursor()
return namedb_get_account(cur, address, token_type) | python | def get_account(self, address, token_type):
"""
Get the state of an account for a given token type
"""
cur = self.db.cursor()
return namedb_get_account(cur, address, token_type) | [
"def",
"get_account",
"(",
"self",
",",
"address",
",",
"token_type",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_account",
"(",
"cur",
",",
"address",
",",
"token_type",
")"
] | Get the state of an account for a given token type | [
"Get",
"the",
"state",
"of",
"an",
"account",
"for",
"a",
"given",
"token",
"type"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L860-L865 |
230,595 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_account_balance | def get_account_balance(self, account):
"""
What's the balance of an account?
Aborts if its negative
"""
balance = namedb_get_account_balance(account)
assert isinstance(balance, (int,long)), 'BUG: account balance of {} is {} (type {})'.format(account['address'], balance, ... | python | def get_account_balance(self, account):
"""
What's the balance of an account?
Aborts if its negative
"""
balance = namedb_get_account_balance(account)
assert isinstance(balance, (int,long)), 'BUG: account balance of {} is {} (type {})'.format(account['address'], balance, ... | [
"def",
"get_account_balance",
"(",
"self",
",",
"account",
")",
":",
"balance",
"=",
"namedb_get_account_balance",
"(",
"account",
")",
"assert",
"isinstance",
"(",
"balance",
",",
"(",
"int",
",",
"long",
")",
")",
",",
"'BUG: account balance of {} is {} (type {}... | What's the balance of an account?
Aborts if its negative | [
"What",
"s",
"the",
"balance",
"of",
"an",
"account?",
"Aborts",
"if",
"its",
"negative"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L868-L875 |
230,596 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_account_history | def get_account_history(self, address, offset=None, count=None):
"""
Get the history of account transactions over a block range
Returns a dict keyed by blocks, which map to lists of account state transitions
"""
cur = self.db.cursor()
return namedb_get_account_history(cur... | python | def get_account_history(self, address, offset=None, count=None):
"""
Get the history of account transactions over a block range
Returns a dict keyed by blocks, which map to lists of account state transitions
"""
cur = self.db.cursor()
return namedb_get_account_history(cur... | [
"def",
"get_account_history",
"(",
"self",
",",
"address",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_account_history",
"(",
"cur",
",",
"address",
",",
... | Get the history of account transactions over a block range
Returns a dict keyed by blocks, which map to lists of account state transitions | [
"Get",
"the",
"history",
"of",
"account",
"transactions",
"over",
"a",
"block",
"range",
"Returns",
"a",
"dict",
"keyed",
"by",
"blocks",
"which",
"map",
"to",
"lists",
"of",
"account",
"state",
"transitions"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L893-L899 |
230,597 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_name_at | def get_name_at( self, name, block_number, include_expired=False ):
"""
Generate and return the sequence of of states a name record was in
at a particular block number.
"""
cur = self.db.cursor()
return namedb_get_name_at(cur, name, block_number, include_expired=include_e... | python | def get_name_at( self, name, block_number, include_expired=False ):
"""
Generate and return the sequence of of states a name record was in
at a particular block number.
"""
cur = self.db.cursor()
return namedb_get_name_at(cur, name, block_number, include_expired=include_e... | [
"def",
"get_name_at",
"(",
"self",
",",
"name",
",",
"block_number",
",",
"include_expired",
"=",
"False",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_name_at",
"(",
"cur",
",",
"name",
",",
"block_number",
","... | Generate and return the sequence of of states a name record was in
at a particular block number. | [
"Generate",
"and",
"return",
"the",
"sequence",
"of",
"of",
"states",
"a",
"name",
"record",
"was",
"in",
"at",
"a",
"particular",
"block",
"number",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L912-L918 |
230,598 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_namespace_at | def get_namespace_at( self, namespace_id, block_number ):
"""
Generate and return the sequence of states a namespace record was in
at a particular block number.
Includes expired namespaces by default.
"""
cur = self.db.cursor()
return namedb_get_namespace_at(cur... | python | def get_namespace_at( self, namespace_id, block_number ):
"""
Generate and return the sequence of states a namespace record was in
at a particular block number.
Includes expired namespaces by default.
"""
cur = self.db.cursor()
return namedb_get_namespace_at(cur... | [
"def",
"get_namespace_at",
"(",
"self",
",",
"namespace_id",
",",
"block_number",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_namespace_at",
"(",
"cur",
",",
"namespace_id",
",",
"block_number",
",",
"include_expired... | Generate and return the sequence of states a namespace record was in
at a particular block number.
Includes expired namespaces by default. | [
"Generate",
"and",
"return",
"the",
"sequence",
"of",
"states",
"a",
"namespace",
"record",
"was",
"in",
"at",
"a",
"particular",
"block",
"number",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L921-L929 |
230,599 | blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | BlockstackDB.get_account_at | def get_account_at(self, address, block_number):
"""
Get the sequence of states an account was in at a given block.
Returns a list of states
"""
cur = self.db.cursor()
return namedb_get_account_at(cur, address, block_number) | python | def get_account_at(self, address, block_number):
"""
Get the sequence of states an account was in at a given block.
Returns a list of states
"""
cur = self.db.cursor()
return namedb_get_account_at(cur, address, block_number) | [
"def",
"get_account_at",
"(",
"self",
",",
"address",
",",
"block_number",
")",
":",
"cur",
"=",
"self",
".",
"db",
".",
"cursor",
"(",
")",
"return",
"namedb_get_account_at",
"(",
"cur",
",",
"address",
",",
"block_number",
")"
] | Get the sequence of states an account was in at a given block.
Returns a list of states | [
"Get",
"the",
"sequence",
"of",
"states",
"an",
"account",
"was",
"in",
"at",
"a",
"given",
"block",
".",
"Returns",
"a",
"list",
"of",
"states"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L932-L938 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.