repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_sync_zonefile_inventory | def atlas_peer_sync_zonefile_inventory( my_hostport, peer_hostport, maxlen, timeout=None, peer_table=None ):
"""
Synchronize our knowledge of a peer's zonefiles up to a given byte length
NOT THREAD SAFE; CALL FROM ONLY ONE THREAD.
maxlen is the maximum length in bits of the expected zonefile.
Retu... | python | def atlas_peer_sync_zonefile_inventory( my_hostport, peer_hostport, maxlen, timeout=None, peer_table=None ):
"""
Synchronize our knowledge of a peer's zonefiles up to a given byte length
NOT THREAD SAFE; CALL FROM ONLY ONE THREAD.
maxlen is the maximum length in bits of the expected zonefile.
Retu... | [
"def",
"atlas_peer_sync_zonefile_inventory",
"(",
"my_hostport",
",",
"peer_hostport",
",",
"maxlen",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"atlas_inv_timeout",
"(",
")",
"pee... | Synchronize our knowledge of a peer's zonefiles up to a given byte length
NOT THREAD SAFE; CALL FROM ONLY ONE THREAD.
maxlen is the maximum length in bits of the expected zonefile.
Return the new inv vector if we synced it (updating the peer table in the process)
Return None if not | [
"Synchronize",
"our",
"knowledge",
"of",
"a",
"peer",
"s",
"zonefiles",
"up",
"to",
"a",
"given",
"byte",
"length",
"NOT",
"THREAD",
"SAFE",
";",
"CALL",
"FROM",
"ONLY",
"ONE",
"THREAD",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2031-L2074 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_refresh_zonefile_inventory | def atlas_peer_refresh_zonefile_inventory( my_hostport, peer_hostport, byte_offset, timeout=None, peer_table=None, con=None, path=None, local_inv=None ):
"""
Refresh a peer's zonefile recent inventory vector entries,
by removing every bit after byte_offset and re-synchronizing them.
The intuition here ... | python | def atlas_peer_refresh_zonefile_inventory( my_hostport, peer_hostport, byte_offset, timeout=None, peer_table=None, con=None, path=None, local_inv=None ):
"""
Refresh a peer's zonefile recent inventory vector entries,
by removing every bit after byte_offset and re-synchronizing them.
The intuition here ... | [
"def",
"atlas_peer_refresh_zonefile_inventory",
"(",
"my_hostport",
",",
"peer_hostport",
",",
"byte_offset",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"local_inv",
"=",
"None",
")",
... | Refresh a peer's zonefile recent inventory vector entries,
by removing every bit after byte_offset and re-synchronizing them.
The intuition here is that recent zonefiles are much rarer than older
zonefiles (which will have been near-100% replicated), meaning the tail
of the peer's zonefile inventory is... | [
"Refresh",
"a",
"peer",
"s",
"zonefile",
"recent",
"inventory",
"vector",
"entries",
"by",
"removing",
"every",
"bit",
"after",
"byte_offset",
"and",
"re",
"-",
"synchronizing",
"them",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2077-L2131 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_has_fresh_zonefile_inventory | def atlas_peer_has_fresh_zonefile_inventory( peer_hostport, peer_table=None ):
"""
Does the given atlas node have a fresh zonefile inventory?
"""
fresh = False
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return False
now = time_no... | python | def atlas_peer_has_fresh_zonefile_inventory( peer_hostport, peer_table=None ):
"""
Does the given atlas node have a fresh zonefile inventory?
"""
fresh = False
with AtlasPeerTableLocked(peer_table) as ptbl:
if peer_hostport not in ptbl.keys():
return False
now = time_no... | [
"def",
"atlas_peer_has_fresh_zonefile_inventory",
"(",
"peer_hostport",
",",
"peer_table",
"=",
"None",
")",
":",
"fresh",
"=",
"False",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"if",
"peer_hostport",
"not",
"in",
"ptbl",
".",
"... | Does the given atlas node have a fresh zonefile inventory? | [
"Does",
"the",
"given",
"atlas",
"node",
"have",
"a",
"fresh",
"zonefile",
"inventory?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2134-L2153 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_find_missing_zonefile_availability | def atlas_find_missing_zonefile_availability( peer_table=None, con=None, path=None, missing_zonefile_info=None ):
"""
Find the set of missing zonefiles, as well as their popularity amongst
our neighbors.
Only consider zonefiles that are known by at least
one peer; otherwise they're missing from
... | python | def atlas_find_missing_zonefile_availability( peer_table=None, con=None, path=None, missing_zonefile_info=None ):
"""
Find the set of missing zonefiles, as well as their popularity amongst
our neighbors.
Only consider zonefiles that are known by at least
one peer; otherwise they're missing from
... | [
"def",
"atlas_find_missing_zonefile_availability",
"(",
"peer_table",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"missing_zonefile_info",
"=",
"None",
")",
":",
"bit_offset",
"=",
"0",
"bit_count",
"=",
"10000",
"missing",
"=",
"[",
... | Find the set of missing zonefiles, as well as their popularity amongst
our neighbors.
Only consider zonefiles that are known by at least
one peer; otherwise they're missing from
our clique (and we'll re-sync our neighborss' inventories
every so often to make sure we detect when zonefiles
becom... | [
"Find",
"the",
"set",
"of",
"missing",
"zonefiles",
"as",
"well",
"as",
"their",
"popularity",
"amongst",
"our",
"neighbors",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2177-L2266 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_has_zonefile | def atlas_peer_has_zonefile( peer_hostport, zonefile_hash, zonefile_bits=None, con=None, path=None, peer_table=None ):
"""
Does the given peer have the given zonefile defined?
Check its inventory vector
Return True if present
Return False if not present
Return None if we don't know about the zo... | python | def atlas_peer_has_zonefile( peer_hostport, zonefile_hash, zonefile_bits=None, con=None, path=None, peer_table=None ):
"""
Does the given peer have the given zonefile defined?
Check its inventory vector
Return True if present
Return False if not present
Return None if we don't know about the zo... | [
"def",
"atlas_peer_has_zonefile",
"(",
"peer_hostport",
",",
"zonefile_hash",
",",
"zonefile_bits",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"peer_table",
"=",
"None",
")",
":",
"bits",
"=",
"None",
"if",
"zonefile_bits",
"is",
... | Does the given peer have the given zonefile defined?
Check its inventory vector
Return True if present
Return False if not present
Return None if we don't know about the zonefile ourselves, or if we don't know about the peer | [
"Does",
"the",
"given",
"peer",
"have",
"the",
"given",
"zonefile",
"defined?",
"Check",
"its",
"inventory",
"vector"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2269-L2297 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_get_neighbors | def atlas_peer_get_neighbors( my_hostport, peer_hostport, timeout=None, peer_table=None, con=None, path=None ):
"""
Ask the peer server at the given URL for its neighbors.
Update the health info in peer_table
(if not given, the global peer table will be used instead)
Return the list on success
... | python | def atlas_peer_get_neighbors( my_hostport, peer_hostport, timeout=None, peer_table=None, con=None, path=None ):
"""
Ask the peer server at the given URL for its neighbors.
Update the health info in peer_table
(if not given, the global peer table will be used instead)
Return the list on success
... | [
"def",
"atlas_peer_get_neighbors",
"(",
"my_hostport",
",",
"peer_hostport",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"at... | Ask the peer server at the given URL for its neighbors.
Update the health info in peer_table
(if not given, the global peer table will be used instead)
Return the list on success
Return None on failure to contact
Raise on invalid URL | [
"Ask",
"the",
"peer",
"server",
"at",
"the",
"given",
"URL",
"for",
"its",
"neighbors",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2300-L2354 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_get_zonefiles | def atlas_get_zonefiles( my_hostport, peer_hostport, zonefile_hashes, timeout=None, peer_table=None ):
"""
Given a list of zonefile hashes.
go and get them from the given host.
Update node health
Return the newly-fetched zonefiles on success (as a dict mapping hashes to zonefile data)
Return N... | python | def atlas_get_zonefiles( my_hostport, peer_hostport, zonefile_hashes, timeout=None, peer_table=None ):
"""
Given a list of zonefile hashes.
go and get them from the given host.
Update node health
Return the newly-fetched zonefiles on success (as a dict mapping hashes to zonefile data)
Return N... | [
"def",
"atlas_get_zonefiles",
"(",
"my_hostport",
",",
"peer_hostport",
",",
"zonefile_hashes",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"atlas_zonefiles_timeout",
"(",
")",
"zf_... | Given a list of zonefile hashes.
go and get them from the given host.
Update node health
Return the newly-fetched zonefiles on success (as a dict mapping hashes to zonefile data)
Return None on error. | [
"Given",
"a",
"list",
"of",
"zonefile",
"hashes",
".",
"go",
"and",
"get",
"them",
"from",
"the",
"given",
"host",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2357-L2417 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_rank_peers_by_data_availability | def atlas_rank_peers_by_data_availability( peer_list=None, peer_table=None, local_inv=None, con=None, path=None ):
"""
Get a ranking of peers to contact for a zonefile.
Peers are ranked by the number of zonefiles they have
which we don't have.
This is used to select neighbors.
"""
with Atl... | python | def atlas_rank_peers_by_data_availability( peer_list=None, peer_table=None, local_inv=None, con=None, path=None ):
"""
Get a ranking of peers to contact for a zonefile.
Peers are ranked by the number of zonefiles they have
which we don't have.
This is used to select neighbors.
"""
with Atl... | [
"def",
"atlas_rank_peers_by_data_availability",
"(",
"peer_list",
"=",
"None",
",",
"peer_table",
"=",
"None",
",",
"local_inv",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
... | Get a ranking of peers to contact for a zonefile.
Peers are ranked by the number of zonefiles they have
which we don't have.
This is used to select neighbors. | [
"Get",
"a",
"ranking",
"of",
"peers",
"to",
"contact",
"for",
"a",
"zonefile",
".",
"Peers",
"are",
"ranked",
"by",
"the",
"number",
"of",
"zonefiles",
"they",
"have",
"which",
"we",
"don",
"t",
"have",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2453-L2488 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_peer_dequeue_all | def atlas_peer_dequeue_all( peer_queue=None ):
"""
Get all queued peers
"""
peers = []
with AtlasPeerQueueLocked(peer_queue) as pq:
while len(pq) > 0:
peers.append( pq.pop(0) )
return peers | python | def atlas_peer_dequeue_all( peer_queue=None ):
"""
Get all queued peers
"""
peers = []
with AtlasPeerQueueLocked(peer_queue) as pq:
while len(pq) > 0:
peers.append( pq.pop(0) )
return peers | [
"def",
"atlas_peer_dequeue_all",
"(",
"peer_queue",
"=",
"None",
")",
":",
"peers",
"=",
"[",
"]",
"with",
"AtlasPeerQueueLocked",
"(",
"peer_queue",
")",
"as",
"pq",
":",
"while",
"len",
"(",
"pq",
")",
">",
"0",
":",
"peers",
".",
"append",
"(",
"pq"... | Get all queued peers | [
"Get",
"all",
"queued",
"peers"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2524-L2534 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_zonefile_push_enqueue | def atlas_zonefile_push_enqueue( zonefile_hash, name, txid, zonefile_data, zonefile_queue=None, con=None, path=None ):
"""
Enqueue the given zonefile into our "push" queue,
from which it will be replicated to storage and sent
out to other peers who don't have it.
Return True if we enqueued it
R... | python | def atlas_zonefile_push_enqueue( zonefile_hash, name, txid, zonefile_data, zonefile_queue=None, con=None, path=None ):
"""
Enqueue the given zonefile into our "push" queue,
from which it will be replicated to storage and sent
out to other peers who don't have it.
Return True if we enqueued it
R... | [
"def",
"atlas_zonefile_push_enqueue",
"(",
"zonefile_hash",
",",
"name",
",",
"txid",
",",
"zonefile_data",
",",
"zonefile_queue",
"=",
"None",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"res",
"=",
"False",
"bits",
"=",
"atlasdb_get_zonefi... | Enqueue the given zonefile into our "push" queue,
from which it will be replicated to storage and sent
out to other peers who don't have it.
Return True if we enqueued it
Return False if not | [
"Enqueue",
"the",
"given",
"zonefile",
"into",
"our",
"push",
"queue",
"from",
"which",
"it",
"will",
"be",
"replicated",
"to",
"storage",
"and",
"sent",
"out",
"to",
"other",
"peers",
"who",
"don",
"t",
"have",
"it",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2560-L2589 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_zonefile_push_dequeue | def atlas_zonefile_push_dequeue( zonefile_queue=None ):
"""
Dequeue a zonefile's information to replicate
Return None if there are none queued
"""
ret = None
with AtlasZonefileQueueLocked(zonefile_queue) as zfq:
if len(zfq) > 0:
ret = zfq.pop(0)
return ret | python | def atlas_zonefile_push_dequeue( zonefile_queue=None ):
"""
Dequeue a zonefile's information to replicate
Return None if there are none queued
"""
ret = None
with AtlasZonefileQueueLocked(zonefile_queue) as zfq:
if len(zfq) > 0:
ret = zfq.pop(0)
return ret | [
"def",
"atlas_zonefile_push_dequeue",
"(",
"zonefile_queue",
"=",
"None",
")",
":",
"ret",
"=",
"None",
"with",
"AtlasZonefileQueueLocked",
"(",
"zonefile_queue",
")",
"as",
"zfq",
":",
"if",
"len",
"(",
"zfq",
")",
">",
"0",
":",
"ret",
"=",
"zfq",
".",
... | Dequeue a zonefile's information to replicate
Return None if there are none queued | [
"Dequeue",
"a",
"zonefile",
"s",
"information",
"to",
"replicate",
"Return",
"None",
"if",
"there",
"are",
"none",
"queued"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2592-L2602 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_zonefile_push | def atlas_zonefile_push( my_hostport, peer_hostport, zonefile_data, timeout=None, peer_table=None ):
"""
Push the given zonefile to the given peer
Return True on success
Return False on failure
"""
if timeout is None:
timeout = atlas_push_zonefiles_timeout()
zonefile_hash = get_z... | python | def atlas_zonefile_push( my_hostport, peer_hostport, zonefile_data, timeout=None, peer_table=None ):
"""
Push the given zonefile to the given peer
Return True on success
Return False on failure
"""
if timeout is None:
timeout = atlas_push_zonefiles_timeout()
zonefile_hash = get_z... | [
"def",
"atlas_zonefile_push",
"(",
"my_hostport",
",",
"peer_hostport",
",",
"zonefile_data",
",",
"timeout",
"=",
"None",
",",
"peer_table",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"atlas_push_zonefiles_timeout",
"(",
")",
"... | Push the given zonefile to the given peer
Return True on success
Return False on failure | [
"Push",
"the",
"given",
"zonefile",
"to",
"the",
"given",
"peer",
"Return",
"True",
"on",
"success",
"Return",
"False",
"on",
"failure"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2605-L2646 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_node_init | def atlas_node_init(my_hostname, my_portnum, atlasdb_path, zonefile_dir, working_dir):
"""
Start up the atlas node.
Return a bundle of atlas state
"""
atlas_state = {}
atlas_state['peer_crawler'] = AtlasPeerCrawler(my_hostname, my_portnum, atlasdb_path, working_dir)
atlas_state['health_check... | python | def atlas_node_init(my_hostname, my_portnum, atlasdb_path, zonefile_dir, working_dir):
"""
Start up the atlas node.
Return a bundle of atlas state
"""
atlas_state = {}
atlas_state['peer_crawler'] = AtlasPeerCrawler(my_hostname, my_portnum, atlasdb_path, working_dir)
atlas_state['health_check... | [
"def",
"atlas_node_init",
"(",
"my_hostname",
",",
"my_portnum",
",",
"atlasdb_path",
",",
"zonefile_dir",
",",
"working_dir",
")",
":",
"atlas_state",
"=",
"{",
"}",
"atlas_state",
"[",
"'peer_crawler'",
"]",
"=",
"AtlasPeerCrawler",
"(",
"my_hostname",
",",
"m... | Start up the atlas node.
Return a bundle of atlas state | [
"Start",
"up",
"the",
"atlas",
"node",
".",
"Return",
"a",
"bundle",
"of",
"atlas",
"state"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3584-L3595 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_node_start | def atlas_node_start(atlas_state):
"""
Start up atlas threads
"""
for component in atlas_state.keys():
log.debug("Starting Atlas component '%s'" % component)
atlas_state[component].start() | python | def atlas_node_start(atlas_state):
"""
Start up atlas threads
"""
for component in atlas_state.keys():
log.debug("Starting Atlas component '%s'" % component)
atlas_state[component].start() | [
"def",
"atlas_node_start",
"(",
"atlas_state",
")",
":",
"for",
"component",
"in",
"atlas_state",
".",
"keys",
"(",
")",
":",
"log",
".",
"debug",
"(",
"\"Starting Atlas component '%s'\"",
"%",
"component",
")",
"atlas_state",
"[",
"component",
"]",
".",
"star... | Start up atlas threads | [
"Start",
"up",
"atlas",
"threads"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3597-L3603 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_node_add_callback | def atlas_node_add_callback(atlas_state, callback_name, callback):
"""
Add a callback to the initialized atlas state
"""
if callback_name == 'store_zonefile':
atlas_state['zonefile_crawler'].set_store_zonefile_callback(callback)
else:
raise ValueError("Unrecognized callback {}".form... | python | def atlas_node_add_callback(atlas_state, callback_name, callback):
"""
Add a callback to the initialized atlas state
"""
if callback_name == 'store_zonefile':
atlas_state['zonefile_crawler'].set_store_zonefile_callback(callback)
else:
raise ValueError("Unrecognized callback {}".form... | [
"def",
"atlas_node_add_callback",
"(",
"atlas_state",
",",
"callback_name",
",",
"callback",
")",
":",
"if",
"callback_name",
"==",
"'store_zonefile'",
":",
"atlas_state",
"[",
"'zonefile_crawler'",
"]",
".",
"set_store_zonefile_callback",
"(",
"callback",
")",
"else"... | Add a callback to the initialized atlas state | [
"Add",
"a",
"callback",
"to",
"the",
"initialized",
"atlas",
"state"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3606-L3614 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | atlas_node_stop | def atlas_node_stop( atlas_state ):
"""
Stop the atlas node threads
"""
for component in atlas_state.keys():
log.debug("Stopping Atlas component '%s'" % component)
atlas_state[component].ask_join()
atlas_state[component].join()
return True | python | def atlas_node_stop( atlas_state ):
"""
Stop the atlas node threads
"""
for component in atlas_state.keys():
log.debug("Stopping Atlas component '%s'" % component)
atlas_state[component].ask_join()
atlas_state[component].join()
return True | [
"def",
"atlas_node_stop",
"(",
"atlas_state",
")",
":",
"for",
"component",
"in",
"atlas_state",
".",
"keys",
"(",
")",
":",
"log",
".",
"debug",
"(",
"\"Stopping Atlas component '%s'\"",
"%",
"component",
")",
"atlas_state",
"[",
"component",
"]",
".",
"ask_j... | Stop the atlas node threads | [
"Stop",
"the",
"atlas",
"node",
"threads"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3617-L3626 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasPeerCrawler.canonical_peer | def canonical_peer( self, peer ):
"""
Get the canonical peer name
"""
their_host, their_port = url_to_host_port( peer )
if their_host in ['127.0.0.1', '::1']:
their_host = 'localhost'
return "%s:%s" % (their_host, their_port) | python | def canonical_peer( self, peer ):
"""
Get the canonical peer name
"""
their_host, their_port = url_to_host_port( peer )
if their_host in ['127.0.0.1', '::1']:
their_host = 'localhost'
return "%s:%s" % (their_host, their_port) | [
"def",
"canonical_peer",
"(",
"self",
",",
"peer",
")",
":",
"their_host",
",",
"their_port",
"=",
"url_to_host_port",
"(",
"peer",
")",
"if",
"their_host",
"in",
"[",
"'127.0.0.1'",
",",
"'::1'",
"]",
":",
"their_host",
"=",
"'localhost'",
"return",
"\"%s:%... | Get the canonical peer name | [
"Get",
"the",
"canonical",
"peer",
"name"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2713-L2722 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasPeerCrawler.remove_unhealthy_peers | def remove_unhealthy_peers( self, count, con=None, path=None, peer_table=None, min_request_count=10, min_health=MIN_PEER_HEALTH ):
"""
Remove up to @count unhealthy peers
Return the list of peers we removed
"""
if path is None:
path = self.atlasdb_path
... | python | def remove_unhealthy_peers( self, count, con=None, path=None, peer_table=None, min_request_count=10, min_health=MIN_PEER_HEALTH ):
"""
Remove up to @count unhealthy peers
Return the list of peers we removed
"""
if path is None:
path = self.atlasdb_path
... | [
"def",
"remove_unhealthy_peers",
"(",
"self",
",",
"count",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"peer_table",
"=",
"None",
",",
"min_request_count",
"=",
"10",
",",
"min_health",
"=",
"MIN_PEER_HEALTH",
")",
":",
"if",
"path",
"is",
"... | Remove up to @count unhealthy peers
Return the list of peers we removed | [
"Remove",
"up",
"to"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2836-L2860 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasPeerCrawler.get_current_peers | def get_current_peers( self, peer_table=None ):
"""
Get the current set of peers
"""
# get current peers
current_peers = None
with AtlasPeerTableLocked(peer_table) as ptbl:
current_peers = ptbl.keys()[:]
return current_peers | python | def get_current_peers( self, peer_table=None ):
"""
Get the current set of peers
"""
# get current peers
current_peers = None
with AtlasPeerTableLocked(peer_table) as ptbl:
current_peers = ptbl.keys()[:]
return current_peers | [
"def",
"get_current_peers",
"(",
"self",
",",
"peer_table",
"=",
"None",
")",
":",
"current_peers",
"=",
"None",
"with",
"AtlasPeerTableLocked",
"(",
"peer_table",
")",
"as",
"ptbl",
":",
"current_peers",
"=",
"ptbl",
".",
"keys",
"(",
")",
"[",
":",
"]",
... | Get the current set of peers | [
"Get",
"the",
"current",
"set",
"of",
"peers"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2945-L2955 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasPeerCrawler.canonical_new_peer_list | def canonical_new_peer_list( self, peers_to_add ):
"""
Make a list of canonical new peers, using the
self.new_peers and the given peers to add
Return a shuffled list of canonicalized host:port
strings.
"""
new_peers = list(set(self.new_peers + peers_to_add))
... | python | def canonical_new_peer_list( self, peers_to_add ):
"""
Make a list of canonical new peers, using the
self.new_peers and the given peers to add
Return a shuffled list of canonicalized host:port
strings.
"""
new_peers = list(set(self.new_peers + peers_to_add))
... | [
"def",
"canonical_new_peer_list",
"(",
"self",
",",
"peers_to_add",
")",
":",
"new_peers",
"=",
"list",
"(",
"set",
"(",
"self",
".",
"new_peers",
"+",
"peers_to_add",
")",
")",
"random",
".",
"shuffle",
"(",
"new_peers",
")",
"tmp",
"=",
"[",
"]",
"for"... | Make a list of canonical new peers, using the
self.new_peers and the given peers to add
Return a shuffled list of canonicalized host:port
strings. | [
"Make",
"a",
"list",
"of",
"canonical",
"new",
"peers",
"using",
"the",
"self",
".",
"new_peers",
"and",
"the",
"given",
"peers",
"to",
"add"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L2958-L2980 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasHealthChecker.step | def step(self, con=None, path=None, peer_table=None, local_inv=None):
"""
Find peers with stale zonefile inventory data,
and refresh them.
Return True on success
Return False on error
"""
if path is None:
path = self.atlasdb_path
peer_hostpor... | python | def step(self, con=None, path=None, peer_table=None, local_inv=None):
"""
Find peers with stale zonefile inventory data,
and refresh them.
Return True on success
Return False on error
"""
if path is None:
path = self.atlasdb_path
peer_hostpor... | [
"def",
"step",
"(",
"self",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
",",
"peer_table",
"=",
"None",
",",
"local_inv",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"self",
".",
"atlasdb_path",
"peer_hostports",
"=",
... | Find peers with stale zonefile inventory data,
and refresh them.
Return True on success
Return False on error | [
"Find",
"peers",
"with",
"stale",
"zonefile",
"inventory",
"data",
"and",
"refresh",
"them",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3171-L3210 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasHealthChecker.run | def run(self, peer_table=None):
"""
Loop forever, pinging someone every pass.
"""
self.running = True
while self.running:
local_inv = atlas_get_zonefile_inventory()
t1 = time_now()
self.step( peer_table=peer_table, local_inv=local_inv, path=sel... | python | def run(self, peer_table=None):
"""
Loop forever, pinging someone every pass.
"""
self.running = True
while self.running:
local_inv = atlas_get_zonefile_inventory()
t1 = time_now()
self.step( peer_table=peer_table, local_inv=local_inv, path=sel... | [
"def",
"run",
"(",
"self",
",",
"peer_table",
"=",
"None",
")",
":",
"self",
".",
"running",
"=",
"True",
"while",
"self",
".",
"running",
":",
"local_inv",
"=",
"atlas_get_zonefile_inventory",
"(",
")",
"t1",
"=",
"time_now",
"(",
")",
"self",
".",
"s... | Loop forever, pinging someone every pass. | [
"Loop",
"forever",
"pinging",
"someone",
"every",
"pass",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3213-L3231 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasZonefileCrawler.set_zonefile_present | def set_zonefile_present(self, zfhash, block_height, con=None, path=None):
"""
Set a zonefile as present, and if it was previously absent, inform the storage listener
"""
was_present = atlasdb_set_zonefile_present( zfhash, True, con=con, path=path )
# tell anyone who cares that ... | python | def set_zonefile_present(self, zfhash, block_height, con=None, path=None):
"""
Set a zonefile as present, and if it was previously absent, inform the storage listener
"""
was_present = atlasdb_set_zonefile_present( zfhash, True, con=con, path=path )
# tell anyone who cares that ... | [
"def",
"set_zonefile_present",
"(",
"self",
",",
"zfhash",
",",
"block_height",
",",
"con",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"was_present",
"=",
"atlasdb_set_zonefile_present",
"(",
"zfhash",
",",
"True",
",",
"con",
"=",
"con",
",",
"path"... | Set a zonefile as present, and if it was previously absent, inform the storage listener | [
"Set",
"a",
"zonefile",
"as",
"present",
"and",
"if",
"it",
"was",
"previously",
"absent",
"inform",
"the",
"storage",
"listener"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3257-L3268 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasZonefileCrawler.find_zonefile_origins | def find_zonefile_origins( self, missing_zfinfo, peer_hostports ):
"""
Find out which peers can serve which zonefiles
"""
zonefile_origins = {} # map peer hostport to list of zonefile hashes
# which peers can serve each zonefile?
for zfhash in missing_zfinfo.keys():
... | python | def find_zonefile_origins( self, missing_zfinfo, peer_hostports ):
"""
Find out which peers can serve which zonefiles
"""
zonefile_origins = {} # map peer hostport to list of zonefile hashes
# which peers can serve each zonefile?
for zfhash in missing_zfinfo.keys():
... | [
"def",
"find_zonefile_origins",
"(",
"self",
",",
"missing_zfinfo",
",",
"peer_hostports",
")",
":",
"zonefile_origins",
"=",
"{",
"}",
"for",
"zfhash",
"in",
"missing_zfinfo",
".",
"keys",
"(",
")",
":",
"for",
"peer_hostport",
"in",
"peer_hostports",
":",
"i... | Find out which peers can serve which zonefiles | [
"Find",
"out",
"which",
"peers",
"can",
"serve",
"which",
"zonefiles"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3316-L3331 | train |
blockstack/blockstack-core | blockstack/lib/atlas.py | AtlasZonefilePusher.step | def step( self, peer_table=None, zonefile_queue=None, path=None ):
"""
Run one step of this algorithm.
Push the zonefile to all the peers that need it.
Return the number of peers we sent to
"""
if path is None:
path = self.atlasdb_path
if BLOCKSTACK_T... | python | def step( self, peer_table=None, zonefile_queue=None, path=None ):
"""
Run one step of this algorithm.
Push the zonefile to all the peers that need it.
Return the number of peers we sent to
"""
if path is None:
path = self.atlasdb_path
if BLOCKSTACK_T... | [
"def",
"step",
"(",
"self",
",",
"peer_table",
"=",
"None",
",",
"zonefile_queue",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"self",
".",
"atlasdb_path",
"if",
"BLOCKSTACK_TEST",
":",
"log",
".",
"... | Run one step of this algorithm.
Push the zonefile to all the peers that need it.
Return the number of peers we sent to | [
"Run",
"one",
"step",
"of",
"this",
"algorithm",
".",
"Push",
"the",
"zonefile",
"to",
"all",
"the",
"peers",
"that",
"need",
"it",
".",
"Return",
"the",
"number",
"of",
"peers",
"we",
"sent",
"to"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/atlas.py#L3509-L3561 | train |
blockstack/blockstack-core | blockstack/lib/queue.py | queuedb_create | def queuedb_create(path):
"""
Create a sqlite3 db at the given path.
Create all the tables and indexes we need.
Raises if the table already exists
"""
global QUEUE_SQL, ERROR_SQL
lines = [l + ";" for l in QUEUE_SQL.split(";")]
con = sqlite3.connect( path, isolation_level=None )
db_... | python | def queuedb_create(path):
"""
Create a sqlite3 db at the given path.
Create all the tables and indexes we need.
Raises if the table already exists
"""
global QUEUE_SQL, ERROR_SQL
lines = [l + ";" for l in QUEUE_SQL.split(";")]
con = sqlite3.connect( path, isolation_level=None )
db_... | [
"def",
"queuedb_create",
"(",
"path",
")",
":",
"global",
"QUEUE_SQL",
",",
"ERROR_SQL",
"lines",
"=",
"[",
"l",
"+",
"\";\"",
"for",
"l",
"in",
"QUEUE_SQL",
".",
"split",
"(",
"\";\"",
")",
"]",
"con",
"=",
"sqlite3",
".",
"connect",
"(",
"path",
",... | Create a sqlite3 db at the given path.
Create all the tables and indexes we need.
Raises if the table already exists | [
"Create",
"a",
"sqlite3",
"db",
"at",
"the",
"given",
"path",
".",
"Create",
"all",
"the",
"tables",
"and",
"indexes",
"we",
"need",
".",
"Raises",
"if",
"the",
"table",
"already",
"exists"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/queue.py#L46-L63 | train |
blockstack/blockstack-core | blockstack/lib/queue.py | queuedb_row_factory | def queuedb_row_factory(cursor, row):
"""
Dict row factory
"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | python | def queuedb_row_factory(cursor, row):
"""
Dict row factory
"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | [
"def",
"queuedb_row_factory",
"(",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"d",
"[",
"col",
"[",
"0",
"]",
"]",
"=",
"row",
"[",
"idx",
"]",
"... | Dict row factory | [
"Dict",
"row",
"factory"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/queue.py#L75-L83 | train |
blockstack/blockstack-core | blockstack/lib/queue.py | queuedb_findall | def queuedb_findall(path, queue_id, name=None, offset=None, limit=None):
"""
Get all queued entries for a queue and a name.
If name is None, then find all queue entries
Return the rows on success (empty list if not found)
Raise on error
"""
sql = "SELECT * FROM queue WHERE queue_id = ? ORDE... | python | def queuedb_findall(path, queue_id, name=None, offset=None, limit=None):
"""
Get all queued entries for a queue and a name.
If name is None, then find all queue entries
Return the rows on success (empty list if not found)
Raise on error
"""
sql = "SELECT * FROM queue WHERE queue_id = ? ORDE... | [
"def",
"queuedb_findall",
"(",
"path",
",",
"queue_id",
",",
"name",
"=",
"None",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"sql",
"=",
"\"SELECT * FROM queue WHERE queue_id = ? ORDER BY rowid ASC\"",
"args",
"=",
"(",
"queue_id",
",",
"... | Get all queued entries for a queue and a name.
If name is None, then find all queue entries
Return the rows on success (empty list if not found)
Raise on error | [
"Get",
"all",
"queued",
"entries",
"for",
"a",
"queue",
"and",
"a",
"name",
".",
"If",
"name",
"is",
"None",
"then",
"find",
"all",
"queue",
"entries"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/queue.py#L103-L143 | train |
blockstack/blockstack-core | blockstack/lib/queue.py | queuedb_append | def queuedb_append(path, queue_id, name, data):
"""
Append an element to the back of the queue.
Return True on success
Raise on error
"""
sql = "INSERT INTO queue VALUES (?,?,?);"
args = (name, queue_id, data)
db = queuedb_open(path)
if db is None:
raise Exception("Failed to... | python | def queuedb_append(path, queue_id, name, data):
"""
Append an element to the back of the queue.
Return True on success
Raise on error
"""
sql = "INSERT INTO queue VALUES (?,?,?);"
args = (name, queue_id, data)
db = queuedb_open(path)
if db is None:
raise Exception("Failed to... | [
"def",
"queuedb_append",
"(",
"path",
",",
"queue_id",
",",
"name",
",",
"data",
")",
":",
"sql",
"=",
"\"INSERT INTO queue VALUES (?,?,?);\"",
"args",
"=",
"(",
"name",
",",
"queue_id",
",",
"data",
")",
"db",
"=",
"queuedb_open",
"(",
"path",
")",
"if",
... | Append an element to the back of the queue.
Return True on success
Raise on error | [
"Append",
"an",
"element",
"to",
"the",
"back",
"of",
"the",
"queue",
".",
"Return",
"True",
"on",
"success",
"Raise",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/queue.py#L146-L164 | train |
blockstack/blockstack-core | blockstack/lib/queue.py | queuedb_remove | def queuedb_remove(path, entry, cur=None):
"""
Remove an element from a queue.
Return True on success
Raise on error
"""
sql = "DELETE FROM queue WHERE queue_id = ? AND name = ?;"
args = (entry['queue_id'], entry['name'])
cursor = None
if cur:
cursor = cur
else:
... | python | def queuedb_remove(path, entry, cur=None):
"""
Remove an element from a queue.
Return True on success
Raise on error
"""
sql = "DELETE FROM queue WHERE queue_id = ? AND name = ?;"
args = (entry['queue_id'], entry['name'])
cursor = None
if cur:
cursor = cur
else:
... | [
"def",
"queuedb_remove",
"(",
"path",
",",
"entry",
",",
"cur",
"=",
"None",
")",
":",
"sql",
"=",
"\"DELETE FROM queue WHERE queue_id = ? AND name = ?;\"",
"args",
"=",
"(",
"entry",
"[",
"'queue_id'",
"]",
",",
"entry",
"[",
"'name'",
"]",
")",
"cursor",
"... | Remove an element from a queue.
Return True on success
Raise on error | [
"Remove",
"an",
"element",
"from",
"a",
"queue",
".",
"Return",
"True",
"on",
"success",
"Raise",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/queue.py#L167-L192 | train |
blockstack/blockstack-core | blockstack/lib/queue.py | queuedb_removeall | def queuedb_removeall(path, entries):
"""
Remove all entries from a queue
"""
db = queuedb_open(path)
if db is None:
raise Exception("Failed to open %s" % path)
cursor = db.cursor()
queuedb_query_execute(cursor, 'BEGIN', ())
for entry in entries:
queuedb_remove(path, en... | python | def queuedb_removeall(path, entries):
"""
Remove all entries from a queue
"""
db = queuedb_open(path)
if db is None:
raise Exception("Failed to open %s" % path)
cursor = db.cursor()
queuedb_query_execute(cursor, 'BEGIN', ())
for entry in entries:
queuedb_remove(path, en... | [
"def",
"queuedb_removeall",
"(",
"path",
",",
"entries",
")",
":",
"db",
"=",
"queuedb_open",
"(",
"path",
")",
"if",
"db",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Failed to open %s\"",
"%",
"path",
")",
"cursor",
"=",
"db",
".",
"cursor",
"(",
... | Remove all entries from a queue | [
"Remove",
"all",
"entries",
"from",
"a",
"queue"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/queue.py#L195-L213 | train |
blockstack/blockstack-core | blockstack/lib/operations/register.py | check_payment_in_stacks | def check_payment_in_stacks(state_engine, nameop, state_op_type, fee_block_id):
"""
Verify that if tokens were paid for a name priced in BTC, that enough were paid.
Does not check account balances or namespace types; it only inspects the transaction data.
Returns {'status': True, 'tokens_paid': ..., 't... | python | def check_payment_in_stacks(state_engine, nameop, state_op_type, fee_block_id):
"""
Verify that if tokens were paid for a name priced in BTC, that enough were paid.
Does not check account balances or namespace types; it only inspects the transaction data.
Returns {'status': True, 'tokens_paid': ..., 't... | [
"def",
"check_payment_in_stacks",
"(",
"state_engine",
",",
"nameop",
",",
"state_op_type",
",",
"fee_block_id",
")",
":",
"name",
"=",
"nameop",
"[",
"'name'",
"]",
"namespace_id",
"=",
"get_namespace_from_name",
"(",
"name",
")",
"name_without_namespace",
"=",
"... | Verify that if tokens were paid for a name priced in BTC, that enough were paid.
Does not check account balances or namespace types; it only inspects the transaction data.
Returns {'status': True, 'tokens_paid': ..., 'token_units': ...} on success
Returns {'status': False} on error | [
"Verify",
"that",
"if",
"tokens",
"were",
"paid",
"for",
"a",
"name",
"priced",
"in",
"BTC",
"that",
"enough",
"were",
"paid",
".",
"Does",
"not",
"check",
"account",
"balances",
"or",
"namespace",
"types",
";",
"it",
"only",
"inspects",
"the",
"transactio... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/register.py#L201-L228 | train |
blockstack/blockstack-core | blockstack/lib/operations/register.py | check_payment | def check_payment(state_engine, state_op_type, nameop, fee_block_id, token_address, burn_address, name_fee, block_id):
"""
Verify that the right payment was made, in the right cryptocurrency units.
Does not check any accounts or modify the nameop in any way; it only checks that the name was paid for by the ... | python | def check_payment(state_engine, state_op_type, nameop, fee_block_id, token_address, burn_address, name_fee, block_id):
"""
Verify that the right payment was made, in the right cryptocurrency units.
Does not check any accounts or modify the nameop in any way; it only checks that the name was paid for by the ... | [
"def",
"check_payment",
"(",
"state_engine",
",",
"state_op_type",
",",
"nameop",
",",
"fee_block_id",
",",
"token_address",
",",
"burn_address",
",",
"name_fee",
",",
"block_id",
")",
":",
"assert",
"state_op_type",
"in",
"[",
"'NAME_REGISTRATION'",
",",
"'NAME_R... | Verify that the right payment was made, in the right cryptocurrency units.
Does not check any accounts or modify the nameop in any way; it only checks that the name was paid for by the transaction.
NOTE: if state_op_type is NAME_REGISTRATION, you will need to have called state_create_put_preorder() before call... | [
"Verify",
"that",
"the",
"right",
"payment",
"was",
"made",
"in",
"the",
"right",
"cryptocurrency",
"units",
".",
"Does",
"not",
"check",
"any",
"accounts",
"or",
"modify",
"the",
"nameop",
"in",
"any",
"way",
";",
"it",
"only",
"checks",
"that",
"the",
... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/register.py#L405-L448 | train |
blockstack/blockstack-core | blockstack/lib/operations/namespacepreorder.py | check | def check( state_engine, nameop, block_id, checked_ops ):
"""
Given a NAMESPACE_PREORDER nameop, see if we can preorder it.
It must be unqiue.
Return True if accepted.
Return False if not.
"""
namespace_id_hash = nameop['preorder_hash']
consensus_hash = nameop['consensus_hash']
tok... | python | def check( state_engine, nameop, block_id, checked_ops ):
"""
Given a NAMESPACE_PREORDER nameop, see if we can preorder it.
It must be unqiue.
Return True if accepted.
Return False if not.
"""
namespace_id_hash = nameop['preorder_hash']
consensus_hash = nameop['consensus_hash']
tok... | [
"def",
"check",
"(",
"state_engine",
",",
"nameop",
",",
"block_id",
",",
"checked_ops",
")",
":",
"namespace_id_hash",
"=",
"nameop",
"[",
"'preorder_hash'",
"]",
"consensus_hash",
"=",
"nameop",
"[",
"'consensus_hash'",
"]",
"token_fee",
"=",
"nameop",
"[",
... | Given a NAMESPACE_PREORDER nameop, see if we can preorder it.
It must be unqiue.
Return True if accepted.
Return False if not. | [
"Given",
"a",
"NAMESPACE_PREORDER",
"nameop",
"see",
"if",
"we",
"can",
"preorder",
"it",
".",
"It",
"must",
"be",
"unqiue",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/namespacepreorder.py#L53-L134 | train |
blockstack/blockstack-core | blockstack/lib/fast_sync.py | snapshot_peek_number | def snapshot_peek_number( fd, off ):
"""
Read the last 8 bytes of fd
and interpret it as an int.
"""
# read number of 8 bytes
fd.seek( off - 8, os.SEEK_SET )
value_hex = fd.read(8)
if len(value_hex) != 8:
return None
try:
value = int(value_hex, 16)
except ValueEr... | python | def snapshot_peek_number( fd, off ):
"""
Read the last 8 bytes of fd
and interpret it as an int.
"""
# read number of 8 bytes
fd.seek( off - 8, os.SEEK_SET )
value_hex = fd.read(8)
if len(value_hex) != 8:
return None
try:
value = int(value_hex, 16)
except ValueEr... | [
"def",
"snapshot_peek_number",
"(",
"fd",
",",
"off",
")",
":",
"fd",
".",
"seek",
"(",
"off",
"-",
"8",
",",
"os",
".",
"SEEK_SET",
")",
"value_hex",
"=",
"fd",
".",
"read",
"(",
"8",
")",
"if",
"len",
"(",
"value_hex",
")",
"!=",
"8",
":",
"r... | Read the last 8 bytes of fd
and interpret it as an int. | [
"Read",
"the",
"last",
"8",
"bytes",
"of",
"fd",
"and",
"interpret",
"it",
"as",
"an",
"int",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L52-L67 | train |
blockstack/blockstack-core | blockstack/lib/fast_sync.py | get_file_hash | def get_file_hash( fd, hashfunc, fd_len=None ):
"""
Get the hex-encoded hash of the fd's data
"""
h = hashfunc()
fd.seek(0, os.SEEK_SET)
count = 0
while True:
buf = fd.read(65536)
if len(buf) == 0:
break
if fd_len is not None:
if count + len... | python | def get_file_hash( fd, hashfunc, fd_len=None ):
"""
Get the hex-encoded hash of the fd's data
"""
h = hashfunc()
fd.seek(0, os.SEEK_SET)
count = 0
while True:
buf = fd.read(65536)
if len(buf) == 0:
break
if fd_len is not None:
if count + len... | [
"def",
"get_file_hash",
"(",
"fd",
",",
"hashfunc",
",",
"fd_len",
"=",
"None",
")",
":",
"h",
"=",
"hashfunc",
"(",
")",
"fd",
".",
"seek",
"(",
"0",
",",
"os",
".",
"SEEK_SET",
")",
"count",
"=",
"0",
"while",
"True",
":",
"buf",
"=",
"fd",
"... | Get the hex-encoded hash of the fd's data | [
"Get",
"the",
"hex",
"-",
"encoded",
"hash",
"of",
"the",
"fd",
"s",
"data"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L89-L111 | train |
blockstack/blockstack-core | blockstack/lib/fast_sync.py | fast_sync_sign_snapshot | def fast_sync_sign_snapshot( snapshot_path, private_key, first=False ):
"""
Append a signature to the end of a snapshot path
with the given private key.
If first is True, then don't expect the signature trailer.
Return True on success
Return False on error
"""
if not os.path.exists... | python | def fast_sync_sign_snapshot( snapshot_path, private_key, first=False ):
"""
Append a signature to the end of a snapshot path
with the given private key.
If first is True, then don't expect the signature trailer.
Return True on success
Return False on error
"""
if not os.path.exists... | [
"def",
"fast_sync_sign_snapshot",
"(",
"snapshot_path",
",",
"private_key",
",",
"first",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"snapshot_path",
")",
":",
"log",
".",
"error",
"(",
"\"No such file or directory: {}\"",
".",... | Append a signature to the end of a snapshot path
with the given private key.
If first is True, then don't expect the signature trailer.
Return True on success
Return False on error | [
"Append",
"a",
"signature",
"to",
"the",
"end",
"of",
"a",
"snapshot",
"path",
"with",
"the",
"given",
"private",
"key",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L114-L180 | train |
blockstack/blockstack-core | blockstack/lib/fast_sync.py | fast_sync_snapshot_compress | def fast_sync_snapshot_compress( snapshot_dir, export_path ):
"""
Given the path to a directory, compress it and export it to the
given path.
Return {'status': True} on success
Return {'error': ...} on failure
"""
snapshot_dir = os.path.abspath(snapshot_dir)
export_path = os.path.abspa... | python | def fast_sync_snapshot_compress( snapshot_dir, export_path ):
"""
Given the path to a directory, compress it and export it to the
given path.
Return {'status': True} on success
Return {'error': ...} on failure
"""
snapshot_dir = os.path.abspath(snapshot_dir)
export_path = os.path.abspa... | [
"def",
"fast_sync_snapshot_compress",
"(",
"snapshot_dir",
",",
"export_path",
")",
":",
"snapshot_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"snapshot_dir",
")",
"export_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"export_path",
")",
"if",
"... | Given the path to a directory, compress it and export it to the
given path.
Return {'status': True} on success
Return {'error': ...} on failure | [
"Given",
"the",
"path",
"to",
"a",
"directory",
"compress",
"it",
"and",
"export",
"it",
"to",
"the",
"given",
"path",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/fast_sync.py#L183-L220 | train |
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 ):
"""
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):
... | [
"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 | train |
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):
"""
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:
... | [
"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 | train |
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 ):
"""
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... | [
"def",
"state_check_collisions",
"(",
"state_engine",
",",
"nameop",
",",
"history_id_key",
",",
"block_id",
",",
"checked_ops",
",",
"collision_checker",
")",
":",
"collision_check",
"=",
"getattr",
"(",
"state_engine",
",",
"collision_checker",
",",
"None",
")",
... | 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 | train |
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 ):
"""
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... | [
"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 | train |
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 ):
"""
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... | [
"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 | train |
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 ):
"""
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 ... | [
"def",
"_read_atlas_zonefile",
"(",
"zonefile_path",
",",
"zonefile_hash",
")",
":",
"with",
"open",
"(",
"zonefile_path",
",",
"\"rb\"",
")",
"as",
"f",
":",
"data",
"=",
"f",
".",
"read",
"(",
")",
"if",
"zonefile_hash",
"is",
"not",
"None",
":",
"if",... | 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 | train |
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 ):
"""
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... | [
"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 | train |
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):
"""
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... | [
"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 | train |
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 ):
"""
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... | [
"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 | train |
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):
"""
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... | [
"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 | train |
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 ):
"""
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" ... | [
"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 | train |
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 ):
"""
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... | [
"def",
"find_transfer_consensus_hash",
"(",
"name_rec",
",",
"block_id",
",",
"vtxindex",
",",
"nameop_consensus_hash",
")",
":",
"for",
"historic_block_number",
"in",
"reversed",
"(",
"sorted",
"(",
"name_rec",
"[",
"'history'",
"]",
".",
"keys",
"(",
")",
")",... | 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 | train |
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):
"""
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... | [
"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 | train |
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 ):
"""
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:... | [
"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 | train |
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):
"""
Get the PID file path.
"""
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 | train |
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 ):
"""
Put a PID into a pidfile
"""
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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | get_logfile_path | def get_logfile_path(working_dir):
"""
Get the logfile path for our service endpoint.
"""
logfile_filename = virtualchain_hooks.get_virtual_chain_name() + ".log"
return os.path.join( working_dir, logfile_filename ) | python | def get_logfile_path(working_dir):
"""
Get the logfile path for our service endpoint.
"""
logfile_filename = virtualchain_hooks.get_virtual_chain_name() + ".log"
return os.path.join( working_dir, logfile_filename ) | [
"def",
"get_logfile_path",
"(",
"working_dir",
")",
":",
"logfile_filename",
"=",
"virtualchain_hooks",
".",
"get_virtual_chain_name",
"(",
")",
"+",
"\".log\"",
"return",
"os",
".",
"path",
".",
"join",
"(",
"working_dir",
",",
"logfile_filename",
")"
] | Get the logfile path for our service endpoint. | [
"Get",
"the",
"logfile",
"path",
"for",
"our",
"service",
"endpoint",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L155-L160 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | get_index_range | def get_index_range(working_dir):
"""
Get the bitcoin block index range.
Mask connection failures with timeouts.
Always try to reconnect.
The last block will be the last block to search for names.
This will be NUM_CONFIRMATIONS behind the actual last-block the
cryptocurrency node knows abou... | python | def get_index_range(working_dir):
"""
Get the bitcoin block index range.
Mask connection failures with timeouts.
Always try to reconnect.
The last block will be the last block to search for names.
This will be NUM_CONFIRMATIONS behind the actual last-block the
cryptocurrency node knows abou... | [
"def",
"get_index_range",
"(",
"working_dir",
")",
":",
"bitcoind_session",
"=",
"get_bitcoind",
"(",
"new",
"=",
"True",
")",
"assert",
"bitcoind_session",
"is",
"not",
"None",
"first_block",
"=",
"None",
"last_block",
"=",
"None",
"wait",
"=",
"1.0",
"while"... | Get the bitcoin block index range.
Mask connection failures with timeouts.
Always try to reconnect.
The last block will be the last block to search for names.
This will be NUM_CONFIRMATIONS behind the actual last-block the
cryptocurrency node knows about. | [
"Get",
"the",
"bitcoin",
"block",
"index",
"range",
".",
"Mask",
"connection",
"failures",
"with",
"timeouts",
".",
"Always",
"try",
"to",
"reconnect",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L163-L197 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | rpc_start | def rpc_start( working_dir, port, subdomain_index=None, thread=True ):
"""
Start the global RPC server thread
Returns the RPC server thread
"""
rpc_srv = BlockstackdRPCServer( working_dir, port, subdomain_index=subdomain_index )
log.debug("Starting RPC on port {}".format(port))
if thread:
... | python | def rpc_start( working_dir, port, subdomain_index=None, thread=True ):
"""
Start the global RPC server thread
Returns the RPC server thread
"""
rpc_srv = BlockstackdRPCServer( working_dir, port, subdomain_index=subdomain_index )
log.debug("Starting RPC on port {}".format(port))
if thread:
... | [
"def",
"rpc_start",
"(",
"working_dir",
",",
"port",
",",
"subdomain_index",
"=",
"None",
",",
"thread",
"=",
"True",
")",
":",
"rpc_srv",
"=",
"BlockstackdRPCServer",
"(",
"working_dir",
",",
"port",
",",
"subdomain_index",
"=",
"subdomain_index",
")",
"log",... | Start the global RPC server thread
Returns the RPC server thread | [
"Start",
"the",
"global",
"RPC",
"server",
"thread",
"Returns",
"the",
"RPC",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2079-L2090 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | rpc_chain_sync | def rpc_chain_sync(server_state, new_block_height, finish_time):
"""
Flush the global RPC server cache, and tell the rpc server that we've
reached the given block height at the given time.
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
rpc_srv.cache_flush()
rpc_srv.set... | python | def rpc_chain_sync(server_state, new_block_height, finish_time):
"""
Flush the global RPC server cache, and tell the rpc server that we've
reached the given block height at the given time.
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
rpc_srv.cache_flush()
rpc_srv.set... | [
"def",
"rpc_chain_sync",
"(",
"server_state",
",",
"new_block_height",
",",
"finish_time",
")",
":",
"rpc_srv",
"=",
"server_state",
"[",
"'rpc'",
"]",
"if",
"rpc_srv",
"is",
"not",
"None",
":",
"rpc_srv",
".",
"cache_flush",
"(",
")",
"rpc_srv",
".",
"set_l... | Flush the global RPC server cache, and tell the rpc server that we've
reached the given block height at the given time. | [
"Flush",
"the",
"global",
"RPC",
"server",
"cache",
"and",
"tell",
"the",
"rpc",
"server",
"that",
"we",
"ve",
"reached",
"the",
"given",
"block",
"height",
"at",
"the",
"given",
"time",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2093-L2101 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | rpc_stop | def rpc_stop(server_state):
"""
Stop the global RPC server thread
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
log.info("Shutting down RPC")
rpc_srv.stop_server()
rpc_srv.join()
log.info("RPC joined")
else:
log.info("RPC already joined")
... | python | def rpc_stop(server_state):
"""
Stop the global RPC server thread
"""
rpc_srv = server_state['rpc']
if rpc_srv is not None:
log.info("Shutting down RPC")
rpc_srv.stop_server()
rpc_srv.join()
log.info("RPC joined")
else:
log.info("RPC already joined")
... | [
"def",
"rpc_stop",
"(",
"server_state",
")",
":",
"rpc_srv",
"=",
"server_state",
"[",
"'rpc'",
"]",
"if",
"rpc_srv",
"is",
"not",
"None",
":",
"log",
".",
"info",
"(",
"\"Shutting down RPC\"",
")",
"rpc_srv",
".",
"stop_server",
"(",
")",
"rpc_srv",
".",
... | Stop the global RPC server thread | [
"Stop",
"the",
"global",
"RPC",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2104-L2119 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | gc_stop | def gc_stop():
"""
Stop a the optimistic GC thread
"""
global gc_thread
if gc_thread:
log.info("Shutting down GC thread")
gc_thread.signal_stop()
gc_thread.join()
log.info("GC thread joined")
gc_thread = None
else:
log.info("GC thread already ... | python | def gc_stop():
"""
Stop a the optimistic GC thread
"""
global gc_thread
if gc_thread:
log.info("Shutting down GC thread")
gc_thread.signal_stop()
gc_thread.join()
log.info("GC thread joined")
gc_thread = None
else:
log.info("GC thread already ... | [
"def",
"gc_stop",
"(",
")",
":",
"global",
"gc_thread",
"if",
"gc_thread",
":",
"log",
".",
"info",
"(",
"\"Shutting down GC thread\"",
")",
"gc_thread",
".",
"signal_stop",
"(",
")",
"gc_thread",
".",
"join",
"(",
")",
"log",
".",
"info",
"(",
"\"GC threa... | Stop a the optimistic GC thread | [
"Stop",
"a",
"the",
"optimistic",
"GC",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2133-L2146 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | api_start | def api_start(working_dir, host, port, thread=True):
"""
Start the global API server
Returns the API server thread
"""
api_srv = BlockstackdAPIServer( working_dir, host, port )
log.info("Starting API server on port {}".format(port))
if thread:
api_srv.start()
return api_srv | python | def api_start(working_dir, host, port, thread=True):
"""
Start the global API server
Returns the API server thread
"""
api_srv = BlockstackdAPIServer( working_dir, host, port )
log.info("Starting API server on port {}".format(port))
if thread:
api_srv.start()
return api_srv | [
"def",
"api_start",
"(",
"working_dir",
",",
"host",
",",
"port",
",",
"thread",
"=",
"True",
")",
":",
"api_srv",
"=",
"BlockstackdAPIServer",
"(",
"working_dir",
",",
"host",
",",
"port",
")",
"log",
".",
"info",
"(",
"\"Starting API server on port {}\"",
... | Start the global API server
Returns the API server thread | [
"Start",
"the",
"global",
"API",
"server",
"Returns",
"the",
"API",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2157-L2167 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | api_stop | def api_stop(server_state):
"""
Stop the global API server thread
"""
api_srv = server_state['api']
if api_srv is not None:
log.info("Shutting down API")
api_srv.stop_server()
api_srv.join()
log.info("API server joined")
else:
log.info("API already joined... | python | def api_stop(server_state):
"""
Stop the global API server thread
"""
api_srv = server_state['api']
if api_srv is not None:
log.info("Shutting down API")
api_srv.stop_server()
api_srv.join()
log.info("API server joined")
else:
log.info("API already joined... | [
"def",
"api_stop",
"(",
"server_state",
")",
":",
"api_srv",
"=",
"server_state",
"[",
"'api'",
"]",
"if",
"api_srv",
"is",
"not",
"None",
":",
"log",
".",
"info",
"(",
"\"Shutting down API\"",
")",
"api_srv",
".",
"stop_server",
"(",
")",
"api_srv",
".",
... | Stop the global API server thread | [
"Stop",
"the",
"global",
"API",
"server",
"thread"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2170-L2184 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | atlas_init | def atlas_init(blockstack_opts, db, recover=False, port=None):
"""
Start up atlas functionality
"""
if port is None:
port = blockstack_opts['rpc_port']
# start atlas node
atlas_state = None
if is_atlas_enabled(blockstack_opts):
atlas_seed_peers = filter( lambda x: len(x) > 0... | python | def atlas_init(blockstack_opts, db, recover=False, port=None):
"""
Start up atlas functionality
"""
if port is None:
port = blockstack_opts['rpc_port']
# start atlas node
atlas_state = None
if is_atlas_enabled(blockstack_opts):
atlas_seed_peers = filter( lambda x: len(x) > 0... | [
"def",
"atlas_init",
"(",
"blockstack_opts",
",",
"db",
",",
"recover",
"=",
"False",
",",
"port",
"=",
"None",
")",
":",
"if",
"port",
"is",
"None",
":",
"port",
"=",
"blockstack_opts",
"[",
"'rpc_port'",
"]",
"atlas_state",
"=",
"None",
"if",
"is_atlas... | Start up atlas functionality | [
"Start",
"up",
"atlas",
"functionality"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2187-L2208 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | read_pid_file | def read_pid_file(pidfile_path):
"""
Read the PID from the PID file
"""
try:
fin = open(pidfile_path, "r")
except Exception, e:
return None
else:
pid_data = fin.read().strip()
fin.close()
try:
pid = int(pid_data)
return pid
... | python | def read_pid_file(pidfile_path):
"""
Read the PID from the PID file
"""
try:
fin = open(pidfile_path, "r")
except Exception, e:
return None
else:
pid_data = fin.read().strip()
fin.close()
try:
pid = int(pid_data)
return pid
... | [
"def",
"read_pid_file",
"(",
"pidfile_path",
")",
":",
"try",
":",
"fin",
"=",
"open",
"(",
"pidfile_path",
",",
"\"r\"",
")",
"except",
"Exception",
",",
"e",
":",
"return",
"None",
"else",
":",
"pid_data",
"=",
"fin",
".",
"read",
"(",
")",
".",
"s... | Read the PID from the PID file | [
"Read",
"the",
"PID",
"from",
"the",
"PID",
"file"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2220-L2238 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | check_server_running | def check_server_running(pid):
"""
Determine if the given process is running
"""
if pid == os.getpid():
# special case--we're in Docker or some other kind of container
# (or we got really unlucky and got the same PID twice).
# this PID does not correspond to another running serve... | python | def check_server_running(pid):
"""
Determine if the given process is running
"""
if pid == os.getpid():
# special case--we're in Docker or some other kind of container
# (or we got really unlucky and got the same PID twice).
# this PID does not correspond to another running serve... | [
"def",
"check_server_running",
"(",
"pid",
")",
":",
"if",
"pid",
"==",
"os",
".",
"getpid",
"(",
")",
":",
"return",
"False",
"try",
":",
"os",
".",
"kill",
"(",
"pid",
",",
"0",
")",
"return",
"True",
"except",
"OSError",
"as",
"oe",
":",
"if",
... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | stop_server | def stop_server( working_dir, clean=False, kill=False ):
"""
Stop the blockstackd server.
"""
timeout = 1.0
dead = False
for i in xrange(0, 5):
# try to kill the main supervisor
pid_file = get_pidfile_path(working_dir)
if not os.path.exists(pid_file):
dead =... | python | def stop_server( working_dir, clean=False, kill=False ):
"""
Stop the blockstackd server.
"""
timeout = 1.0
dead = False
for i in xrange(0, 5):
# try to kill the main supervisor
pid_file = get_pidfile_path(working_dir)
if not os.path.exists(pid_file):
dead =... | [
"def",
"stop_server",
"(",
"working_dir",
",",
"clean",
"=",
"False",
",",
"kill",
"=",
"False",
")",
":",
"timeout",
"=",
"1.0",
"dead",
"=",
"False",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"5",
")",
":",
"pid_file",
"=",
"get_pidfile_path",
"("... | Stop the blockstackd server. | [
"Stop",
"the",
"blockstackd",
"server",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2261-L2340 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | genesis_block_load | def genesis_block_load(module_path=None):
"""
Make sure the genesis block is good to go.
Load and instantiate it.
"""
if os.environ.get('BLOCKSTACK_GENESIS_BLOCK_PATH') is not None:
log.warning('Using envar-given genesis block')
module_path = os.environ['BLOCKSTACK_GENESIS_BLOCK_PATH... | python | def genesis_block_load(module_path=None):
"""
Make sure the genesis block is good to go.
Load and instantiate it.
"""
if os.environ.get('BLOCKSTACK_GENESIS_BLOCK_PATH') is not None:
log.warning('Using envar-given genesis block')
module_path = os.environ['BLOCKSTACK_GENESIS_BLOCK_PATH... | [
"def",
"genesis_block_load",
"(",
"module_path",
"=",
"None",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'BLOCKSTACK_GENESIS_BLOCK_PATH'",
")",
"is",
"not",
"None",
":",
"log",
".",
"warning",
"(",
"'Using envar-given genesis block'",
")",
"module_p... | Make sure the genesis block is good to go.
Load and instantiate it. | [
"Make",
"sure",
"the",
"genesis",
"block",
"is",
"good",
"to",
"go",
".",
"Load",
"and",
"instantiate",
"it",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2431-L2484 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | server_setup | def server_setup(working_dir, port=None, api_port=None, indexer_enabled=None, indexer_url=None, api_enabled=None, recover=False):
"""
Set up the server.
Start all subsystems, write pid file, set up signal handlers, set up DB.
Returns a server instance.
"""
if not is_genesis_block_instantiated():... | python | def server_setup(working_dir, port=None, api_port=None, indexer_enabled=None, indexer_url=None, api_enabled=None, recover=False):
"""
Set up the server.
Start all subsystems, write pid file, set up signal handlers, set up DB.
Returns a server instance.
"""
if not is_genesis_block_instantiated():... | [
"def",
"server_setup",
"(",
"working_dir",
",",
"port",
"=",
"None",
",",
"api_port",
"=",
"None",
",",
"indexer_enabled",
"=",
"None",
",",
"indexer_url",
"=",
"None",
",",
"api_enabled",
"=",
"None",
",",
"recover",
"=",
"False",
")",
":",
"if",
"not",... | Set up the server.
Start all subsystems, write pid file, set up signal handlers, set up DB.
Returns a server instance. | [
"Set",
"up",
"the",
"server",
".",
"Start",
"all",
"subsystems",
"write",
"pid",
"file",
"set",
"up",
"signal",
"handlers",
"set",
"up",
"DB",
".",
"Returns",
"a",
"server",
"instance",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2487-L2599 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | server_shutdown | def server_shutdown(server_state):
"""
Shut down server subsystems.
Remove PID file.
"""
set_running( False )
# stop API servers
rpc_stop(server_state)
api_stop(server_state)
# stop atlas node
server_atlas_shutdown(server_state)
# stopping GC
gc_stop()
# clear PID... | python | def server_shutdown(server_state):
"""
Shut down server subsystems.
Remove PID file.
"""
set_running( False )
# stop API servers
rpc_stop(server_state)
api_stop(server_state)
# stop atlas node
server_atlas_shutdown(server_state)
# stopping GC
gc_stop()
# clear PID... | [
"def",
"server_shutdown",
"(",
"server_state",
")",
":",
"set_running",
"(",
"False",
")",
"rpc_stop",
"(",
"server_state",
")",
"api_stop",
"(",
"server_state",
")",
"server_atlas_shutdown",
"(",
"server_state",
")",
"gc_stop",
"(",
")",
"try",
":",
"if",
"os... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | run_server | def run_server(working_dir, foreground=False, expected_snapshots=GENESIS_SNAPSHOT, port=None, api_port=None, use_api=None, use_indexer=None, indexer_url=None, recover=False):
"""
Run blockstackd. Optionally daemonize.
Return 0 on success
Return negative on error
"""
global rpc_server
global... | python | def run_server(working_dir, foreground=False, expected_snapshots=GENESIS_SNAPSHOT, port=None, api_port=None, use_api=None, use_indexer=None, indexer_url=None, recover=False):
"""
Run blockstackd. Optionally daemonize.
Return 0 on success
Return negative on error
"""
global rpc_server
global... | [
"def",
"run_server",
"(",
"working_dir",
",",
"foreground",
"=",
"False",
",",
"expected_snapshots",
"=",
"GENESIS_SNAPSHOT",
",",
"port",
"=",
"None",
",",
"api_port",
"=",
"None",
",",
"use_api",
"=",
"None",
",",
"use_indexer",
"=",
"None",
",",
"indexer_... | Run blockstackd. Optionally daemonize.
Return 0 on success
Return negative on error | [
"Run",
"blockstackd",
".",
"Optionally",
"daemonize",
".",
"Return",
"0",
"on",
"success",
"Return",
"negative",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2641-L2716 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | setup | def setup(working_dir, interactive=False):
"""
Do one-time initialization.
Call this to set up global state.
"""
# set up our implementation
log.debug("Working dir: {}".format(working_dir))
if not os.path.exists( working_dir ):
os.makedirs( working_dir, 0700 )
node_config = load... | python | def setup(working_dir, interactive=False):
"""
Do one-time initialization.
Call this to set up global state.
"""
# set up our implementation
log.debug("Working dir: {}".format(working_dir))
if not os.path.exists( working_dir ):
os.makedirs( working_dir, 0700 )
node_config = load... | [
"def",
"setup",
"(",
"working_dir",
",",
"interactive",
"=",
"False",
")",
":",
"log",
".",
"debug",
"(",
"\"Working dir: {}\"",
".",
"format",
"(",
"working_dir",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"working_dir",
")",
":",
"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | reconfigure | def reconfigure(working_dir):
"""
Reconfigure blockstackd.
"""
configure(working_dir, force=True, interactive=True)
print "Blockstack successfully reconfigured."
sys.exit(0) | python | def reconfigure(working_dir):
"""
Reconfigure blockstackd.
"""
configure(working_dir, force=True, interactive=True)
print "Blockstack successfully reconfigured."
sys.exit(0) | [
"def",
"reconfigure",
"(",
"working_dir",
")",
":",
"configure",
"(",
"working_dir",
",",
"force",
"=",
"True",
",",
"interactive",
"=",
"True",
")",
"print",
"\"Blockstack successfully reconfigured.\"",
"sys",
".",
"exit",
"(",
"0",
")"
] | Reconfigure blockstackd. | [
"Reconfigure",
"blockstackd",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2737-L2743 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | verify_database | def verify_database(trusted_consensus_hash, consensus_block_height, untrusted_working_dir, trusted_working_dir, start_block=None, expected_snapshots={}):
"""
Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not
"""
db = BlockstackDB... | python | def verify_database(trusted_consensus_hash, consensus_block_height, untrusted_working_dir, trusted_working_dir, start_block=None, expected_snapshots={}):
"""
Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not
"""
db = BlockstackDB... | [
"def",
"verify_database",
"(",
"trusted_consensus_hash",
",",
"consensus_block_height",
",",
"untrusted_working_dir",
",",
"trusted_working_dir",
",",
"start_block",
"=",
"None",
",",
"expected_snapshots",
"=",
"{",
"}",
")",
":",
"db",
"=",
"BlockstackDB",
".",
"ge... | Verify that a database is consistent with a
known-good consensus hash.
Return True if valid.
Return False if not | [
"Verify",
"that",
"a",
"database",
"is",
"consistent",
"with",
"a",
"known",
"-",
"good",
"consensus",
"hash",
".",
"Return",
"True",
"if",
"valid",
".",
"Return",
"False",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2746-L2755 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | check_and_set_envars | def check_and_set_envars( argv ):
"""
Go through argv and find any special command-line flags
that set environment variables that affect multiple modules.
If any of them are given, then set them in this process's
environment and re-exec the process without the CLI flags.
argv should be like sy... | python | def check_and_set_envars( argv ):
"""
Go through argv and find any special command-line flags
that set environment variables that affect multiple modules.
If any of them are given, then set them in this process's
environment and re-exec the process without the CLI flags.
argv should be like sy... | [
"def",
"check_and_set_envars",
"(",
"argv",
")",
":",
"special_flags",
"=",
"{",
"'--debug'",
":",
"{",
"'arg'",
":",
"False",
",",
"'envar'",
":",
"'BLOCKSTACK_DEBUG'",
",",
"'exec'",
":",
"True",
",",
"}",
",",
"'--verbose'",
":",
"{",
"'arg'",
":",
"F... | Go through argv and find any special command-line flags
that set environment variables that affect multiple modules.
If any of them are given, then set them in this process's
environment and re-exec the process without the CLI flags.
argv should be like sys.argv: argv[0] is the binary
Does not r... | [
"Go",
"through",
"argv",
"and",
"find",
"any",
"special",
"command",
"-",
"line",
"flags",
"that",
"set",
"environment",
"variables",
"that",
"affect",
"multiple",
"modules",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2758-L2875 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | load_expected_snapshots | def load_expected_snapshots( snapshots_path ):
"""
Load expected consensus hashes from a .snapshots file.
Return the snapshots as a dict on success
Return None on error
"""
# use snapshots?
snapshots_path = os.path.expanduser(snapshots_path)
expected_snapshots = {}
# legacy chainsta... | python | def load_expected_snapshots( snapshots_path ):
"""
Load expected consensus hashes from a .snapshots file.
Return the snapshots as a dict on success
Return None on error
"""
# use snapshots?
snapshots_path = os.path.expanduser(snapshots_path)
expected_snapshots = {}
# legacy chainsta... | [
"def",
"load_expected_snapshots",
"(",
"snapshots_path",
")",
":",
"snapshots_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"snapshots_path",
")",
"expected_snapshots",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"snapshots_path",
",",
"\"r\"",
")... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | do_genesis_block_audit | def do_genesis_block_audit(genesis_block_path=None, key_id=None):
"""
Loads and audits the genesis block, optionally using an alternative key
"""
signing_keys = GENESIS_BLOCK_SIGNING_KEYS
if genesis_block_path is not None:
# alternative genesis block
genesis_block_load(genesis_block_... | python | def do_genesis_block_audit(genesis_block_path=None, key_id=None):
"""
Loads and audits the genesis block, optionally using an alternative key
"""
signing_keys = GENESIS_BLOCK_SIGNING_KEYS
if genesis_block_path is not None:
# alternative genesis block
genesis_block_load(genesis_block_... | [
"def",
"do_genesis_block_audit",
"(",
"genesis_block_path",
"=",
"None",
",",
"key_id",
"=",
"None",
")",
":",
"signing_keys",
"=",
"GENESIS_BLOCK_SIGNING_KEYS",
"if",
"genesis_block_path",
"is",
"not",
"None",
":",
"genesis_block_load",
"(",
"genesis_block_path",
")"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | setup_recovery | def setup_recovery(working_dir):
"""
Set up the recovery metadata so we can fully recover secondary state,
like subdomains.
"""
db = get_db_state(working_dir)
bitcoind_session = get_bitcoind(new=True)
assert bitcoind_session is not None
_, current_block = virtualchain.get_index_range('b... | python | def setup_recovery(working_dir):
"""
Set up the recovery metadata so we can fully recover secondary state,
like subdomains.
"""
db = get_db_state(working_dir)
bitcoind_session = get_bitcoind(new=True)
assert bitcoind_session is not None
_, current_block = virtualchain.get_index_range('b... | [
"def",
"setup_recovery",
"(",
"working_dir",
")",
":",
"db",
"=",
"get_db_state",
"(",
"working_dir",
")",
"bitcoind_session",
"=",
"get_bitcoind",
"(",
"new",
"=",
"True",
")",
"assert",
"bitcoind_session",
"is",
"not",
"None",
"_",
",",
"current_block",
"=",... | Set up the recovery metadata so we can fully recover secondary state,
like subdomains. | [
"Set",
"up",
"the",
"recovery",
"metadata",
"so",
"we",
"can",
"fully",
"recover",
"secondary",
"state",
"like",
"subdomains",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2954-L2967 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | check_recovery | def check_recovery(working_dir):
"""
Do we need to recover on start-up?
"""
recovery_start_block, recovery_end_block = get_recovery_range(working_dir)
if recovery_start_block is not None and recovery_end_block is not None:
local_current_block = virtualchain_hooks.get_last_block(working_dir)
... | python | def check_recovery(working_dir):
"""
Do we need to recover on start-up?
"""
recovery_start_block, recovery_end_block = get_recovery_range(working_dir)
if recovery_start_block is not None and recovery_end_block is not None:
local_current_block = virtualchain_hooks.get_last_block(working_dir)
... | [
"def",
"check_recovery",
"(",
"working_dir",
")",
":",
"recovery_start_block",
",",
"recovery_end_block",
"=",
"get_recovery_range",
"(",
"working_dir",
")",
"if",
"recovery_start_block",
"is",
"not",
"None",
"and",
"recovery_end_block",
"is",
"not",
"None",
":",
"l... | Do we need to recover on start-up? | [
"Do",
"we",
"need",
"to",
"recover",
"on",
"start",
"-",
"up?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2970-L2987 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.success_response | def success_response(self, method_resp, **kw):
"""
Make a standard "success" response,
which contains some ancilliary data.
Also, detect if this node is too far behind the Bitcoin blockchain,
and if so, convert this into an error message.
"""
resp = {
... | python | def success_response(self, method_resp, **kw):
"""
Make a standard "success" response,
which contains some ancilliary data.
Also, detect if this node is too far behind the Bitcoin blockchain,
and if so, convert this into an error message.
"""
resp = {
... | [
"def",
"success_response",
"(",
"self",
",",
"method_resp",
",",
"**",
"kw",
")",
":",
"resp",
"=",
"{",
"'status'",
":",
"True",
",",
"'indexing'",
":",
"config",
".",
"is_indexing",
"(",
"self",
".",
"working_dir",
")",
",",
"'lastblock'",
":",
"virtua... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.load_name_info | def load_name_info(self, db, name_record):
"""
Get some extra name information, given a db-loaded name record.
Return the updated name_record
"""
name = str(name_record['name'])
name_record = self.sanitize_rec(name_record)
namespace_id = get_namespace_from_name(n... | python | def load_name_info(self, db, name_record):
"""
Get some extra name information, given a db-loaded name record.
Return the updated name_record
"""
name = str(name_record['name'])
name_record = self.sanitize_rec(name_record)
namespace_id = get_namespace_from_name(n... | [
"def",
"load_name_info",
"(",
"self",
",",
"db",
",",
"name_record",
")",
":",
"name",
"=",
"str",
"(",
"name_record",
"[",
"'name'",
"]",
")",
"name_record",
"=",
"self",
".",
"sanitize_rec",
"(",
"name_record",
")",
"namespace_id",
"=",
"get_namespace_from... | Get some extra name information, given a db-loaded name record.
Return the updated name_record | [
"Get",
"some",
"extra",
"name",
"information",
"given",
"a",
"db",
"-",
"loaded",
"name",
"record",
".",
"Return",
"the",
"updated",
"name_record"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L574-L620 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_name_DID_info | def get_name_DID_info(self, name):
"""
Get a name's DID info
Returns None if not found
"""
db = get_db_state(self.working_dir)
did_info = db.get_name_DID_info(name)
if did_info is None:
return {'error': 'No such name', 'http_status': 404}
retu... | python | def get_name_DID_info(self, name):
"""
Get a name's DID info
Returns None if not found
"""
db = get_db_state(self.working_dir)
did_info = db.get_name_DID_info(name)
if did_info is None:
return {'error': 'No such name', 'http_status': 404}
retu... | [
"def",
"get_name_DID_info",
"(",
"self",
",",
"name",
")",
":",
"db",
"=",
"get_db_state",
"(",
"self",
".",
"working_dir",
")",
"did_info",
"=",
"db",
".",
"get_name_DID_info",
"(",
"name",
")",
"if",
"did_info",
"is",
"None",
":",
"return",
"{",
"'erro... | Get a name's DID info
Returns None if not found | [
"Get",
"a",
"name",
"s",
"DID",
"info",
"Returns",
"None",
"if",
"not",
"found"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L712-L722 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_name_DID | def rpc_get_name_DID(self, name, **con_info):
"""
Given a name or subdomain, return its DID.
"""
did_info = None
if check_name(name):
did_info = self.get_name_DID_info(name)
elif check_subdomain(name):
did_info = self.get_subdomain_DID_info(name)
... | python | def rpc_get_name_DID(self, name, **con_info):
"""
Given a name or subdomain, return its DID.
"""
did_info = None
if check_name(name):
did_info = self.get_name_DID_info(name)
elif check_subdomain(name):
did_info = self.get_subdomain_DID_info(name)
... | [
"def",
"rpc_get_name_DID",
"(",
"self",
",",
"name",
",",
"**",
"con_info",
")",
":",
"did_info",
"=",
"None",
"if",
"check_name",
"(",
"name",
")",
":",
"did_info",
"=",
"self",
".",
"get_name_DID_info",
"(",
"name",
")",
"elif",
"check_subdomain",
"(",
... | Given a name or subdomain, return its DID. | [
"Given",
"a",
"name",
"or",
"subdomain",
"return",
"its",
"DID",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L734-L750 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_DID_record | def rpc_get_DID_record(self, did, **con_info):
"""
Given a DID, return the name or subdomain it corresponds to
"""
if not isinstance(did, (str,unicode)):
return {'error': 'Invalid DID: not a string', 'http_status': 400}
try:
did_info = parse_DID(did)
... | python | def rpc_get_DID_record(self, did, **con_info):
"""
Given a DID, return the name or subdomain it corresponds to
"""
if not isinstance(did, (str,unicode)):
return {'error': 'Invalid DID: not a string', 'http_status': 400}
try:
did_info = parse_DID(did)
... | [
"def",
"rpc_get_DID_record",
"(",
"self",
",",
"did",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"isinstance",
"(",
"did",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid DID: not a string'",
",",
"'http_status'"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_blockstack_ops_at | def rpc_get_blockstack_ops_at(self, block_id, offset, count, **con_info):
"""
Get the name operations that occured in the given block.
Does not include account operations.
Returns {'nameops': [...]} on success.
Returns {'error': ...} on error
"""
if not check_blo... | python | def rpc_get_blockstack_ops_at(self, block_id, offset, count, **con_info):
"""
Get the name operations that occured in the given block.
Does not include account operations.
Returns {'nameops': [...]} on success.
Returns {'error': ...} on error
"""
if not check_blo... | [
"def",
"rpc_get_blockstack_ops_at",
"(",
"self",
",",
"block_id",
",",
"offset",
",",
"count",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"check_block",
"(",
"block_id",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid block height'",
",",
"'http_status'"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_blockstack_ops_hash_at | def rpc_get_blockstack_ops_hash_at( self, block_id, **con_info ):
"""
Get the hash over the sequence of names and namespaces altered at the given block.
Used by SNV clients.
Returns {'status': True, 'ops_hash': ops_hash} on success
Returns {'error': ...} on error
"""
... | python | def rpc_get_blockstack_ops_hash_at( self, block_id, **con_info ):
"""
Get the hash over the sequence of names and namespaces altered at the given block.
Used by SNV clients.
Returns {'status': True, 'ops_hash': ops_hash} on success
Returns {'error': ...} on error
"""
... | [
"def",
"rpc_get_blockstack_ops_hash_at",
"(",
"self",
",",
"block_id",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"check_block",
"(",
"block_id",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid block height'",
",",
"'http_status'",
":",
"400",
"}",
"db",... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_bitcoind_info | def get_bitcoind_info(self):
"""
Get bitcoind info. Try the cache, and on cache miss,
fetch from bitcoind and cache.
"""
cached_bitcoind_info = self.get_cached_bitcoind_info()
if cached_bitcoind_info:
return cached_bitcoind_info
bitcoind_opts = defa... | python | def get_bitcoind_info(self):
"""
Get bitcoind info. Try the cache, and on cache miss,
fetch from bitcoind and cache.
"""
cached_bitcoind_info = self.get_cached_bitcoind_info()
if cached_bitcoind_info:
return cached_bitcoind_info
bitcoind_opts = defa... | [
"def",
"get_bitcoind_info",
"(",
"self",
")",
":",
"cached_bitcoind_info",
"=",
"self",
".",
"get_cached_bitcoind_info",
"(",
")",
"if",
"cached_bitcoind_info",
":",
"return",
"cached_bitcoind_info",
"bitcoind_opts",
"=",
"default_bitcoind_opts",
"(",
"virtualchain",
".... | Get bitcoind info. Try the cache, and on cache miss,
fetch from bitcoind and cache. | [
"Get",
"bitcoind",
"info",
".",
"Try",
"the",
"cache",
"and",
"on",
"cache",
"miss",
"fetch",
"from",
"bitcoind",
"and",
"cache",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1078-L1102 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_consensus_info | def get_consensus_info(self):
"""
Get block height and consensus hash. Try the cache, and
on cache miss, fetch from the db
"""
cached_consensus_info = self.get_cached_consensus_info()
if cached_consensus_info:
return cached_consensus_info
db = get_db... | python | def get_consensus_info(self):
"""
Get block height and consensus hash. Try the cache, and
on cache miss, fetch from the db
"""
cached_consensus_info = self.get_cached_consensus_info()
if cached_consensus_info:
return cached_consensus_info
db = get_db... | [
"def",
"get_consensus_info",
"(",
"self",
")",
":",
"cached_consensus_info",
"=",
"self",
".",
"get_cached_consensus_info",
"(",
")",
"if",
"cached_consensus_info",
":",
"return",
"cached_consensus_info",
"db",
"=",
"get_db_state",
"(",
"self",
".",
"working_dir",
"... | Get block height and consensus hash. Try the cache, and
on cache miss, fetch from the db | [
"Get",
"block",
"height",
"and",
"consensus",
"hash",
".",
"Try",
"the",
"cache",
"and",
"on",
"cache",
"miss",
"fetch",
"from",
"the",
"db"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1105-L1121 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_tokens | def rpc_get_account_tokens(self, address, **con_info):
"""
Get the types of tokens that an account owns
Returns the list on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
# must be b58
if is_... | python | def rpc_get_account_tokens(self, address, **con_info):
"""
Get the types of tokens that an account owns
Returns the list on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
# must be b58
if is_... | [
"def",
"rpc_get_account_tokens",
"(",
"self",
",",
"address",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",
"400",
"}",
"if",
"i... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_balance | def rpc_get_account_balance(self, address, token_type, **con_info):
"""
Get the balance of an address for a particular token type
Returns the value on success
Returns 0 if the balance is 0, or if there is no address
"""
if not check_account_address(address):
r... | python | def rpc_get_account_balance(self, address, token_type, **con_info):
"""
Get the balance of an address for a particular token type
Returns the value on success
Returns 0 if the balance is 0, or if there is no address
"""
if not check_account_address(address):
r... | [
"def",
"rpc_get_account_balance",
"(",
"self",
",",
"address",
",",
"token_type",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",
"4... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.export_account_state | def export_account_state(self, account_state):
"""
Make an account state presentable to external consumers
"""
return {
'address': account_state['address'],
'type': account_state['type'],
'credit_value': '{}'.format(account_state['credit_value']),
... | python | def export_account_state(self, account_state):
"""
Make an account state presentable to external consumers
"""
return {
'address': account_state['address'],
'type': account_state['type'],
'credit_value': '{}'.format(account_state['credit_value']),
... | [
"def",
"export_account_state",
"(",
"self",
",",
"account_state",
")",
":",
"return",
"{",
"'address'",
":",
"account_state",
"[",
"'address'",
"]",
",",
"'type'",
":",
"account_state",
"[",
"'type'",
"]",
",",
"'credit_value'",
":",
"'{}'",
".",
"format",
"... | Make an account state presentable to external consumers | [
"Make",
"an",
"account",
"state",
"presentable",
"to",
"external",
"consumers"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1347-L1360 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_record | def rpc_get_account_record(self, address, token_type, **con_info):
"""
Get the current state of an account
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_token_type(token_type):
return {'err... | python | def rpc_get_account_record(self, address, token_type, **con_info):
"""
Get the current state of an account
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status': 400}
if not check_token_type(token_type):
return {'err... | [
"def",
"rpc_get_account_record",
"(",
"self",
",",
"address",
",",
"token_type",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",
"40... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_account_at | def rpc_get_account_at(self, address, block_height, **con_info):
"""
Get the account's statuses at a particular block height.
Returns the sequence of history states on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status'... | python | def rpc_get_account_at(self, address, block_height, **con_info):
"""
Get the account's statuses at a particular block height.
Returns the sequence of history states on success
"""
if not check_account_address(address):
return {'error': 'Invalid address', 'http_status'... | [
"def",
"rpc_get_account_at",
"(",
"self",
",",
"address",
",",
"block_height",
",",
"**",
"con_info",
")",
":",
"if",
"not",
"check_account_address",
"(",
"address",
")",
":",
"return",
"{",
"'error'",
":",
"'Invalid address'",
",",
"'http_status'",
":",
"400"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_consensus_hashes | def rpc_get_consensus_hashes( self, block_id_list, **con_info ):
"""
Return the consensus hashes at multiple block numbers
Return a dict mapping each block ID to its consensus hash.
Returns {'status': True, 'consensus_hashes': dict} on success
Returns {'error': ...} on success
... | python | def rpc_get_consensus_hashes( self, block_id_list, **con_info ):
"""
Return the consensus hashes at multiple block numbers
Return a dict mapping each block ID to its consensus hash.
Returns {'status': True, 'consensus_hashes': dict} on success
Returns {'error': ...} on success
... | [
"def",
"rpc_get_consensus_hashes",
"(",
"self",
",",
"block_id_list",
",",
"**",
"con_info",
")",
":",
"if",
"type",
"(",
"block_id_list",
")",
"!=",
"list",
":",
"return",
"{",
"'error'",
":",
"'Invalid block heights'",
",",
"'http_status'",
":",
"400",
"}",
... | Return the consensus hashes at multiple block numbers
Return a dict mapping each block ID to its consensus hash.
Returns {'status': True, 'consensus_hashes': dict} on success
Returns {'error': ...} on success | [
"Return",
"the",
"consensus",
"hashes",
"at",
"multiple",
"block",
"numbers",
"Return",
"a",
"dict",
"mapping",
"each",
"block",
"ID",
"to",
"its",
"consensus",
"hash",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1653-L1678 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.get_zonefile_data | def get_zonefile_data( self, zonefile_hash, zonefile_dir ):
"""
Get a zonefile by hash
Return the serialized zonefile on success
Return None on error
"""
# check cache
atlas_zonefile_data = get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=False )
... | python | def get_zonefile_data( self, zonefile_hash, zonefile_dir ):
"""
Get a zonefile by hash
Return the serialized zonefile on success
Return None on error
"""
# check cache
atlas_zonefile_data = get_atlas_zonefile_data( zonefile_hash, zonefile_dir, check=False )
... | [
"def",
"get_zonefile_data",
"(",
"self",
",",
"zonefile_hash",
",",
"zonefile_dir",
")",
":",
"atlas_zonefile_data",
"=",
"get_atlas_zonefile_data",
"(",
"zonefile_hash",
",",
"zonefile_dir",
",",
"check",
"=",
"False",
")",
"if",
"atlas_zonefile_data",
"is",
"not",... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_get_zonefiles_by_block | def rpc_get_zonefiles_by_block( self, from_block, to_block, offset, count, **con_info ):
"""
Get information about zonefiles announced in blocks [@from_block, @to_block]
@offset - offset into result set
@count - max records to return, must be <= 100
Returns {'status': True, 'last... | python | def rpc_get_zonefiles_by_block( self, from_block, to_block, offset, count, **con_info ):
"""
Get information about zonefiles announced in blocks [@from_block, @to_block]
@offset - offset into result set
@count - max records to return, must be <= 100
Returns {'status': True, 'last... | [
"def",
"rpc_get_zonefiles_by_block",
"(",
"self",
",",
"from_block",
",",
"to_block",
",",
"offset",
",",
"count",
",",
"**",
"con_info",
")",
":",
"conf",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_atlas_enabled",
"(",
"conf",
")",
":",
"return"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.peer_exchange | def peer_exchange(self, peer_host, peer_port):
"""
Exchange peers.
Add the given peer to the list of new peers to consider.
Return the list of healthy peers
"""
# get peers
peer_list = atlas_get_live_neighbors( "%s:%s" % (peer_host, peer_port) )
if len(pee... | python | def peer_exchange(self, peer_host, peer_port):
"""
Exchange peers.
Add the given peer to the list of new peers to consider.
Return the list of healthy peers
"""
# get peers
peer_list = atlas_get_live_neighbors( "%s:%s" % (peer_host, peer_port) )
if len(pee... | [
"def",
"peer_exchange",
"(",
"self",
",",
"peer_host",
",",
"peer_port",
")",
":",
"peer_list",
"=",
"atlas_get_live_neighbors",
"(",
"\"%s:%s\"",
"%",
"(",
"peer_host",
",",
"peer_port",
")",
")",
"if",
"len",
"(",
"peer_list",
")",
">",
"atlas_max_neighbors"... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPC.rpc_atlas_peer_exchange | def rpc_atlas_peer_exchange(self, remote_peer, **con_info):
"""
Accept a remotely-given atlas peer, and return our list
of healthy peers. The remotely-given atlas peer will only
be considered if the caller is localhost; otherwise, the caller's
socket-given information will be us... | python | def rpc_atlas_peer_exchange(self, remote_peer, **con_info):
"""
Accept a remotely-given atlas peer, and return our list
of healthy peers. The remotely-given atlas peer will only
be considered if the caller is localhost; otherwise, the caller's
socket-given information will be us... | [
"def",
"rpc_atlas_peer_exchange",
"(",
"self",
",",
"remote_peer",
",",
"**",
"con_info",
")",
":",
"conf",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"conf",
".",
"get",
"(",
"'atlas'",
",",
"False",
")",
":",
"return",
"{",
"'error'",
":",
"'No... | 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 | train |
blockstack/blockstack-core | blockstack/blockstackd.py | BlockstackdRPCServer.stop_server | def stop_server(self):
"""
Stop serving. Also stops the thread.
"""
if self.rpc_server is not None:
try:
self.rpc_server.socket.shutdown(socket.SHUT_RDWR)
except:
log.warning("Failed to shut down server socket")
self.r... | python | def stop_server(self):
"""
Stop serving. Also stops the thread.
"""
if self.rpc_server is not None:
try:
self.rpc_server.socket.shutdown(socket.SHUT_RDWR)
except:
log.warning("Failed to shut down server socket")
self.r... | [
"def",
"stop_server",
"(",
"self",
")",
":",
"if",
"self",
".",
"rpc_server",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"rpc_server",
".",
"socket",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"except",
":",
"log",
".",
"warning",
... | Stop serving. Also stops the thread. | [
"Stop",
"serving",
".",
"Also",
"stops",
"the",
"thread",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L2017-L2027 | train |
blockstack/blockstack-core | blockstack/lib/nameset/virtualchain_hooks.py | get_last_block | def get_last_block(working_dir):
"""
Get the last block processed
Return the integer on success
Return None on error
"""
# make this usable even if we haven't explicitly configured virtualchain
impl = sys.modules[__name__]
return BlockstackDB.get_lastblock(impl, working_dir) | python | def get_last_block(working_dir):
"""
Get the last block processed
Return the integer on success
Return None on error
"""
# make this usable even if we haven't explicitly configured virtualchain
impl = sys.modules[__name__]
return BlockstackDB.get_lastblock(impl, working_dir) | [
"def",
"get_last_block",
"(",
"working_dir",
")",
":",
"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 | train |
blockstack/blockstack-core | blockstack/lib/nameset/virtualchain_hooks.py | get_or_instantiate_db_state | def get_or_instantiate_db_state(working_dir):
"""
Get a read-only handle to the DB.
Instantiate it first if it doesn't exist.
DO NOT CALL WHILE INDEXING
Returns the handle on success
Raises on error
"""
# instantiates
new_db = BlockstackDB.borrow_readwrite_instance(working_dir, -1... | python | def get_or_instantiate_db_state(working_dir):
"""
Get a read-only handle to the DB.
Instantiate it first if it doesn't exist.
DO NOT CALL WHILE INDEXING
Returns the handle on success
Raises on error
"""
# instantiates
new_db = BlockstackDB.borrow_readwrite_instance(working_dir, -1... | [
"def",
"get_or_instantiate_db_state",
"(",
"working_dir",
")",
":",
"new_db",
"=",
"BlockstackDB",
".",
"borrow_readwrite_instance",
"(",
"working_dir",
",",
"-",
"1",
")",
"BlockstackDB",
".",
"release_readwrite_instance",
"(",
"new_db",
",",
"-",
"1",
")",
"retu... | 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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.