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 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
244,300 | blockstack/blockstack-core | blockstack/lib/fast_sync.py | fast_sync_snapshot_decompress | def fast_sync_snapshot_decompress( snapshot_path, output_dir ):
"""
Given the path to a snapshot file, decompress it and
write its contents to the given output directory
Return {'status': True} on success
Return {'error': ...} on failure
"""
if not tarfile.is_tarfile(snapshot_path):
... | python | def fast_sync_snapshot_decompress( snapshot_path, output_dir ):
if not tarfile.is_tarfile(snapshot_path):
return {'error': 'Not a tarfile-compatible archive: {}'.format(snapshot_path)}
if not os.path.exists(output_dir):
os.makedirs(output_dir)
with tarfile.TarFile.bz2open(snapshot_path, 'r... | [
"def",
"fast_sync_snapshot_decompress",
"(",
"snapshot_path",
",",
"output_dir",
")",
":",
"if",
"not",
"tarfile",
".",
"is_tarfile",
"(",
"snapshot_path",
")",
":",
"return",
"{",
"'error'",
":",
"'Not a tarfile-compatible archive: {}'",
".",
"format",
"(",
"snapsh... | Given the path to a snapshot file, decompress it and
write its contents to the given output directory
Return {'status': True} on success
Return {'error': ...} on failure | [
"Given",
"the",
"path",
"to",
"a",
"snapshot",
"file",
"decompress",
"it",
"and",
"write",
"its",
"contents",
"to",
"the",
"given",
"output",
"directory"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L223-L240 |
244,301 | blockstack/blockstack-core | blockstack/lib/fast_sync.py | fast_sync_fetch | def fast_sync_fetch(working_dir, import_url):
"""
Get the data for an import snapshot.
Store it to a temporary path
Return the path on success
Return None on error
"""
try:
fd, tmppath = tempfile.mkstemp(prefix='.blockstack-fast-sync-', dir=working_dir)
except Exception, e:
... | python | def fast_sync_fetch(working_dir, import_url):
try:
fd, tmppath = tempfile.mkstemp(prefix='.blockstack-fast-sync-', dir=working_dir)
except Exception, e:
log.exception(e)
return None
log.debug("Fetch {} to {}...".format(import_url, tmppath))
try:
path, headers = urll... | [
"def",
"fast_sync_fetch",
"(",
"working_dir",
",",
"import_url",
")",
":",
"try",
":",
"fd",
",",
"tmppath",
"=",
"tempfile",
".",
"mkstemp",
"(",
"prefix",
"=",
"'.blockstack-fast-sync-'",
",",
"dir",
"=",
"working_dir",
")",
"except",
"Exception",
",",
"e"... | Get the data for an import snapshot.
Store it to a temporary path
Return the path on success
Return None on error | [
"Get",
"the",
"data",
"for",
"an",
"import",
"snapshot",
".",
"Store",
"it",
"to",
"a",
"temporary",
"path",
"Return",
"the",
"path",
"on",
"success",
"Return",
"None",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L410-L433 |
244,302 | blockstack/blockstack-core | blockstack/lib/nameset/__init__.py | state_check_collisions | def state_check_collisions( state_engine, nameop, history_id_key, block_id, checked_ops, collision_checker ):
"""
See that there are no state-creating or state-preordering collisions at this block, for this history ID.
Return True if collided; False if not
"""
# verify no collisions against already... | python | def state_check_collisions( state_engine, nameop, history_id_key, block_id, checked_ops, collision_checker ):
# verify no collisions against already-accepted names
collision_check = getattr( state_engine, collision_checker, None )
try:
assert collision_check is not None, "Collision-checker '%s' not ... | [
"def",
"state_check_collisions",
"(",
"state_engine",
",",
"nameop",
",",
"history_id_key",
",",
"block_id",
",",
"checked_ops",
",",
"collision_checker",
")",
":",
"# verify no collisions against already-accepted names",
"collision_check",
"=",
"getattr",
"(",
"state_engin... | See that there are no state-creating or state-preordering collisions at this block, for this history ID.
Return True if collided; False if not | [
"See",
"that",
"there",
"are",
"no",
"state",
"-",
"creating",
"or",
"state",
"-",
"preordering",
"collisions",
"at",
"this",
"block",
"for",
"this",
"history",
"ID",
".",
"Return",
"True",
"if",
"collided",
";",
"False",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/__init__.py#L100-L119 |
244,303 | blockstack/blockstack-core | blockstack/lib/nameset/__init__.py | state_create_is_valid | def state_create_is_valid( nameop ):
"""
Is a nameop a valid state-preorder operation?
"""
assert '__state_create__' in nameop, "Not tagged with @state_create"
assert nameop['__state_create__'], "BUG: tagged False by @state_create"
assert '__preorder__' in nameop, "No preorder"
assert '__tab... | python | def state_create_is_valid( nameop ):
assert '__state_create__' in nameop, "Not tagged with @state_create"
assert nameop['__state_create__'], "BUG: tagged False by @state_create"
assert '__preorder__' in nameop, "No preorder"
assert '__table__' in nameop, "No table given"
assert '__history_id_key__' ... | [
"def",
"state_create_is_valid",
"(",
"nameop",
")",
":",
"assert",
"'__state_create__'",
"in",
"nameop",
",",
"\"Not tagged with @state_create\"",
"assert",
"nameop",
"[",
"'__state_create__'",
"]",
",",
"\"BUG: tagged False by @state_create\"",
"assert",
"'__preorder__'",
... | Is a nameop a valid state-preorder operation? | [
"Is",
"a",
"nameop",
"a",
"valid",
"state",
"-",
"preorder",
"operation?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/__init__.py#L348-L360 |
244,304 | blockstack/blockstack-core | blockstack/lib/nameset/__init__.py | state_transition_is_valid | def state_transition_is_valid( nameop ):
"""
Is this a valid state transition?
"""
assert '__state_transition__' in nameop, "Not tagged with @state_transition"
assert nameop['__state_transition__'], "BUG: @state_transition tagged False"
assert '__history_id_key__' in nameop, "Missing __history_i... | python | def state_transition_is_valid( nameop ):
assert '__state_transition__' in nameop, "Not tagged with @state_transition"
assert nameop['__state_transition__'], "BUG: @state_transition tagged False"
assert '__history_id_key__' in nameop, "Missing __history_id_key__"
history_id_key = nameop['__history_id_key... | [
"def",
"state_transition_is_valid",
"(",
"nameop",
")",
":",
"assert",
"'__state_transition__'",
"in",
"nameop",
",",
"\"Not tagged with @state_transition\"",
"assert",
"nameop",
"[",
"'__state_transition__'",
"]",
",",
"\"BUG: @state_transition tagged False\"",
"assert",
"'_... | Is this a valid state transition? | [
"Is",
"this",
"a",
"valid",
"state",
"transition?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/__init__.py#L391-L404 |
244,305 | blockstack/blockstack-core | blockstack/lib/storage/crawl.py | _read_atlas_zonefile | def _read_atlas_zonefile( zonefile_path, zonefile_hash ):
"""
Read and verify an atlas zone file
"""
with open(zonefile_path, "rb") as f:
data = f.read()
# sanity check
if zonefile_hash is not None:
if not verify_zonefile( data, zonefile_hash ):
log.debug("Corrupt ... | python | def _read_atlas_zonefile( zonefile_path, zonefile_hash ):
with open(zonefile_path, "rb") as f:
data = f.read()
# sanity check
if zonefile_hash is not None:
if not verify_zonefile( data, zonefile_hash ):
log.debug("Corrupt zonefile '%s'" % zonefile_hash)
return None
... | [
"def",
"_read_atlas_zonefile",
"(",
"zonefile_path",
",",
"zonefile_hash",
")",
":",
"with",
"open",
"(",
"zonefile_path",
",",
"\"rb\"",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
"# sanity check ",
"if",
"zonefile_hash",
"is",
"not",
"... | Read and verify an atlas zone file | [
"Read",
"and",
"verify",
"an",
"atlas",
"zone",
"file"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/crawl.py#L37-L51 |
244,306 | blockstack/blockstack-core | blockstack/lib/storage/crawl.py | get_atlas_zonefile_data | def get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=True ):
"""
Get a serialized cached zonefile from local disk
Return None if not found
"""
zonefile_path = atlas_zonefile_path(zonefile_dir, zonefile_hash)
zonefile_path_legacy = atlas_zonefile_path_legacy(zonefile_dir, zonefile_has... | python | def get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=True ):
zonefile_path = atlas_zonefile_path(zonefile_dir, zonefile_hash)
zonefile_path_legacy = atlas_zonefile_path_legacy(zonefile_dir, zonefile_hash)
for zfp in [zonefile_path, zonefile_path_legacy]:
if not os.path.exists( zfp ):
... | [
"def",
"get_atlas_zonefile_data",
"(",
"zonefile_hash",
",",
"zonefile_dir",
",",
"check",
"=",
"True",
")",
":",
"zonefile_path",
"=",
"atlas_zonefile_path",
"(",
"zonefile_dir",
",",
"zonefile_hash",
")",
"zonefile_path_legacy",
"=",
"atlas_zonefile_path_legacy",
"(",... | Get a serialized cached zonefile from local disk
Return None if not found | [
"Get",
"a",
"serialized",
"cached",
"zonefile",
"from",
"local",
"disk",
"Return",
"None",
"if",
"not",
"found"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/crawl.py#L54-L75 |
244,307 | blockstack/blockstack-core | blockstack/lib/storage/crawl.py | store_atlas_zonefile_data | def store_atlas_zonefile_data(zonefile_data, zonefile_dir, fsync=True):
"""
Store a validated zonefile.
zonefile_data should be a dict.
The caller should first authenticate the zonefile.
Return True on success
Return False on error
"""
if not os.path.exists(zonefile_dir):
os.make... | python | def store_atlas_zonefile_data(zonefile_data, zonefile_dir, fsync=True):
if not os.path.exists(zonefile_dir):
os.makedirs(zonefile_dir, 0700 )
zonefile_hash = get_zonefile_data_hash( zonefile_data )
# only store to the latest supported directory
zonefile_path = atlas_zonefile_path( zonefile... | [
"def",
"store_atlas_zonefile_data",
"(",
"zonefile_data",
",",
"zonefile_dir",
",",
"fsync",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"zonefile_dir",
")",
":",
"os",
".",
"makedirs",
"(",
"zonefile_dir",
",",
"0700",
")",
... | Store a validated zonefile.
zonefile_data should be a dict.
The caller should first authenticate the zonefile.
Return True on success
Return False on error | [
"Store",
"a",
"validated",
"zonefile",
".",
"zonefile_data",
"should",
"be",
"a",
"dict",
".",
"The",
"caller",
"should",
"first",
"authenticate",
"the",
"zonefile",
".",
"Return",
"True",
"on",
"success",
"Return",
"False",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/crawl.py#L146-L181 |
244,308 | blockstack/blockstack-core | blockstack/lib/storage/crawl.py | remove_atlas_zonefile_data | def remove_atlas_zonefile_data( zonefile_hash, zonefile_dir ):
"""
Remove a cached zonefile.
Idempotent; returns True if deleted or it didn't exist.
Returns False on error
"""
if not os.path.exists(zonefile_dir):
return True
zonefile_path = atlas_zonefile_path( zonefile_dir, zonefil... | python | def remove_atlas_zonefile_data( zonefile_hash, zonefile_dir ):
if not os.path.exists(zonefile_dir):
return True
zonefile_path = atlas_zonefile_path( zonefile_dir, zonefile_hash )
zonefile_path_legacy = atlas_zonefile_path_legacy( zonefile_dir, zonefile_hash )
for zfp in [zonefile_path, zonefil... | [
"def",
"remove_atlas_zonefile_data",
"(",
"zonefile_hash",
",",
"zonefile_dir",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"zonefile_dir",
")",
":",
"return",
"True",
"zonefile_path",
"=",
"atlas_zonefile_path",
"(",
"zonefile_dir",
",",
"zone... | Remove a cached zonefile.
Idempotent; returns True if deleted or it didn't exist.
Returns False on error | [
"Remove",
"a",
"cached",
"zonefile",
".",
"Idempotent",
";",
"returns",
"True",
"if",
"deleted",
"or",
"it",
"didn",
"t",
"exist",
".",
"Returns",
"False",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/crawl.py#L184-L205 |
244,309 | blockstack/blockstack-core | blockstack/lib/storage/crawl.py | add_atlas_zonefile_data | def add_atlas_zonefile_data(zonefile_text, zonefile_dir, fsync=True):
"""
Add a zone file to the atlas zonefiles
Return True on success
Return False on error
"""
rc = store_atlas_zonefile_data(zonefile_text, zonefile_dir, fsync=fsync)
if not rc:
zonefile_hash = get_zonefile_data_has... | python | def add_atlas_zonefile_data(zonefile_text, zonefile_dir, fsync=True):
rc = store_atlas_zonefile_data(zonefile_text, zonefile_dir, fsync=fsync)
if not rc:
zonefile_hash = get_zonefile_data_hash( zonefile_text )
log.error("Failed to save zonefile {}".format(zonefile_hash))
rc = False
... | [
"def",
"add_atlas_zonefile_data",
"(",
"zonefile_text",
",",
"zonefile_dir",
",",
"fsync",
"=",
"True",
")",
":",
"rc",
"=",
"store_atlas_zonefile_data",
"(",
"zonefile_text",
",",
"zonefile_dir",
",",
"fsync",
"=",
"fsync",
")",
"if",
"not",
"rc",
":",
"zonef... | Add a zone file to the atlas zonefiles
Return True on success
Return False on error | [
"Add",
"a",
"zone",
"file",
"to",
"the",
"atlas",
"zonefiles",
"Return",
"True",
"on",
"success",
"Return",
"False",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/storage/crawl.py#L208-L221 |
244,310 | blockstack/blockstack-core | blockstack/lib/operations/transfer.py | transfer_sanity_check | def transfer_sanity_check( name, consensus_hash ):
"""
Verify that data for a transfer is valid.
Return True on success
Raise Exception on error
"""
if name is not None and (not is_b40( name ) or "+" in name or name.count(".") > 1):
raise Exception("Name '%s' has non-base-38 characters" ... | python | def transfer_sanity_check( name, consensus_hash ):
if name is not None and (not is_b40( name ) or "+" in name or name.count(".") > 1):
raise Exception("Name '%s' has non-base-38 characters" % name)
# without the scheme, name must be 37 bytes
if name is not None and (len(name) > LENGTHS['blockch... | [
"def",
"transfer_sanity_check",
"(",
"name",
",",
"consensus_hash",
")",
":",
"if",
"name",
"is",
"not",
"None",
"and",
"(",
"not",
"is_b40",
"(",
"name",
")",
"or",
"\"+\"",
"in",
"name",
"or",
"name",
".",
"count",
"(",
"\".\"",
")",
">",
"1",
")",... | Verify that data for a transfer is valid.
Return True on success
Raise Exception on error | [
"Verify",
"that",
"data",
"for",
"a",
"transfer",
"is",
"valid",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/transfer.py#L70-L84 |
244,311 | blockstack/blockstack-core | blockstack/lib/operations/transfer.py | find_transfer_consensus_hash | def find_transfer_consensus_hash( name_rec, block_id, vtxindex, nameop_consensus_hash ):
"""
Given a name record, find the last consensus hash set by a non-NAME_TRANSFER operation.
@name_rec is the current name record, before this NAME_TRANSFER.
@block_id is the current block height.
@vtxindex is t... | python | def find_transfer_consensus_hash( name_rec, block_id, vtxindex, nameop_consensus_hash ):
# work backwards from the last block
for historic_block_number in reversed(sorted(name_rec['history'].keys())):
for historic_state in reversed(name_rec['history'][historic_block_number]):
if historic_sta... | [
"def",
"find_transfer_consensus_hash",
"(",
"name_rec",
",",
"block_id",
",",
"vtxindex",
",",
"nameop_consensus_hash",
")",
":",
"# work backwards from the last block",
"for",
"historic_block_number",
"in",
"reversed",
"(",
"sorted",
"(",
"name_rec",
"[",
"'history'",
... | Given a name record, find the last consensus hash set by a non-NAME_TRANSFER operation.
@name_rec is the current name record, before this NAME_TRANSFER.
@block_id is the current block height.
@vtxindex is the relative index of this transaction in this block.
@nameop_consensus_hash is the consensus hash... | [
"Given",
"a",
"name",
"record",
"find",
"the",
"last",
"consensus",
"hash",
"set",
"by",
"a",
"non",
"-",
"NAME_TRANSFER",
"operation",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/transfer.py#L87-L146 |
244,312 | blockstack/blockstack-core | blockstack/lib/operations/transfer.py | canonicalize | def canonicalize(parsed_op):
"""
Get the "canonical form" of this operation, putting it into a form where it can be serialized
to form a consensus hash. This method is meant to preserve compatibility across blockstackd releases.
For NAME_TRANSFER, this means:
* add 'keep_data' flag
"""
ass... | python | def canonicalize(parsed_op):
assert 'op' in parsed_op
assert len(parsed_op['op']) == 2
if parsed_op['op'][1] == TRANSFER_KEEP_DATA:
parsed_op['keep_data'] = True
elif parsed_op['op'][1] == TRANSFER_REMOVE_DATA:
parsed_op['keep_data'] = False
else:
raise ValueError("Invalid o... | [
"def",
"canonicalize",
"(",
"parsed_op",
")",
":",
"assert",
"'op'",
"in",
"parsed_op",
"assert",
"len",
"(",
"parsed_op",
"[",
"'op'",
"]",
")",
"==",
"2",
"if",
"parsed_op",
"[",
"'op'",
"]",
"[",
"1",
"]",
"==",
"TRANSFER_KEEP_DATA",
":",
"parsed_op",... | Get the "canonical form" of this operation, putting it into a form where it can be serialized
to form a consensus hash. This method is meant to preserve compatibility across blockstackd releases.
For NAME_TRANSFER, this means:
* add 'keep_data' flag | [
"Get",
"the",
"canonical",
"form",
"of",
"this",
"operation",
"putting",
"it",
"into",
"a",
"form",
"where",
"it",
"can",
"be",
"serialized",
"to",
"form",
"a",
"consensus",
"hash",
".",
"This",
"method",
"is",
"meant",
"to",
"preserve",
"compatibility",
"... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/transfer.py#L405-L423 |
244,313 | blockstack/blockstack-core | blockstack/blockstackd.py | get_bitcoind | def get_bitcoind( new_bitcoind_opts=None, reset=False, new=False ):
"""
Get or instantiate our bitcoind client.
Optionally re-set the bitcoind options.
"""
global bitcoind
if reset:
bitcoind = None
elif not new and bitcoind is not None:
return bitcoind
if new or bitcoind is None:... | python | def get_bitcoind( new_bitcoind_opts=None, reset=False, new=False ):
global bitcoind
if reset:
bitcoind = None
elif not new and bitcoind is not None:
return bitcoind
if new or bitcoind is None:
if new_bitcoind_opts is not None:
set_bitcoin_opts( new_bitcoind_opts )
bitco... | [
"def",
"get_bitcoind",
"(",
"new_bitcoind_opts",
"=",
"None",
",",
"reset",
"=",
"False",
",",
"new",
"=",
"False",
")",
":",
"global",
"bitcoind",
"if",
"reset",
":",
"bitcoind",
"=",
"None",
"elif",
"not",
"new",
"and",
"bitcoind",
"is",
"not",
"None",... | Get or instantiate our bitcoind client.
Optionally re-set the bitcoind options. | [
"Get",
"or",
"instantiate",
"our",
"bitcoind",
"client",
".",
"Optionally",
"re",
"-",
"set",
"the",
"bitcoind",
"options",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L95-L133 |
244,314 | blockstack/blockstack-core | blockstack/blockstackd.py | get_pidfile_path | def get_pidfile_path(working_dir):
"""
Get the PID file path.
"""
pid_filename = virtualchain_hooks.get_virtual_chain_name() + ".pid"
return os.path.join( working_dir, pid_filename ) | python | def get_pidfile_path(working_dir):
pid_filename = virtualchain_hooks.get_virtual_chain_name() + ".pid"
return os.path.join( working_dir, pid_filename ) | [
"def",
"get_pidfile_path",
"(",
"working_dir",
")",
":",
"pid_filename",
"=",
"virtualchain_hooks",
".",
"get_virtual_chain_name",
"(",
")",
"+",
"\".pid\"",
"return",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"pid_filename",
")"
] | Get the PID file path. | [
"Get",
"the",
"PID",
"file",
"path",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L136-L141 |
244,315 | blockstack/blockstack-core | blockstack/blockstackd.py | put_pidfile | def put_pidfile( pidfile_path, pid ):
"""
Put a PID into a pidfile
"""
with open( pidfile_path, "w" ) as f:
f.write("%s" % pid)
os.fsync(f.fileno())
return | python | def put_pidfile( pidfile_path, pid ):
with open( pidfile_path, "w" ) as f:
f.write("%s" % pid)
os.fsync(f.fileno())
return | [
"def",
"put_pidfile",
"(",
"pidfile_path",
",",
"pid",
")",
":",
"with",
"open",
"(",
"pidfile_path",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"\"%s\"",
"%",
"pid",
")",
"os",
".",
"fsync",
"(",
"f",
".",
"fileno",
"(",
")",
")"... | Put a PID into a pidfile | [
"Put",
"a",
"PID",
"into",
"a",
"pidfile"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L144-L152 |
244,316 | 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):
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 |
244,317 | 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):
bitcoind_session = get_bitcoind(new=True)
assert bitcoind_session is not None
first_block = None
last_block = None
wait = 1.0
while last_block is None and is_running():
first_block, last_block = virtualchain.get_index_range('bitcoin', bitcoind_session,... | [
"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 |
244,318 | 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 ):
rpc_srv = BlockstackdRPCServer( working_dir, port, subdomain_index=subdomain_index )
log.debug("Starting RPC on port {}".format(port))
if thread:
rpc_srv.start()
return rpc_srv | [
"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 |
244,319 | 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):
rpc_srv = server_state['rpc']
if rpc_srv is not None:
rpc_srv.cache_flush()
rpc_srv.set_last_index_time(finish_time) | [
"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 |
244,320 | 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):
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")
server_state['rpc'] = None | [
"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 |
244,321 | 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():
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 joined") | [
"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 |
244,322 | 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):
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 |
244,323 | 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):
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")
server_state['api'] = None | [
"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 |
244,324 | 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):
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, blockstack_opts['atlas_seeds'].split(","))
... | [
"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 |
244,325 | 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):
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
except:
return None | [
"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 |
244,326 | 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):
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 server, either way.
return False
try:
os.kill(... | [
"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 |
244,327 | 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 ):
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 = True
break
pid = read_pid_fi... | [
"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 |
244,328 | 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):
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']
genesis_block = None
genesis_block_stages = None
if module_path:
lo... | [
"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 |
244,329 | 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):
if not is_genesis_block_instantiated():
# default genesis block
genesis_block_load()
blockstack_opts = get_blockstack_opts()
blockstack_api_opts = get_blockstack... | [
"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 |
244,330 | 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):
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 file
try:
if os.path.exists(server_state['pid_file']):
... | [
"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 |
244,331 | 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):
global rpc_server
global api_server
indexer_log_path = get_logfile_path(working_dir)
logfile = None
if not foreground:
... | [
"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 |
244,332 | 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):
# 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_configuration(working_dir)
if node_config is None:
sys.exit(1)
log.d... | [
"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 |
244,333 | 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):
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 |
244,334 | 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={}):
db = BlockstackDB.get_readwrite_instance(trusted_working_dir)
consensus_impl = virtualchain_hooks
return virtualchain.state_engine_verify(trusted_consensu... | [
"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 |
244,335 | 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 ):
special_flags = {
'--debug': {
'arg': False,
'envar': 'BLOCKSTACK_DEBUG',
'exec': True,
},
'--verbose': {
'arg': False,
'envar': 'BLOCKSTACK_DEBUG',
'exec': True,
},
'--t... | [
"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 |
244,336 | 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 ):
# use snapshots?
snapshots_path = os.path.expanduser(snapshots_path)
expected_snapshots = {}
# legacy chainstate?
try:
with open(snapshots_path, "r") as f:
snapshots_json = f.read()
snapshots_data = json.loads(snaps... | [
"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 |
244,337 | 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):
signing_keys = GENESIS_BLOCK_SIGNING_KEYS
if genesis_block_path is not None:
# alternative genesis block
genesis_block_load(genesis_block_path)
if key_id is not None:
# alternative signing key
gpg2_path = ... | [
"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 |
244,338 | 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):
db = get_db_state(working_dir)
bitcoind_session = get_bitcoind(new=True)
assert bitcoind_session is not None
_, current_block = virtualchain.get_index_range('bitcoin', bitcoind_session, virtualchain_hooks, working_dir)
assert current_block, 'Failed to connect to bit... | [
"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 |
244,339 | 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):
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)
if local_current_block <= recovery_end_block:
... | [
"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 |
244,340 | 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):
resp = {
'status': True,
'indexing': config.is_indexing(self.working_dir),
'lastblock': virtualchain_hooks.get_last_block(self.working_dir),
}
resp.update(kw)
resp.update(method_resp)
if ... | [
"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 |
244,341 | 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):
name = str(name_record['name'])
name_record = self.sanitize_rec(name_record)
namespace_id = get_namespace_from_name(name)
namespace_record = db.get_namespace(namespace_id, include_history=False)
if namespace_record is None:
... | [
"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 |
244,342 | 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):
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}
return did_info | [
"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 |
244,343 | 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):
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)
else:
return {'error': 'Invalid name or subdomain', 'htt... | [
"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 |
244,344 | 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):
if not isinstance(did, (str,unicode)):
return {'error': 'Invalid DID: not a string', 'http_status': 400}
try:
did_info = parse_DID(did)
except:
return {'error': 'Invalid DID', 'http_status': 400}
res = N... | [
"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 |
244,345 | 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):
if not check_block(block_id):
return {'error': 'Invalid block height', 'http_status': 400}
if not check_offset(offset):
return {'error': 'Invalid offset', 'http_status': 400}
if not check_count(co... | [
"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 |
244,346 | 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 ):
if not check_block(block_id):
return {'error': 'Invalid block height', 'http_status': 400}
db = get_db_state(self.working_dir)
ops_hash = db.get_block_ops_hash( block_id )
db.close()
return self.succe... | [
"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 |
244,347 | 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):
cached_bitcoind_info = self.get_cached_bitcoind_info()
if cached_bitcoind_info:
return cached_bitcoind_info
bitcoind_opts = default_bitcoind_opts( virtualchain.get_config_filename(virtualchain_hooks, self.working_dir), prefix=True )
bitcoind = ge... | [
"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 |
244,348 | 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):
cached_consensus_info = self.get_cached_consensus_info()
if cached_consensus_info:
return cached_consensus_info
db = get_db_state(self.working_dir)
ch = db.get_current_consensus()
block = db.get_current_block()
db.close()
... | [
"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 |
244,349 | 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):
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
# must be b58
if is_c32_address(address):
address = c32ToB58(address)
db = get_db_state(self.working_dir)
... | [
"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 |
244,350 | 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):
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_token_type(token_type):
return {'error': 'Invalid token type', 'http_status': 400}
# must be b... | [
"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 |
244,351 | 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):
return {
'address': account_state['address'],
'type': account_state['type'],
'credit_value': '{}'.format(account_state['credit_value']),
'debit_value': '{}'.format(account_state['debit_value']),
'lock_tran... | [
"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 |
244,352 | 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):
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_token_type(token_type):
return {'error': 'Invalid token type', 'http_status': 400}
# must be b5... | [
"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 |
244,353 | 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):
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_block(block_height):
return {'error': 'Invalid start block', 'http_status': 400}
# must be b58
... | [
"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 |
244,354 | 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 ):
if type(block_id_list) != list:
return {'error': 'Invalid block heights', 'http_status': 400}
if len(block_id_list) > 32:
return {'error': 'Too many block heights', 'http_status': 400}
for bid in block_id_... | [
"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 |
244,355 | 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 ):
# check cache
atlas_zonefile_data = get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=False )
if atlas_zonefile_data is not None:
# check hash
zfh = get_zonefile_data_hash( atlas_zonefile_data )
... | [
"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 |
244,356 | 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 ):
conf = get_blockstack_opts()
if not is_atlas_enabled(conf):
return {'error': 'Not an atlas node', 'http_status': 400}
if not check_block(from_block):
return {'error': 'Invalid from_b... | [
"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 |
244,357 | 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):
# get peers
peer_list = atlas_get_live_neighbors( "%s:%s" % (peer_host, peer_port) )
if len(peer_list) > atlas_max_neighbors():
random.shuffle(peer_list)
peer_list = peer_list[:atlas_max_neighbors()]
log.info("Enqueu... | [
"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 |
244,358 | 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):
conf = get_blockstack_opts()
if not conf.get('atlas', False):
return {'error': 'Not an atlas node', 'http_status': 404}
# take the socket-given information if this is not localhost
client_host = con_info['client_hos... | [
"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 |
244,359 | 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):
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.rpc_server.shutdown() | [
"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 |
244,360 | 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):
# 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 |
244,361 | 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):
# instantiates
new_db = BlockstackDB.borrow_readwrite_instance(working_dir, -1)
BlockstackDB.release_readwrite_instance(new_db, -1)
return get_db_state(working_dir) | [
"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 |
244,362 | 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):
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:
assert 'last_creation_op' in block_op, 'QUIRK BUG: missing last_creation_op in {}'.format(op_get_opcode_name(block_op['op']))... | [
"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 |
244,363 | 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 ):
subdomain_index = server_state['subdomains']
atlas_state = server_state['atlas']
# make this usable even if we haven't explicitly configured virtualchain
impl = sys.modules[__name__]
... | [
"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 |
244,364 | 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):
if not url.startswith('http://') and not url.startswith('https://'):
return None
urlinfo = urllib2.urlparse.urlparse(url)
assert urlinfo.scheme in ['http', 'https'], 'Invalid URL scheme in {}'.format(url)
return urlinfo.scheme | [
"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 |
244,365 | 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):
if name_type not in ['name', 'subdomain']:
raise ValueError("Require 'name' or 'subdomain' for name_type")
if name_type == 'name':
address = virtualchain.address_reencode(address)
else:
# what's the current version byte?
vb = keylib.b... | [
"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 |
244,366 | 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):
from ..blockstackd import get_gc_thread
try:
self.finish_request(request, client_address)
except Exception:
self.handle_error(request, client_address)
finally:
self.shutdown_request(request)
... | [
"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 |
244,367 | 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):
# Note that this class must be mixed with another class that implements get_request()
request, client_addr = super(BoundedThreadingMixIn, self).get_request()
overload = False
with self._thread_guard:
if self._threads is not None and len(self._threads) +... | [
"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 |
244,368 | 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 ):
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()
return EPOCHS[epoch_number] | [
"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 |
244,369 | 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 ):
epoch_config = get_epoch_config( block_height )
if epoch_config['namespaces'].has_key(namespace_id):
return epoch_config['namespaces'][namespace_id]['NAMESPACE_LIFETIME_MULTIPLIER']
else:
return epoch_config['namespac... | [
"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 |
244,370 | 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 ):
epoch_config = get_epoch_config( block_height )
if epoch_config['namespaces'].has_key(namespace_id):
return epoch_config['namespaces'][namespace_id]['NAMESPACE_LIFETIME_GRACE_PERIOD']
else:
return epoch_config['name... | [
"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 |
244,371 | 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 ):
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_prices']
else:
return epoch_config['namespace_prices_stac... | [
"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 |
244,372 | 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):
global OPCODE_NAMES
# special case...
if op_string == '{}:'.format(NAME_REGISTRATION):
return 'NAME_RENEWAL'
op = op_string[0]
if op not in OPCODE_NAMES:
raise Exception('No such operation "{}"'.format(op))
return OPCODE_NAMES[op] | [
"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 |
244,373 | 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 ):
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 |
244,374 | 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):
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 |
244,375 | 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):
indexing_path = get_indexing_lockfile(working_dir)
if flag:
try:
fd = open( indexing_path, "w+" )
fd.close()
return True
except:
return False
else:
try:
os.unlink( indexing_path )
... | [
"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 |
244,376 | 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):
recovery_range_path = os.path.join(working_dir, '.recovery')
with open(recovery_range_path, 'w') as f:
f.write('{}\n{}\n'.format(start_block, end_block))
f.flush()
os.fsync(f.fileno()) | [
"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 |
244,377 | 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):
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 |
244,378 | 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):
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 'atlasdb_path' not in blockstack_opts:
... | [
"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 |
244,379 | 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):
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_path' path set")
return False
return Tru... | [
"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 |
244,380 | 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 ):
if not force:
# don't store unless we haven't seen it before
if announcement_hash in ANNOUNCEMENTS:
return
announce_filename = get_announce_filename( working_dir )
announce_filename_tmp = announc... | [
"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 |
244,381 | 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):
from .util import url_to_host_port, url_protocol
if config_file is None:
config_file = virtualchain.get_config_filename(get_default_virtualchain_impl(), working_dir)
parser = SafeConfigParser()
parser.read(config_file)
blockstack_ap... | [
"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 |
244,382 | 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):
# pretty-print the message
lines = message.split('\n')
max_line_len = max([len(l) for l in lines])
print('-' * max_line_len)
print(message)
print('-' * max_line_len)
ret = {}
for param in parameters:
formatted_param = p... | [
"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 |
244,383 | 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):
# are we missing anything?
missing_params = list(set(all_params) - set(given_opts))
num_prompted = 0
if not missing_params:
return given_opts, missing_params, num_prompted
if not prompt_miss... | [
"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 |
244,384 | 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):
ret = {}
for opt_name, opt_value in opts.items():
# remove prefix
if opt_name.startswith(prefix):
opt_name = opt_name[len(prefix):]
ret[opt_name] = opt_value
return ret | [
"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 |
244,385 | 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):
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 |
244,386 | 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):
default_bitcoin_opts = virtualchain.get_bitcoind_config(config_file=config_file)
# drop dict values that are None
default_bitcoin_opts = {k: v for k, v in default_bitcoin_opts.items() if v is not None}
# strip 'bitcoind_'
if not prefix:
... | [
"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 |
244,387 | 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():
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 |
244,388 | 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):
parser = SafeConfigParser()
if os.path.exists(config_file):
parser.read(config_file)
for sec_name in opts:
sec_opts = opts[sec_name]
if parser.has_section(sec_name):
parser.remove_section(sec_name)
parser.add_section(s... | [
"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 |
244,389 | 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):
import nameset.virtualchain_hooks as virtualchain_hooks
# acquire configuration, and store it globally
opts = configure(working_dir)
blockstack_opts = opts.get('blockstack', None)
blockstack_api_opts = opts.get('blockstack-api', None)
bitcoin_opts = opts['bi... | [
"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 |
244,390 | 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 ):
namespace_id = nameop['namespace_id']
sender = nameop['sender']
# must have been revealed
if not state_engine.is_namespace_revealed( namespace_id ):
log.warning("Namespace '%s' is not revealed" % namespace_id )
return False
# ... | [
"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 |
244,391 | 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):
if val < 0:
raise ValueError('"val" must be a non-negative integer.')
if val == 0:
return charset[0]
output = ""
while val > 0:
val, digit = divmod(val, len(charset))
output += charset[digit]
# reverse the characters in the output ... | [
"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 |
244,392 | 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):
output = 0
for char in s:
output = output * len(charset) + charset.index(char)
return output | [
"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 |
244,393 | 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):
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, target_charset)
return output_string | [
"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 |
244,394 | 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):
def wrap( reader ):
def wrapped_reader( *args, **kw ):
rec = reader( *args, **kw )
if rec is not None:
for field in autofill_fields:
if field == "opcode" and 'opcode' not in rec.keys():
assert... | [
"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 |
244,395 | 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={}):
import virtualchain_hooks
db_path = virtualchain.get_db_filename(virtualchain_hooks, working_dir)
db = BlockstackDB(db_path, DISPOSITION_RO, working_dir, get_genesis_block(), expected_snapshots={})
rc = db.db_setup()
... | [
"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 |
244,396 | 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 ):
# construct fields
opfields = {}
for opname in SERIALIZE_FIELDS.keys():
opcode = NAME_OPCODES[opname]
opfields[opcode] = SERIALIZE_FIELDS[opname]
return opfields | [
"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 |
244,397 | 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):
return super(BlockstackDB, cls).get_state_paths(impl, working_dir) + [
os.path.join(working_dir, 'atlas.db'),
os.path.join(working_dir, 'subdomains.db'),
os.path.join(working_dir, 'subdomains.db.queue')
] | [
"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 |
244,398 | 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 ):
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 |
244,399 | 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 ):
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.