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/scripts.py | check_account_address | def check_account_address(address):
"""
verify that a string is a valid account address.
Can be a b58-check address, a c32-check address, as well as the string "treasury" or "unallocated" or a string starting with 'not_distributed_'
>>> check_account_address('16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg')
Tr... | python | def check_account_address(address):
"""
verify that a string is a valid account address.
Can be a b58-check address, a c32-check address, as well as the string "treasury" or "unallocated" or a string starting with 'not_distributed_'
>>> check_account_address('16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg')
Tr... | [
"def",
"check_account_address",
"(",
"address",
")",
":",
"if",
"address",
"==",
"'treasury'",
"or",
"address",
"==",
"'unallocated'",
":",
"return",
"True",
"if",
"address",
".",
"startswith",
"(",
"'not_distributed_'",
")",
"and",
"len",
"(",
"address",
")",... | verify that a string is a valid account address.
Can be a b58-check address, a c32-check address, as well as the string "treasury" or "unallocated" or a string starting with 'not_distributed_'
>>> check_account_address('16EMaNw3pkn3v6f2BgnSSs53zAKH4Q8YJg')
True
>>> check_account_address('16EMaNw3pkn3v6... | [
"verify",
"that",
"a",
"string",
"is",
"a",
"valid",
"account",
"address",
".",
"Can",
"be",
"a",
"b58",
"-",
"check",
"address",
"a",
"c32",
"-",
"check",
"address",
"as",
"well",
"as",
"the",
"string",
"treasury",
"or",
"unallocated",
"or",
"a",
"str... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/scripts.py#L692-L731 | train |
blockstack/blockstack-core | blockstack/lib/scripts.py | check_tx_output_types | def check_tx_output_types(outputs, block_height):
"""
Verify that the list of transaction outputs are acceptable
"""
# for now, we do not allow nonstandard outputs (all outputs must be p2pkh or p2sh outputs)
# this excludes bech32 outputs, for example.
supported_output_types = get_epoch_btc_scri... | python | def check_tx_output_types(outputs, block_height):
"""
Verify that the list of transaction outputs are acceptable
"""
# for now, we do not allow nonstandard outputs (all outputs must be p2pkh or p2sh outputs)
# this excludes bech32 outputs, for example.
supported_output_types = get_epoch_btc_scri... | [
"def",
"check_tx_output_types",
"(",
"outputs",
",",
"block_height",
")",
":",
"supported_output_types",
"=",
"get_epoch_btc_script_types",
"(",
"block_height",
")",
"for",
"out",
"in",
"outputs",
":",
"out_type",
"=",
"virtualchain",
".",
"btc_script_classify",
"(",
... | Verify that the list of transaction outputs are acceptable | [
"Verify",
"that",
"the",
"list",
"of",
"transaction",
"outputs",
"are",
"acceptable"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/scripts.py#L734-L747 | train |
blockstack/blockstack-core | blockstack/lib/scripts.py | address_as_b58 | def address_as_b58(addr):
"""
Given a b58check or c32check address,
return the b58check encoding
"""
if is_c32_address(addr):
return c32ToB58(addr)
else:
if check_address(addr):
return addr
else:
raise ValueError('Address {} is not b58 or c32'.for... | python | def address_as_b58(addr):
"""
Given a b58check or c32check address,
return the b58check encoding
"""
if is_c32_address(addr):
return c32ToB58(addr)
else:
if check_address(addr):
return addr
else:
raise ValueError('Address {} is not b58 or c32'.for... | [
"def",
"address_as_b58",
"(",
"addr",
")",
":",
"if",
"is_c32_address",
"(",
"addr",
")",
":",
"return",
"c32ToB58",
"(",
"addr",
")",
"else",
":",
"if",
"check_address",
"(",
"addr",
")",
":",
"return",
"addr",
"else",
":",
"raise",
"ValueError",
"(",
... | Given a b58check or c32check address,
return the b58check encoding | [
"Given",
"a",
"b58check",
"or",
"c32check",
"address",
"return",
"the",
"b58check",
"encoding"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/scripts.py#L770-L782 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | verify | def verify(address, plaintext, scriptSigb64):
"""
Verify that a given plaintext is signed by the given scriptSig, given the address
"""
assert isinstance(address, str)
assert isinstance(scriptSigb64, str)
scriptSig = base64.b64decode(scriptSigb64)
hash_hex = hashlib.sha256(plaintext).hexdig... | python | def verify(address, plaintext, scriptSigb64):
"""
Verify that a given plaintext is signed by the given scriptSig, given the address
"""
assert isinstance(address, str)
assert isinstance(scriptSigb64, str)
scriptSig = base64.b64decode(scriptSigb64)
hash_hex = hashlib.sha256(plaintext).hexdig... | [
"def",
"verify",
"(",
"address",
",",
"plaintext",
",",
"scriptSigb64",
")",
":",
"assert",
"isinstance",
"(",
"address",
",",
"str",
")",
"assert",
"isinstance",
"(",
"scriptSigb64",
",",
"str",
")",
"scriptSig",
"=",
"base64",
".",
"b64decode",
"(",
"scr... | Verify that a given plaintext is signed by the given scriptSig, given the address | [
"Verify",
"that",
"a",
"given",
"plaintext",
"is",
"signed",
"by",
"the",
"given",
"scriptSig",
"given",
"the",
"address"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1727-L1745 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | verify_singlesig | def verify_singlesig(address, hash_hex, scriptSig):
"""
Verify that a p2pkh address is signed by the given pay-to-pubkey-hash scriptsig
"""
try:
sighex, pubkey_hex = virtualchain.btc_script_deserialize(scriptSig)
except:
log.warn("Wrong signature structure for {}".format(address))
... | python | def verify_singlesig(address, hash_hex, scriptSig):
"""
Verify that a p2pkh address is signed by the given pay-to-pubkey-hash scriptsig
"""
try:
sighex, pubkey_hex = virtualchain.btc_script_deserialize(scriptSig)
except:
log.warn("Wrong signature structure for {}".format(address))
... | [
"def",
"verify_singlesig",
"(",
"address",
",",
"hash_hex",
",",
"scriptSig",
")",
":",
"try",
":",
"sighex",
",",
"pubkey_hex",
"=",
"virtualchain",
".",
"btc_script_deserialize",
"(",
"scriptSig",
")",
"except",
":",
"log",
".",
"warn",
"(",
"\"Wrong signatu... | Verify that a p2pkh address is signed by the given pay-to-pubkey-hash scriptsig | [
"Verify",
"that",
"a",
"p2pkh",
"address",
"is",
"signed",
"by",
"the",
"given",
"pay",
"-",
"to",
"-",
"pubkey",
"-",
"hash",
"scriptsig"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1748-L1764 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | verify_multisig | def verify_multisig(address, hash_hex, scriptSig):
"""
verify that a p2sh address is signed by the given scriptsig
"""
script_parts = virtualchain.btc_script_deserialize(scriptSig)
if len(script_parts) < 2:
log.warn("Verfiying multisig failed, couldn't grab script parts")
return Fals... | python | def verify_multisig(address, hash_hex, scriptSig):
"""
verify that a p2sh address is signed by the given scriptsig
"""
script_parts = virtualchain.btc_script_deserialize(scriptSig)
if len(script_parts) < 2:
log.warn("Verfiying multisig failed, couldn't grab script parts")
return Fals... | [
"def",
"verify_multisig",
"(",
"address",
",",
"hash_hex",
",",
"scriptSig",
")",
":",
"script_parts",
"=",
"virtualchain",
".",
"btc_script_deserialize",
"(",
"scriptSig",
")",
"if",
"len",
"(",
"script_parts",
")",
"<",
"2",
":",
"log",
".",
"warn",
"(",
... | verify that a p2sh address is signed by the given scriptsig | [
"verify",
"that",
"a",
"p2sh",
"address",
"is",
"signed",
"by",
"the",
"given",
"scriptsig"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1767-L1800 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | is_subdomain_missing_zonefiles_record | def is_subdomain_missing_zonefiles_record(rec):
"""
Does a given parsed zone file TXT record encode a missing-zonefile vector?
Return True if so
Return False if not
"""
if rec['name'] != SUBDOMAIN_TXT_RR_MISSING:
return False
txt_entry = rec['txt']
if isinstance(txt_entry, list)... | python | def is_subdomain_missing_zonefiles_record(rec):
"""
Does a given parsed zone file TXT record encode a missing-zonefile vector?
Return True if so
Return False if not
"""
if rec['name'] != SUBDOMAIN_TXT_RR_MISSING:
return False
txt_entry = rec['txt']
if isinstance(txt_entry, list)... | [
"def",
"is_subdomain_missing_zonefiles_record",
"(",
"rec",
")",
":",
"if",
"rec",
"[",
"'name'",
"]",
"!=",
"SUBDOMAIN_TXT_RR_MISSING",
":",
"return",
"False",
"txt_entry",
"=",
"rec",
"[",
"'txt'",
"]",
"if",
"isinstance",
"(",
"txt_entry",
",",
"list",
")",... | Does a given parsed zone file TXT record encode a missing-zonefile vector?
Return True if so
Return False if not | [
"Does",
"a",
"given",
"parsed",
"zone",
"file",
"TXT",
"record",
"encode",
"a",
"missing",
"-",
"zonefile",
"vector?",
"Return",
"True",
"if",
"so",
"Return",
"False",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1810-L1830 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | is_subdomain_record | def is_subdomain_record(rec):
"""
Does a given parsed zone file TXT record (@rec) encode a subdomain?
Return True if so
Return False if not
"""
txt_entry = rec['txt']
if not isinstance(txt_entry, list):
return False
has_parts_entry = False
has_pk_entry = False
has_seqn_e... | python | def is_subdomain_record(rec):
"""
Does a given parsed zone file TXT record (@rec) encode a subdomain?
Return True if so
Return False if not
"""
txt_entry = rec['txt']
if not isinstance(txt_entry, list):
return False
has_parts_entry = False
has_pk_entry = False
has_seqn_e... | [
"def",
"is_subdomain_record",
"(",
"rec",
")",
":",
"txt_entry",
"=",
"rec",
"[",
"'txt'",
"]",
"if",
"not",
"isinstance",
"(",
"txt_entry",
",",
"list",
")",
":",
"return",
"False",
"has_parts_entry",
"=",
"False",
"has_pk_entry",
"=",
"False",
"has_seqn_en... | Does a given parsed zone file TXT record (@rec) encode a subdomain?
Return True if so
Return False if not | [
"Does",
"a",
"given",
"parsed",
"zone",
"file",
"TXT",
"record",
"("
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1833-L1854 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomain_info | def get_subdomain_info(fqn, db_path=None, atlasdb_path=None, zonefiles_dir=None, check_pending=False, include_did=False):
"""
Static method for getting the state of a subdomain, given its fully-qualified name.
Return the subdomain record on success.
Return None if not found.
"""
opts = get_block... | python | def get_subdomain_info(fqn, db_path=None, atlasdb_path=None, zonefiles_dir=None, check_pending=False, include_did=False):
"""
Static method for getting the state of a subdomain, given its fully-qualified name.
Return the subdomain record on success.
Return None if not found.
"""
opts = get_block... | [
"def",
"get_subdomain_info",
"(",
"fqn",
",",
"db_path",
"=",
"None",
",",
"atlasdb_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
",",
"check_pending",
"=",
"False",
",",
"include_did",
"=",
"False",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"("... | Static method for getting the state of a subdomain, given its fully-qualified name.
Return the subdomain record on success.
Return None if not found. | [
"Static",
"method",
"for",
"getting",
"the",
"state",
"of",
"a",
"subdomain",
"given",
"its",
"fully",
"-",
"qualified",
"name",
".",
"Return",
"the",
"subdomain",
"record",
"on",
"success",
".",
"Return",
"None",
"if",
"not",
"found",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1857-L1894 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomain_resolver | def get_subdomain_resolver(name, db_path=None, zonefiles_dir=None):
"""
Static method for determining the last-known resolver for a domain name.
Returns the resolver URL on success
Returns None on error
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
log.warn("Su... | python | def get_subdomain_resolver(name, db_path=None, zonefiles_dir=None):
"""
Static method for determining the last-known resolver for a domain name.
Returns the resolver URL on success
Returns None on error
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
log.warn("Su... | [
"def",
"get_subdomain_resolver",
"(",
"name",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"log",
".",
"warn",
"(",
"\"S... | Static method for determining the last-known resolver for a domain name.
Returns the resolver URL on success
Returns None on error | [
"Static",
"method",
"for",
"determining",
"the",
"last",
"-",
"known",
"resolver",
"for",
"a",
"domain",
"name",
".",
"Returns",
"the",
"resolver",
"URL",
"on",
"success",
"Returns",
"None",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1897-L1917 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomains_count | def get_subdomains_count(db_path=None, zonefiles_dir=None):
"""
Static method for getting count of all subdomains
Return number of subdomains on success
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
log.warn("Subdomain support is disabled")
return None
... | python | def get_subdomains_count(db_path=None, zonefiles_dir=None):
"""
Static method for getting count of all subdomains
Return number of subdomains on success
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
log.warn("Subdomain support is disabled")
return None
... | [
"def",
"get_subdomains_count",
"(",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"log",
".",
"warn",
"(",
"\"Subdomain support is... | Static method for getting count of all subdomains
Return number of subdomains on success | [
"Static",
"method",
"for",
"getting",
"count",
"of",
"all",
"subdomains",
"Return",
"number",
"of",
"subdomains",
"on",
"success"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1920-L1937 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomain_DID_info | def get_subdomain_DID_info(fqn, db_path=None, zonefiles_dir=None):
"""
Get a subdomain's DID info.
Return None if not found
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
log.warn("Subdomain support is disabled")
return None
if db_path is None:
... | python | def get_subdomain_DID_info(fqn, db_path=None, zonefiles_dir=None):
"""
Get a subdomain's DID info.
Return None if not found
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
log.warn("Subdomain support is disabled")
return None
if db_path is None:
... | [
"def",
"get_subdomain_DID_info",
"(",
"fqn",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"log",
".",
"warn",
"(",
"\"Su... | Get a subdomain's DID info.
Return None if not found | [
"Get",
"a",
"subdomain",
"s",
"DID",
"info",
".",
"Return",
"None",
"if",
"not",
"found"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1940-L1966 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_DID_subdomain | def get_DID_subdomain(did, db_path=None, zonefiles_dir=None, atlasdb_path=None, check_pending=False):
"""
Static method for resolving a DID to a subdomain
Return the subdomain record on success
Return None on error
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
... | python | def get_DID_subdomain(did, db_path=None, zonefiles_dir=None, atlasdb_path=None, check_pending=False):
"""
Static method for resolving a DID to a subdomain
Return the subdomain record on success
Return None on error
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
... | [
"def",
"get_DID_subdomain",
"(",
"did",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
",",
"atlasdb_path",
"=",
"None",
",",
"check_pending",
"=",
"False",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_... | Static method for resolving a DID to a subdomain
Return the subdomain record on success
Return None on error | [
"Static",
"method",
"for",
"resolving",
"a",
"DID",
"to",
"a",
"subdomain",
"Return",
"the",
"subdomain",
"record",
"on",
"success",
"Return",
"None",
"on",
"error"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1969-L2005 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | is_subdomain_zonefile_hash | def is_subdomain_zonefile_hash(fqn, zonefile_hash, db_path=None, zonefiles_dir=None):
"""
Static method for getting all historic zone file hashes for a subdomain
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['su... | python | def is_subdomain_zonefile_hash(fqn, zonefile_hash, db_path=None, zonefiles_dir=None):
"""
Static method for getting all historic zone file hashes for a subdomain
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['su... | [
"def",
"is_subdomain_zonefile_hash",
"(",
"fqn",
",",
"zonefile_hash",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"return"... | Static method for getting all historic zone file hashes for a subdomain | [
"Static",
"method",
"for",
"getting",
"all",
"historic",
"zone",
"file",
"hashes",
"for",
"a",
"subdomain"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2008-L2024 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomain_history | def get_subdomain_history(fqn, offset=None, count=None, reverse=False, db_path=None, zonefiles_dir=None, json=False):
"""
Static method for getting all historic operations on a subdomain
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
... | python | def get_subdomain_history(fqn, offset=None, count=None, reverse=False, db_path=None, zonefiles_dir=None, json=False):
"""
Static method for getting all historic operations on a subdomain
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
... | [
"def",
"get_subdomain_history",
"(",
"fqn",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
",",
"reverse",
"=",
"False",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
",",
"json",
"=",
"False",
")",
":",
"opts",
"=",
"get_bloc... | Static method for getting all historic operations on a subdomain | [
"Static",
"method",
"for",
"getting",
"all",
"historic",
"operations",
"on",
"a",
"subdomain"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2027-L2063 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_all_subdomains | def get_all_subdomains(offset=None, count=None, min_sequence=None, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of all subdomains
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdo... | python | def get_all_subdomains(offset=None, count=None, min_sequence=None, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of all subdomains
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdo... | [
"def",
"get_all_subdomains",
"(",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
",",
"min_sequence",
"=",
"None",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is... | Static method for getting the list of all subdomains | [
"Static",
"method",
"for",
"getting",
"the",
"list",
"of",
"all",
"subdomains"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2066-L2081 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomain_ops_at_txid | def get_subdomain_ops_at_txid(txid, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of subdomain operations accepted at a given txid.
Includes unaccepted subdomain operations
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if ... | python | def get_subdomain_ops_at_txid(txid, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of subdomain operations accepted at a given txid.
Includes unaccepted subdomain operations
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if ... | [
"def",
"get_subdomain_ops_at_txid",
"(",
"txid",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"return",
"[",
"]",
"if",
... | Static method for getting the list of subdomain operations accepted at a given txid.
Includes unaccepted subdomain operations | [
"Static",
"method",
"for",
"getting",
"the",
"list",
"of",
"subdomain",
"operations",
"accepted",
"at",
"a",
"given",
"txid",
".",
"Includes",
"unaccepted",
"subdomain",
"operations"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2084-L2100 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomains_owned_by_address | def get_subdomains_owned_by_address(address, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of subdomains for a given address
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdomaindb... | python | def get_subdomains_owned_by_address(address, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of subdomains for a given address
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdomaindb... | [
"def",
"get_subdomains_owned_by_address",
"(",
"address",
",",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"return",
"[",
"]",
... | Static method for getting the list of subdomains for a given address | [
"Static",
"method",
"for",
"getting",
"the",
"list",
"of",
"subdomains",
"for",
"a",
"given",
"address"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2103-L2118 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | get_subdomain_last_sequence | def get_subdomain_last_sequence(db_path=None, zonefiles_dir=None):
"""
Static method for getting the last sequence number in the database
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdomaindb_path']
if... | python | def get_subdomain_last_sequence(db_path=None, zonefiles_dir=None):
"""
Static method for getting the last sequence number in the database
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdomaindb_path']
if... | [
"def",
"get_subdomain_last_sequence",
"(",
"db_path",
"=",
"None",
",",
"zonefiles_dir",
"=",
"None",
")",
":",
"opts",
"=",
"get_blockstack_opts",
"(",
")",
"if",
"not",
"is_subdomains_enabled",
"(",
"opts",
")",
":",
"return",
"[",
"]",
"if",
"db_path",
"i... | Static method for getting the last sequence number in the database | [
"Static",
"method",
"for",
"getting",
"the",
"last",
"sequence",
"number",
"in",
"the",
"database"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2121-L2136 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | sign | def sign(privkey_bundle, plaintext):
"""
Sign a subdomain plaintext with a private key bundle
Returns the base64-encoded scriptsig
"""
if virtualchain.is_singlesig(privkey_bundle):
return sign_singlesig(privkey_bundle, plaintext)
elif virtualchain.is_multisig(privkey_bundle):
ret... | python | def sign(privkey_bundle, plaintext):
"""
Sign a subdomain plaintext with a private key bundle
Returns the base64-encoded scriptsig
"""
if virtualchain.is_singlesig(privkey_bundle):
return sign_singlesig(privkey_bundle, plaintext)
elif virtualchain.is_multisig(privkey_bundle):
ret... | [
"def",
"sign",
"(",
"privkey_bundle",
",",
"plaintext",
")",
":",
"if",
"virtualchain",
".",
"is_singlesig",
"(",
"privkey_bundle",
")",
":",
"return",
"sign_singlesig",
"(",
"privkey_bundle",
",",
"plaintext",
")",
"elif",
"virtualchain",
".",
"is_multisig",
"(... | Sign a subdomain plaintext with a private key bundle
Returns the base64-encoded scriptsig | [
"Sign",
"a",
"subdomain",
"plaintext",
"with",
"a",
"private",
"key",
"bundle",
"Returns",
"the",
"base64",
"-",
"encoded",
"scriptsig"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2152-L2162 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | subdomains_init | def subdomains_init(blockstack_opts, working_dir, atlas_state):
"""
Set up subdomain state
Returns a SubdomainIndex object that has been successfully connected to Atlas
"""
if not is_subdomains_enabled(blockstack_opts):
return None
subdomain_state = SubdomainIndex(blockstack_opts['subdo... | python | def subdomains_init(blockstack_opts, working_dir, atlas_state):
"""
Set up subdomain state
Returns a SubdomainIndex object that has been successfully connected to Atlas
"""
if not is_subdomains_enabled(blockstack_opts):
return None
subdomain_state = SubdomainIndex(blockstack_opts['subdo... | [
"def",
"subdomains_init",
"(",
"blockstack_opts",
",",
"working_dir",
",",
"atlas_state",
")",
":",
"if",
"not",
"is_subdomains_enabled",
"(",
"blockstack_opts",
")",
":",
"return",
"None",
"subdomain_state",
"=",
"SubdomainIndex",
"(",
"blockstack_opts",
"[",
"'sub... | Set up subdomain state
Returns a SubdomainIndex object that has been successfully connected to Atlas | [
"Set",
"up",
"subdomain",
"state",
"Returns",
"a",
"SubdomainIndex",
"object",
"that",
"has",
"been",
"successfully",
"connected",
"to",
"Atlas"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L2220-L2231 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | Subdomain.verify_signature | def verify_signature(self, addr):
"""
Given an address, verify whether or not it was signed by it
"""
return verify(virtualchain.address_reencode(addr), self.get_plaintext_to_sign(), self.sig) | python | def verify_signature(self, addr):
"""
Given an address, verify whether or not it was signed by it
"""
return verify(virtualchain.address_reencode(addr), self.get_plaintext_to_sign(), self.sig) | [
"def",
"verify_signature",
"(",
"self",
",",
"addr",
")",
":",
"return",
"verify",
"(",
"virtualchain",
".",
"address_reencode",
"(",
"addr",
")",
",",
"self",
".",
"get_plaintext_to_sign",
"(",
")",
",",
"self",
".",
"sig",
")"
] | Given an address, verify whether or not it was signed by it | [
"Given",
"an",
"address",
"verify",
"whether",
"or",
"not",
"it",
"was",
"signed",
"by",
"it"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L202-L206 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | Subdomain.serialize_to_txt | def serialize_to_txt(self):
"""
Serialize this subdomain record to a TXT record. The trailing newline will be omitted
"""
txtrec = {
'name': self.fqn if self.independent else self.subdomain,
'txt': self.pack_subdomain()[1:]
}
return blockstack_zon... | python | def serialize_to_txt(self):
"""
Serialize this subdomain record to a TXT record. The trailing newline will be omitted
"""
txtrec = {
'name': self.fqn if self.independent else self.subdomain,
'txt': self.pack_subdomain()[1:]
}
return blockstack_zon... | [
"def",
"serialize_to_txt",
"(",
"self",
")",
":",
"txtrec",
"=",
"{",
"'name'",
":",
"self",
".",
"fqn",
"if",
"self",
".",
"independent",
"else",
"self",
".",
"subdomain",
",",
"'txt'",
":",
"self",
".",
"pack_subdomain",
"(",
")",
"[",
"1",
":",
"]... | Serialize this subdomain record to a TXT record. The trailing newline will be omitted | [
"Serialize",
"this",
"subdomain",
"record",
"to",
"a",
"TXT",
"record",
".",
"The",
"trailing",
"newline",
"will",
"be",
"omitted"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L224-L232 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | Subdomain.parse_subdomain_missing_zonefiles_record | def parse_subdomain_missing_zonefiles_record(cls, rec):
"""
Parse a missing-zonefiles vector given by the domain.
Returns the list of zone file indexes on success
Raises ParseError on unparseable records
"""
txt_entry = rec['txt']
if isinstance(txt_entry, list):
... | python | def parse_subdomain_missing_zonefiles_record(cls, rec):
"""
Parse a missing-zonefiles vector given by the domain.
Returns the list of zone file indexes on success
Raises ParseError on unparseable records
"""
txt_entry = rec['txt']
if isinstance(txt_entry, list):
... | [
"def",
"parse_subdomain_missing_zonefiles_record",
"(",
"cls",
",",
"rec",
")",
":",
"txt_entry",
"=",
"rec",
"[",
"'txt'",
"]",
"if",
"isinstance",
"(",
"txt_entry",
",",
"list",
")",
":",
"raise",
"ParseError",
"(",
"\"TXT entry too long for a missing zone file li... | Parse a missing-zonefiles vector given by the domain.
Returns the list of zone file indexes on success
Raises ParseError on unparseable records | [
"Parse",
"a",
"missing",
"-",
"zonefiles",
"vector",
"given",
"by",
"the",
"domain",
".",
"Returns",
"the",
"list",
"of",
"zone",
"file",
"indexes",
"on",
"success",
"Raises",
"ParseError",
"on",
"unparseable",
"records"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L260-L273 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | Subdomain.get_public_key | def get_public_key(self):
"""
Parse the scriptSig and extract the public key.
Raises ValueError if this is a multisig-controlled subdomain.
"""
res = self.get_public_key_info()
if 'error' in res:
raise ValueError(res['error'])
if res['type'] != 'singl... | python | def get_public_key(self):
"""
Parse the scriptSig and extract the public key.
Raises ValueError if this is a multisig-controlled subdomain.
"""
res = self.get_public_key_info()
if 'error' in res:
raise ValueError(res['error'])
if res['type'] != 'singl... | [
"def",
"get_public_key",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"get_public_key_info",
"(",
")",
"if",
"'error'",
"in",
"res",
":",
"raise",
"ValueError",
"(",
"res",
"[",
"'error'",
"]",
")",
"if",
"res",
"[",
"'type'",
"]",
"!=",
"'singlesig... | Parse the scriptSig and extract the public key.
Raises ValueError if this is a multisig-controlled subdomain. | [
"Parse",
"the",
"scriptSig",
"and",
"extract",
"the",
"public",
"key",
".",
"Raises",
"ValueError",
"if",
"this",
"is",
"a",
"multisig",
"-",
"controlled",
"subdomain",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L345-L357 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.close | def close(self):
"""
Close the index
"""
with self.subdomain_db_lock:
self.subdomain_db.close()
self.subdomain_db = None
self.subdomain_db_path = None | python | def close(self):
"""
Close the index
"""
with self.subdomain_db_lock:
self.subdomain_db.close()
self.subdomain_db = None
self.subdomain_db_path = None | [
"def",
"close",
"(",
"self",
")",
":",
"with",
"self",
".",
"subdomain_db_lock",
":",
"self",
".",
"subdomain_db",
".",
"close",
"(",
")",
"self",
".",
"subdomain_db",
"=",
"None",
"self",
".",
"subdomain_db_path",
"=",
"None"
] | Close the index | [
"Close",
"the",
"index"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L441-L448 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.make_new_subdomain_history | def make_new_subdomain_history(self, cursor, subdomain_rec):
"""
Recalculate the history for this subdomain from genesis up until this record.
Returns the list of subdomain records we need to save.
"""
# what's the subdomain's history up until this subdomain record?
hist ... | python | def make_new_subdomain_history(self, cursor, subdomain_rec):
"""
Recalculate the history for this subdomain from genesis up until this record.
Returns the list of subdomain records we need to save.
"""
# what's the subdomain's history up until this subdomain record?
hist ... | [
"def",
"make_new_subdomain_history",
"(",
"self",
",",
"cursor",
",",
"subdomain_rec",
")",
":",
"hist",
"=",
"self",
".",
"subdomain_db",
".",
"get_subdomain_history",
"(",
"subdomain_rec",
".",
"get_fqn",
"(",
")",
",",
"include_unaccepted",
"=",
"True",
",",
... | Recalculate the history for this subdomain from genesis up until this record.
Returns the list of subdomain records we need to save. | [
"Recalculate",
"the",
"history",
"for",
"this",
"subdomain",
"from",
"genesis",
"up",
"until",
"this",
"record",
".",
"Returns",
"the",
"list",
"of",
"subdomain",
"records",
"we",
"need",
"to",
"save",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L570-L605 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.make_new_subdomain_future | def make_new_subdomain_future(self, cursor, subdomain_rec):
"""
Recalculate the future for this subdomain from the current record
until the latest known record.
Returns the list of subdomain records we need to save.
"""
assert subdomain_rec.accepted, 'BUG: given subdomain... | python | def make_new_subdomain_future(self, cursor, subdomain_rec):
"""
Recalculate the future for this subdomain from the current record
until the latest known record.
Returns the list of subdomain records we need to save.
"""
assert subdomain_rec.accepted, 'BUG: given subdomain... | [
"def",
"make_new_subdomain_future",
"(",
"self",
",",
"cursor",
",",
"subdomain_rec",
")",
":",
"assert",
"subdomain_rec",
".",
"accepted",
",",
"'BUG: given subdomain record must already be accepted'",
"fut",
"=",
"self",
".",
"subdomain_db",
".",
"get_subdomain_history"... | Recalculate the future for this subdomain from the current record
until the latest known record.
Returns the list of subdomain records we need to save. | [
"Recalculate",
"the",
"future",
"for",
"this",
"subdomain",
"from",
"the",
"current",
"record",
"until",
"the",
"latest",
"known",
"record",
".",
"Returns",
"the",
"list",
"of",
"subdomain",
"records",
"we",
"need",
"to",
"save",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L608-L647 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.subdomain_try_insert | def subdomain_try_insert(self, cursor, subdomain_rec, history_neighbors):
"""
Try to insert a subdomain record into its history neighbors.
This is an optimization that handles the "usual" case.
We can do this without having to rewrite this subdomain's past and future
if (1) we c... | python | def subdomain_try_insert(self, cursor, subdomain_rec, history_neighbors):
"""
Try to insert a subdomain record into its history neighbors.
This is an optimization that handles the "usual" case.
We can do this without having to rewrite this subdomain's past and future
if (1) we c... | [
"def",
"subdomain_try_insert",
"(",
"self",
",",
"cursor",
",",
"subdomain_rec",
",",
"history_neighbors",
")",
":",
"blockchain_order",
"=",
"history_neighbors",
"[",
"'prev'",
"]",
"+",
"history_neighbors",
"[",
"'cur'",
"]",
"+",
"history_neighbors",
"[",
"'fut... | Try to insert a subdomain record into its history neighbors.
This is an optimization that handles the "usual" case.
We can do this without having to rewrite this subdomain's past and future
if (1) we can find a previously-accepted subdomain record, and (2) the transition
from this subd... | [
"Try",
"to",
"insert",
"a",
"subdomain",
"record",
"into",
"its",
"history",
"neighbors",
".",
"This",
"is",
"an",
"optimization",
"that",
"handles",
"the",
"usual",
"case",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L684-L743 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.enqueue_zonefile | def enqueue_zonefile(self, zonefile_hash, block_height):
"""
Called when we discover a zone file. Queues up a request to reprocess this name's zone files' subdomains.
zonefile_hash is the hash of the zonefile.
block_height is the minimium block height at which this zone file occurs.
... | python | def enqueue_zonefile(self, zonefile_hash, block_height):
"""
Called when we discover a zone file. Queues up a request to reprocess this name's zone files' subdomains.
zonefile_hash is the hash of the zonefile.
block_height is the minimium block height at which this zone file occurs.
... | [
"def",
"enqueue_zonefile",
"(",
"self",
",",
"zonefile_hash",
",",
"block_height",
")",
":",
"with",
"self",
".",
"serialized_enqueue_zonefile",
":",
"log",
".",
"debug",
"(",
"\"Append {} from {}\"",
".",
"format",
"(",
"zonefile_hash",
",",
"block_height",
")",
... | Called when we discover a zone file. Queues up a request to reprocess this name's zone files' subdomains.
zonefile_hash is the hash of the zonefile.
block_height is the minimium block height at which this zone file occurs.
This gets called by:
* AtlasZonefileCrawler (as it's "store_zon... | [
"Called",
"when",
"we",
"discover",
"a",
"zone",
"file",
".",
"Queues",
"up",
"a",
"request",
"to",
"reprocess",
"this",
"name",
"s",
"zone",
"files",
"subdomains",
".",
"zonefile_hash",
"is",
"the",
"hash",
"of",
"the",
"zonefile",
".",
"block_height",
"i... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L823-L835 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.index_blockchain | def index_blockchain(self, block_start, block_end):
"""
Go through the sequence of zone files discovered in a block range, and reindex the names' subdomains.
"""
log.debug("Processing subdomain updates for zonefiles in blocks {}-{}".format(block_start, block_end))
res = ... | python | def index_blockchain(self, block_start, block_end):
"""
Go through the sequence of zone files discovered in a block range, and reindex the names' subdomains.
"""
log.debug("Processing subdomain updates for zonefiles in blocks {}-{}".format(block_start, block_end))
res = ... | [
"def",
"index_blockchain",
"(",
"self",
",",
"block_start",
",",
"block_end",
")",
":",
"log",
".",
"debug",
"(",
"\"Processing subdomain updates for zonefiles in blocks {}-{}\"",
".",
"format",
"(",
"block_start",
",",
"block_end",
")",
")",
"res",
"=",
"self",
"... | Go through the sequence of zone files discovered in a block range, and reindex the names' subdomains. | [
"Go",
"through",
"the",
"sequence",
"of",
"zone",
"files",
"discovered",
"in",
"a",
"block",
"range",
"and",
"reindex",
"the",
"names",
"subdomains",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L838-L847 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainIndex.index_discovered_zonefiles | def index_discovered_zonefiles(self, lastblock):
"""
Go through the list of zone files we discovered via Atlas, grouped by name and ordered by block height.
Find all subsequent zone files for this name, and process all subdomain operations contained within them.
"""
all_queued_zf... | python | def index_discovered_zonefiles(self, lastblock):
"""
Go through the list of zone files we discovered via Atlas, grouped by name and ordered by block height.
Find all subsequent zone files for this name, and process all subdomain operations contained within them.
"""
all_queued_zf... | [
"def",
"index_discovered_zonefiles",
"(",
"self",
",",
"lastblock",
")",
":",
"all_queued_zfinfos",
"=",
"[",
"]",
"subdomain_zonefile_infos",
"=",
"{",
"}",
"name_blocks",
"=",
"{",
"}",
"offset",
"=",
"0",
"while",
"True",
":",
"queued_zfinfos",
"=",
"queued... | Go through the list of zone files we discovered via Atlas, grouped by name and ordered by block height.
Find all subsequent zone files for this name, and process all subdomain operations contained within them. | [
"Go",
"through",
"the",
"list",
"of",
"zone",
"files",
"we",
"discovered",
"via",
"Atlas",
"grouped",
"by",
"name",
"and",
"ordered",
"by",
"block",
"height",
".",
"Find",
"all",
"subsequent",
"zone",
"files",
"for",
"this",
"name",
"and",
"process",
"all"... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L850-L929 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.subdomain_row_factory | def subdomain_row_factory(cls, cursor, row):
"""
Dict row factory for subdomains
"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | python | def subdomain_row_factory(cls, cursor, row):
"""
Dict row factory for subdomains
"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | [
"def",
"subdomain_row_factory",
"(",
"cls",
",",
"cursor",
",",
"row",
")",
":",
"d",
"=",
"{",
"}",
"for",
"idx",
",",
"col",
"in",
"enumerate",
"(",
"cursor",
".",
"description",
")",
":",
"d",
"[",
"col",
"[",
"0",
"]",
"]",
"=",
"row",
"[",
... | Dict row factory for subdomains | [
"Dict",
"row",
"factory",
"for",
"subdomains"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1000-L1008 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB._extract_subdomain | def _extract_subdomain(self, rowdata):
"""
Extract a single subdomain from a DB cursor
Raise SubdomainNotFound if there are no valid rows
"""
name = str(rowdata['fully_qualified_subdomain'])
domain = str(rowdata['domain'])
n = str(rowdata['sequence'])
enco... | python | def _extract_subdomain(self, rowdata):
"""
Extract a single subdomain from a DB cursor
Raise SubdomainNotFound if there are no valid rows
"""
name = str(rowdata['fully_qualified_subdomain'])
domain = str(rowdata['domain'])
n = str(rowdata['sequence'])
enco... | [
"def",
"_extract_subdomain",
"(",
"self",
",",
"rowdata",
")",
":",
"name",
"=",
"str",
"(",
"rowdata",
"[",
"'fully_qualified_subdomain'",
"]",
")",
"domain",
"=",
"str",
"(",
"rowdata",
"[",
"'domain'",
"]",
")",
"n",
"=",
"str",
"(",
"rowdata",
"[",
... | Extract a single subdomain from a DB cursor
Raise SubdomainNotFound if there are no valid rows | [
"Extract",
"a",
"single",
"subdomain",
"from",
"a",
"DB",
"cursor",
"Raise",
"SubdomainNotFound",
"if",
"there",
"are",
"no",
"valid",
"rows"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1025-L1065 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_subdomains_count | def get_subdomains_count(self, accepted=True, cur=None):
"""
Fetch subdomain names
"""
if accepted:
accepted_filter = 'WHERE accepted=1'
else:
accepted_filter = ''
get_cmd = "SELECT COUNT(DISTINCT fully_qualified_subdomain) as count FROM {} {};".f... | python | def get_subdomains_count(self, accepted=True, cur=None):
"""
Fetch subdomain names
"""
if accepted:
accepted_filter = 'WHERE accepted=1'
else:
accepted_filter = ''
get_cmd = "SELECT COUNT(DISTINCT fully_qualified_subdomain) as count FROM {} {};".f... | [
"def",
"get_subdomains_count",
"(",
"self",
",",
"accepted",
"=",
"True",
",",
"cur",
"=",
"None",
")",
":",
"if",
"accepted",
":",
"accepted_filter",
"=",
"'WHERE accepted=1'",
"else",
":",
"accepted_filter",
"=",
"''",
"get_cmd",
"=",
"\"SELECT COUNT(DISTINCT ... | Fetch subdomain names | [
"Fetch",
"subdomain",
"names"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1068-L1092 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_all_subdomains | def get_all_subdomains(self, offset=None, count=None, min_sequence=None, cur=None):
"""
Get and all subdomain names, optionally over a range
"""
get_cmd = 'SELECT DISTINCT fully_qualified_subdomain FROM {}'.format(self.subdomain_table)
args = ()
if min_sequence is not No... | python | def get_all_subdomains(self, offset=None, count=None, min_sequence=None, cur=None):
"""
Get and all subdomain names, optionally over a range
"""
get_cmd = 'SELECT DISTINCT fully_qualified_subdomain FROM {}'.format(self.subdomain_table)
args = ()
if min_sequence is not No... | [
"def",
"get_all_subdomains",
"(",
"self",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
",",
"min_sequence",
"=",
"None",
",",
"cur",
"=",
"None",
")",
":",
"get_cmd",
"=",
"'SELECT DISTINCT fully_qualified_subdomain FROM {}'",
".",
"format",
"(",
"se... | Get and all subdomain names, optionally over a range | [
"Get",
"and",
"all",
"subdomain",
"names",
"optionally",
"over",
"a",
"range"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1095-L1127 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_subdomain_ops_at_txid | def get_subdomain_ops_at_txid(self, txid, cur=None):
"""
Given a txid, get all subdomain operations at that txid.
Include unaccepted operations.
Order by zone file index
"""
get_cmd = 'SELECT * FROM {} WHERE txid = ? ORDER BY zonefile_offset'.format(self.subdomain_table)
... | python | def get_subdomain_ops_at_txid(self, txid, cur=None):
"""
Given a txid, get all subdomain operations at that txid.
Include unaccepted operations.
Order by zone file index
"""
get_cmd = 'SELECT * FROM {} WHERE txid = ? ORDER BY zonefile_offset'.format(self.subdomain_table)
... | [
"def",
"get_subdomain_ops_at_txid",
"(",
"self",
",",
"txid",
",",
"cur",
"=",
"None",
")",
":",
"get_cmd",
"=",
"'SELECT * FROM {} WHERE txid = ? ORDER BY zonefile_offset'",
".",
"format",
"(",
"self",
".",
"subdomain_table",
")",
"cursor",
"=",
"None",
"if",
"cu... | Given a txid, get all subdomain operations at that txid.
Include unaccepted operations.
Order by zone file index | [
"Given",
"a",
"txid",
"get",
"all",
"subdomain",
"operations",
"at",
"that",
"txid",
".",
"Include",
"unaccepted",
"operations",
".",
"Order",
"by",
"zone",
"file",
"index"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1202-L1224 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_subdomains_owned_by_address | def get_subdomains_owned_by_address(self, owner, cur=None):
"""
Get the list of subdomain names that are owned by a given address.
"""
get_cmd = "SELECT fully_qualified_subdomain, MAX(sequence) FROM {} WHERE owner = ? AND accepted=1 GROUP BY fully_qualified_subdomain".format(self.subdoma... | python | def get_subdomains_owned_by_address(self, owner, cur=None):
"""
Get the list of subdomain names that are owned by a given address.
"""
get_cmd = "SELECT fully_qualified_subdomain, MAX(sequence) FROM {} WHERE owner = ? AND accepted=1 GROUP BY fully_qualified_subdomain".format(self.subdoma... | [
"def",
"get_subdomains_owned_by_address",
"(",
"self",
",",
"owner",
",",
"cur",
"=",
"None",
")",
":",
"get_cmd",
"=",
"\"SELECT fully_qualified_subdomain, MAX(sequence) FROM {} WHERE owner = ? AND accepted=1 GROUP BY fully_qualified_subdomain\"",
".",
"format",
"(",
"self",
"... | Get the list of subdomain names that are owned by a given address. | [
"Get",
"the",
"list",
"of",
"subdomain",
"names",
"that",
"are",
"owned",
"by",
"a",
"given",
"address",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1227-L1247 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_domain_resolver | def get_domain_resolver(self, domain_name, cur=None):
"""
Get the last-knwon resolver entry for a domain name
Returns None if not found.
"""
get_cmd = "SELECT resolver FROM {} WHERE domain=? AND resolver != '' AND accepted=1 ORDER BY sequence DESC, parent_zonefile_index DESC LIMI... | python | def get_domain_resolver(self, domain_name, cur=None):
"""
Get the last-knwon resolver entry for a domain name
Returns None if not found.
"""
get_cmd = "SELECT resolver FROM {} WHERE domain=? AND resolver != '' AND accepted=1 ORDER BY sequence DESC, parent_zonefile_index DESC LIMI... | [
"def",
"get_domain_resolver",
"(",
"self",
",",
"domain_name",
",",
"cur",
"=",
"None",
")",
":",
"get_cmd",
"=",
"\"SELECT resolver FROM {} WHERE domain=? AND resolver != '' AND accepted=1 ORDER BY sequence DESC, parent_zonefile_index DESC LIMIT 1;\"",
".",
"format",
"(",
"self"... | Get the last-knwon resolver entry for a domain name
Returns None if not found. | [
"Get",
"the",
"last",
"-",
"knwon",
"resolver",
"entry",
"for",
"a",
"domain",
"name",
"Returns",
"None",
"if",
"not",
"found",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1250-L1269 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_subdomain_DID_info | def get_subdomain_DID_info(self, fqn, cur=None):
"""
Get the DID information for a subdomain.
Raise SubdomainNotFound if there is no such subdomain
Return {'name_type': ..., 'address': ..., 'index': ...}
"""
subrec = self.get_subdomain_entry_at_sequence(fqn, 0, cur=cur)
... | python | def get_subdomain_DID_info(self, fqn, cur=None):
"""
Get the DID information for a subdomain.
Raise SubdomainNotFound if there is no such subdomain
Return {'name_type': ..., 'address': ..., 'index': ...}
"""
subrec = self.get_subdomain_entry_at_sequence(fqn, 0, cur=cur)
... | [
"def",
"get_subdomain_DID_info",
"(",
"self",
",",
"fqn",
",",
"cur",
"=",
"None",
")",
":",
"subrec",
"=",
"self",
".",
"get_subdomain_entry_at_sequence",
"(",
"fqn",
",",
"0",
",",
"cur",
"=",
"cur",
")",
"cmd",
"=",
"'SELECT zonefile_offset FROM {} WHERE fu... | Get the DID information for a subdomain.
Raise SubdomainNotFound if there is no such subdomain
Return {'name_type': ..., 'address': ..., 'index': ...} | [
"Get",
"the",
"DID",
"information",
"for",
"a",
"subdomain",
".",
"Raise",
"SubdomainNotFound",
"if",
"there",
"is",
"no",
"such",
"subdomain"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1272-L1311 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_DID_subdomain | def get_DID_subdomain(self, did, cur=None):
"""
Get a subdomain, given its DID
Raise ValueError if the DID is invalid
Raise SubdomainNotFound if the DID does not correspond to a subdomain
"""
did = str(did)
try:
did_info = parse_DID(did)
a... | python | def get_DID_subdomain(self, did, cur=None):
"""
Get a subdomain, given its DID
Raise ValueError if the DID is invalid
Raise SubdomainNotFound if the DID does not correspond to a subdomain
"""
did = str(did)
try:
did_info = parse_DID(did)
a... | [
"def",
"get_DID_subdomain",
"(",
"self",
",",
"did",
",",
"cur",
"=",
"None",
")",
":",
"did",
"=",
"str",
"(",
"did",
")",
"try",
":",
"did_info",
"=",
"parse_DID",
"(",
"did",
")",
"assert",
"did_info",
"[",
"'name_type'",
"]",
"==",
"'subdomain'",
... | Get a subdomain, given its DID
Raise ValueError if the DID is invalid
Raise SubdomainNotFound if the DID does not correspond to a subdomain | [
"Get",
"a",
"subdomain",
"given",
"its",
"DID",
"Raise",
"ValueError",
"if",
"the",
"DID",
"is",
"invalid",
"Raise",
"SubdomainNotFound",
"if",
"the",
"DID",
"does",
"not",
"correspond",
"to",
"a",
"subdomain"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1314-L1354 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.is_subdomain_zonefile_hash | def is_subdomain_zonefile_hash(self, fqn, zonefile_hash, cur=None):
"""
Does this zone file hash belong to this subdomain?
"""
sql = 'SELECT COUNT(zonefile_hash) FROM {} WHERE fully_qualified_subdomain = ? and zonefile_hash = ?;'.format(self.subdomain_table)
args = (fqn,zonefile_... | python | def is_subdomain_zonefile_hash(self, fqn, zonefile_hash, cur=None):
"""
Does this zone file hash belong to this subdomain?
"""
sql = 'SELECT COUNT(zonefile_hash) FROM {} WHERE fully_qualified_subdomain = ? and zonefile_hash = ?;'.format(self.subdomain_table)
args = (fqn,zonefile_... | [
"def",
"is_subdomain_zonefile_hash",
"(",
"self",
",",
"fqn",
",",
"zonefile_hash",
",",
"cur",
"=",
"None",
")",
":",
"sql",
"=",
"'SELECT COUNT(zonefile_hash) FROM {} WHERE fully_qualified_subdomain = ? and zonefile_hash = ?;'",
".",
"format",
"(",
"self",
".",
"subdoma... | Does this zone file hash belong to this subdomain? | [
"Does",
"this",
"zone",
"file",
"hash",
"belong",
"to",
"this",
"subdomain?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1357-L1377 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.update_subdomain_entry | def update_subdomain_entry(self, subdomain_obj, cur=None):
"""
Update the subdomain history table for this subdomain entry.
Creates it if it doesn't exist.
Return True on success
Raise exception on error
"""
# sanity checks
assert isinstance(subdomain_obj... | python | def update_subdomain_entry(self, subdomain_obj, cur=None):
"""
Update the subdomain history table for this subdomain entry.
Creates it if it doesn't exist.
Return True on success
Raise exception on error
"""
# sanity checks
assert isinstance(subdomain_obj... | [
"def",
"update_subdomain_entry",
"(",
"self",
",",
"subdomain_obj",
",",
"cur",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"subdomain_obj",
",",
"Subdomain",
")",
"zonefile_hash",
"=",
"get_zonefile_data_hash",
"(",
"subdomain_obj",
".",
"zonefile_str",
"... | Update the subdomain history table for this subdomain entry.
Creates it if it doesn't exist.
Return True on success
Raise exception on error | [
"Update",
"the",
"subdomain",
"history",
"table",
"for",
"this",
"subdomain",
"entry",
".",
"Creates",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1435-L1478 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_last_block | def get_last_block(self, cur=None):
"""
Get the highest block last processed
"""
sql = 'SELECT MAX(block_height) FROM {};'.format(self.subdomain_table)
cursor = None
if cur is None:
cursor = self.conn.cursor()
else:
cursor = cur
ro... | python | def get_last_block(self, cur=None):
"""
Get the highest block last processed
"""
sql = 'SELECT MAX(block_height) FROM {};'.format(self.subdomain_table)
cursor = None
if cur is None:
cursor = self.conn.cursor()
else:
cursor = cur
ro... | [
"def",
"get_last_block",
"(",
"self",
",",
"cur",
"=",
"None",
")",
":",
"sql",
"=",
"'SELECT MAX(block_height) FROM {};'",
".",
"format",
"(",
"self",
".",
"subdomain_table",
")",
"cursor",
"=",
"None",
"if",
"cur",
"is",
"None",
":",
"cursor",
"=",
"self... | Get the highest block last processed | [
"Get",
"the",
"highest",
"block",
"last",
"processed"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1513-L1532 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB.get_last_sequence | def get_last_sequence(self, cur=None):
"""
Get the highest sequence number in this db
"""
sql = 'SELECT sequence FROM {} ORDER BY sequence DESC LIMIT 1;'.format(self.subdomain_table)
cursor = None
if cur is None:
cursor = self.conn.cursor()
else:
... | python | def get_last_sequence(self, cur=None):
"""
Get the highest sequence number in this db
"""
sql = 'SELECT sequence FROM {} ORDER BY sequence DESC LIMIT 1;'.format(self.subdomain_table)
cursor = None
if cur is None:
cursor = self.conn.cursor()
else:
... | [
"def",
"get_last_sequence",
"(",
"self",
",",
"cur",
"=",
"None",
")",
":",
"sql",
"=",
"'SELECT sequence FROM {} ORDER BY sequence DESC LIMIT 1;'",
".",
"format",
"(",
"self",
".",
"subdomain_table",
")",
"cursor",
"=",
"None",
"if",
"cur",
"is",
"None",
":",
... | Get the highest sequence number in this db | [
"Get",
"the",
"highest",
"sequence",
"number",
"in",
"this",
"db"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1535-L1553 | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | SubdomainDB._drop_tables | def _drop_tables(self):
"""
Clear the subdomain db's tables
"""
drop_cmd = "DROP TABLE IF EXISTS {};"
for table in [self.subdomain_table, self.blocked_table]:
cursor = self.conn.cursor()
db_query_execute(cursor, drop_cmd.format(table), ()) | python | def _drop_tables(self):
"""
Clear the subdomain db's tables
"""
drop_cmd = "DROP TABLE IF EXISTS {};"
for table in [self.subdomain_table, self.blocked_table]:
cursor = self.conn.cursor()
db_query_execute(cursor, drop_cmd.format(table), ()) | [
"def",
"_drop_tables",
"(",
"self",
")",
":",
"drop_cmd",
"=",
"\"DROP TABLE IF EXISTS {};\"",
"for",
"table",
"in",
"[",
"self",
".",
"subdomain_table",
",",
"self",
".",
"blocked_table",
"]",
":",
"cursor",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
"... | Clear the subdomain db's tables | [
"Clear",
"the",
"subdomain",
"db",
"s",
"tables"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L1556-L1563 | train |
blockstack/blockstack-core | blockstack/lib/hashing.py | hash_name | def hash_name(name, script_pubkey, register_addr=None):
"""
Generate the hash over a name and hex-string script pubkey
"""
bin_name = b40_to_bin(name)
name_and_pubkey = bin_name + unhexlify(script_pubkey)
if register_addr is not None:
name_and_pubkey += str(register_addr)
return hex_has... | python | def hash_name(name, script_pubkey, register_addr=None):
"""
Generate the hash over a name and hex-string script pubkey
"""
bin_name = b40_to_bin(name)
name_and_pubkey = bin_name + unhexlify(script_pubkey)
if register_addr is not None:
name_and_pubkey += str(register_addr)
return hex_has... | [
"def",
"hash_name",
"(",
"name",
",",
"script_pubkey",
",",
"register_addr",
"=",
"None",
")",
":",
"bin_name",
"=",
"b40_to_bin",
"(",
"name",
")",
"name_and_pubkey",
"=",
"bin_name",
"+",
"unhexlify",
"(",
"script_pubkey",
")",
"if",
"register_addr",
"is",
... | Generate the hash over a name and hex-string script pubkey | [
"Generate",
"the",
"hash",
"over",
"a",
"name",
"and",
"hex",
"-",
"string",
"script",
"pubkey"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/hashing.py#L32-L42 | train |
blockstack/blockstack-core | api/search/basic_index.py | fetch_profile_data_from_file | def fetch_profile_data_from_file():
""" takes profile data from file and saves in the profile_data DB
"""
with open(SEARCH_PROFILE_DATA_FILE, 'r') as fin:
profiles = json.load(fin)
counter = 0
log.debug("-" * 5)
log.debug("Fetching profile data from file")
for entry in profiles:
... | python | def fetch_profile_data_from_file():
""" takes profile data from file and saves in the profile_data DB
"""
with open(SEARCH_PROFILE_DATA_FILE, 'r') as fin:
profiles = json.load(fin)
counter = 0
log.debug("-" * 5)
log.debug("Fetching profile data from file")
for entry in profiles:
... | [
"def",
"fetch_profile_data_from_file",
"(",
")",
":",
"with",
"open",
"(",
"SEARCH_PROFILE_DATA_FILE",
",",
"'r'",
")",
"as",
"fin",
":",
"profiles",
"=",
"json",
".",
"load",
"(",
"fin",
")",
"counter",
"=",
"0",
"log",
".",
"debug",
"(",
"\"-\"",
"*",
... | takes profile data from file and saves in the profile_data DB | [
"takes",
"profile",
"data",
"from",
"file",
"and",
"saves",
"in",
"the",
"profile_data",
"DB"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/basic_index.py#L65-L95 | train |
blockstack/blockstack-core | api/search/basic_index.py | create_search_index | def create_search_index():
""" takes people names from blockchain and writes deduped names in a 'cache'
"""
# create people name cache
counter = 0
people_names = []
twitter_handles = []
usernames = []
log.debug("-" * 5)
log.debug("Creating search index")
for user in namespace... | python | def create_search_index():
""" takes people names from blockchain and writes deduped names in a 'cache'
"""
# create people name cache
counter = 0
people_names = []
twitter_handles = []
usernames = []
log.debug("-" * 5)
log.debug("Creating search index")
for user in namespace... | [
"def",
"create_search_index",
"(",
")",
":",
"counter",
"=",
"0",
"people_names",
"=",
"[",
"]",
"twitter_handles",
"=",
"[",
"]",
"usernames",
"=",
"[",
"]",
"log",
".",
"debug",
"(",
"\"-\"",
"*",
"5",
")",
"log",
".",
"debug",
"(",
"\"Creating searc... | takes people names from blockchain and writes deduped names in a 'cache' | [
"takes",
"people",
"names",
"from",
"blockchain",
"and",
"writes",
"deduped",
"names",
"in",
"a",
"cache"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/search/basic_index.py#L177-L277 | train |
blockstack/blockstack-core | blockstack/lib/operations/__init__.py | op_extract | def op_extract(op_name, data, senders, inputs, outputs, block_id, vtxindex, txid):
"""
Extract an operation from transaction data.
Return the extracted fields as a dict.
"""
global EXTRACT_METHODS
if op_name not in EXTRACT_METHODS.keys():
raise Exception("No such operation '%s'" % op_na... | python | def op_extract(op_name, data, senders, inputs, outputs, block_id, vtxindex, txid):
"""
Extract an operation from transaction data.
Return the extracted fields as a dict.
"""
global EXTRACT_METHODS
if op_name not in EXTRACT_METHODS.keys():
raise Exception("No such operation '%s'" % op_na... | [
"def",
"op_extract",
"(",
"op_name",
",",
"data",
",",
"senders",
",",
"inputs",
",",
"outputs",
",",
"block_id",
",",
"vtxindex",
",",
"txid",
")",
":",
"global",
"EXTRACT_METHODS",
"if",
"op_name",
"not",
"in",
"EXTRACT_METHODS",
".",
"keys",
"(",
")",
... | Extract an operation from transaction data.
Return the extracted fields as a dict. | [
"Extract",
"an",
"operation",
"from",
"transaction",
"data",
".",
"Return",
"the",
"extracted",
"fields",
"as",
"a",
"dict",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/__init__.py#L183-L195 | train |
blockstack/blockstack-core | blockstack/lib/operations/__init__.py | op_canonicalize | def op_canonicalize(op_name, parsed_op):
"""
Get the canonical representation of a parsed operation's data.
Meant for backwards-compatibility
"""
global CANONICALIZE_METHODS
if op_name not in CANONICALIZE_METHODS:
# no canonicalization needed
return parsed_op
else:
r... | python | def op_canonicalize(op_name, parsed_op):
"""
Get the canonical representation of a parsed operation's data.
Meant for backwards-compatibility
"""
global CANONICALIZE_METHODS
if op_name not in CANONICALIZE_METHODS:
# no canonicalization needed
return parsed_op
else:
r... | [
"def",
"op_canonicalize",
"(",
"op_name",
",",
"parsed_op",
")",
":",
"global",
"CANONICALIZE_METHODS",
"if",
"op_name",
"not",
"in",
"CANONICALIZE_METHODS",
":",
"return",
"parsed_op",
"else",
":",
"return",
"CANONICALIZE_METHODS",
"[",
"op_name",
"]",
"(",
"pars... | Get the canonical representation of a parsed operation's data.
Meant for backwards-compatibility | [
"Get",
"the",
"canonical",
"representation",
"of",
"a",
"parsed",
"operation",
"s",
"data",
".",
"Meant",
"for",
"backwards",
"-",
"compatibility"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/__init__.py#L198-L209 | train |
blockstack/blockstack-core | blockstack/lib/operations/__init__.py | op_decanonicalize | def op_decanonicalize(op_name, canonical_op):
"""
Get the current representation of a parsed operation's data, given the canonical representation
Meant for backwards-compatibility
"""
global DECANONICALIZE_METHODS
if op_name not in DECANONICALIZE_METHODS:
# no decanonicalization needed
... | python | def op_decanonicalize(op_name, canonical_op):
"""
Get the current representation of a parsed operation's data, given the canonical representation
Meant for backwards-compatibility
"""
global DECANONICALIZE_METHODS
if op_name not in DECANONICALIZE_METHODS:
# no decanonicalization needed
... | [
"def",
"op_decanonicalize",
"(",
"op_name",
",",
"canonical_op",
")",
":",
"global",
"DECANONICALIZE_METHODS",
"if",
"op_name",
"not",
"in",
"DECANONICALIZE_METHODS",
":",
"return",
"canonical_op",
"else",
":",
"return",
"DECANONICALIZE_METHODS",
"[",
"op_name",
"]",
... | Get the current representation of a parsed operation's data, given the canonical representation
Meant for backwards-compatibility | [
"Get",
"the",
"current",
"representation",
"of",
"a",
"parsed",
"operation",
"s",
"data",
"given",
"the",
"canonical",
"representation",
"Meant",
"for",
"backwards",
"-",
"compatibility"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/__init__.py#L212-L223 | train |
blockstack/blockstack-core | blockstack/lib/operations/__init__.py | op_check | def op_check( state_engine, nameop, block_id, checked_ops ):
"""
Given the state engine, the current block, the list of pending
operations processed so far, and the current operation, determine
whether or not it should be accepted.
The operation is allowed to be "type-cast" to a new operation, but ... | python | def op_check( state_engine, nameop, block_id, checked_ops ):
"""
Given the state engine, the current block, the list of pending
operations processed so far, and the current operation, determine
whether or not it should be accepted.
The operation is allowed to be "type-cast" to a new operation, but ... | [
"def",
"op_check",
"(",
"state_engine",
",",
"nameop",
",",
"block_id",
",",
"checked_ops",
")",
":",
"global",
"CHECK_METHODS",
",",
"MUTATE_FIELDS",
"nameop_clone",
"=",
"copy",
".",
"deepcopy",
"(",
"nameop",
")",
"opcode",
"=",
"None",
"if",
"'opcode'",
... | Given the state engine, the current block, the list of pending
operations processed so far, and the current operation, determine
whether or not it should be accepted.
The operation is allowed to be "type-cast" to a new operation, but only once.
If this happens, the operation will be checked again.
... | [
"Given",
"the",
"state",
"engine",
"the",
"current",
"block",
"the",
"list",
"of",
"pending",
"operations",
"processed",
"so",
"far",
"and",
"the",
"current",
"operation",
"determine",
"whether",
"or",
"not",
"it",
"should",
"be",
"accepted",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/__init__.py#L284-L343 | train |
blockstack/blockstack-core | blockstack/lib/operations/__init__.py | op_get_mutate_fields | def op_get_mutate_fields( op_name ):
"""
Get the names of the fields that will change
when this operation gets applied to a record.
"""
global MUTATE_FIELDS
if op_name not in MUTATE_FIELDS.keys():
raise Exception("No such operation '%s'" % op_name)
fields = MUTATE_FIELDS[op_name][:... | python | def op_get_mutate_fields( op_name ):
"""
Get the names of the fields that will change
when this operation gets applied to a record.
"""
global MUTATE_FIELDS
if op_name not in MUTATE_FIELDS.keys():
raise Exception("No such operation '%s'" % op_name)
fields = MUTATE_FIELDS[op_name][:... | [
"def",
"op_get_mutate_fields",
"(",
"op_name",
")",
":",
"global",
"MUTATE_FIELDS",
"if",
"op_name",
"not",
"in",
"MUTATE_FIELDS",
".",
"keys",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"No such operation '%s'\"",
"%",
"op_name",
")",
"fields",
"=",
"MUTATE_FI... | Get the names of the fields that will change
when this operation gets applied to a record. | [
"Get",
"the",
"names",
"of",
"the",
"fields",
"that",
"will",
"change",
"when",
"this",
"operation",
"gets",
"applied",
"to",
"a",
"record",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/__init__.py#L346-L357 | train |
blockstack/blockstack-core | blockstack/lib/operations/__init__.py | op_get_consensus_fields | def op_get_consensus_fields( op_name ):
"""
Get the set of consensus-generating fields for an operation.
"""
global SERIALIZE_FIELDS
if op_name not in SERIALIZE_FIELDS.keys():
raise Exception("No such operation '%s'" % op_name )
fields = SERIALIZE_FIELDS[op_name][:]
return fiel... | python | def op_get_consensus_fields( op_name ):
"""
Get the set of consensus-generating fields for an operation.
"""
global SERIALIZE_FIELDS
if op_name not in SERIALIZE_FIELDS.keys():
raise Exception("No such operation '%s'" % op_name )
fields = SERIALIZE_FIELDS[op_name][:]
return fiel... | [
"def",
"op_get_consensus_fields",
"(",
"op_name",
")",
":",
"global",
"SERIALIZE_FIELDS",
"if",
"op_name",
"not",
"in",
"SERIALIZE_FIELDS",
".",
"keys",
"(",
")",
":",
"raise",
"Exception",
"(",
"\"No such operation '%s'\"",
"%",
"op_name",
")",
"fields",
"=",
"... | Get the set of consensus-generating fields for an operation. | [
"Get",
"the",
"set",
"of",
"consensus",
"-",
"generating",
"fields",
"for",
"an",
"operation",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/__init__.py#L360-L370 | train |
blockstack/blockstack-core | blockstack/lib/operations/update.py | check | def check(state_engine, nameop, block_id, checked_ops ):
"""
Verify the validity of an update to a name's associated data.
Use the nameop's 128-bit name hash to find the name itself.
NAME_UPDATE isn't allowed during an import, so the name's namespace must be ready.
Return True if accepted
Retu... | python | def check(state_engine, nameop, block_id, checked_ops ):
"""
Verify the validity of an update to a name's associated data.
Use the nameop's 128-bit name hash to find the name itself.
NAME_UPDATE isn't allowed during an import, so the name's namespace must be ready.
Return True if accepted
Retu... | [
"def",
"check",
"(",
"state_engine",
",",
"nameop",
",",
"block_id",
",",
"checked_ops",
")",
":",
"name_consensus_hash",
"=",
"nameop",
"[",
"'name_consensus_hash'",
"]",
"sender",
"=",
"nameop",
"[",
"'sender'",
"]",
"sender_names",
"=",
"state_engine",
".",
... | Verify the validity of an update to a name's associated data.
Use the nameop's 128-bit name hash to find the name itself.
NAME_UPDATE isn't allowed during an import, so the name's namespace must be ready.
Return True if accepted
Return False if not. | [
"Verify",
"the",
"validity",
"of",
"an",
"update",
"to",
"a",
"name",
"s",
"associated",
"data",
".",
"Use",
"the",
"nameop",
"s",
"128",
"-",
"bit",
"name",
"hash",
"to",
"find",
"the",
"name",
"itself",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/update.py#L73-L149 | train |
blockstack/blockstack-core | blockstack/lib/audit.py | genesis_block_audit | def genesis_block_audit(genesis_block_stages, key_bundle=GENESIS_BLOCK_SIGNING_KEYS):
"""
Verify the authenticity of the stages of the genesis block, optionally with a given set of keys.
Return True if valid
Return False if not
"""
gpg2_path = find_gpg2()
if gpg2_path is None:
raise ... | python | def genesis_block_audit(genesis_block_stages, key_bundle=GENESIS_BLOCK_SIGNING_KEYS):
"""
Verify the authenticity of the stages of the genesis block, optionally with a given set of keys.
Return True if valid
Return False if not
"""
gpg2_path = find_gpg2()
if gpg2_path is None:
raise ... | [
"def",
"genesis_block_audit",
"(",
"genesis_block_stages",
",",
"key_bundle",
"=",
"GENESIS_BLOCK_SIGNING_KEYS",
")",
":",
"gpg2_path",
"=",
"find_gpg2",
"(",
")",
"if",
"gpg2_path",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'You must install gpg2 to audit the gene... | Verify the authenticity of the stages of the genesis block, optionally with a given set of keys.
Return True if valid
Return False if not | [
"Verify",
"the",
"authenticity",
"of",
"the",
"stages",
"of",
"the",
"genesis",
"block",
"optionally",
"with",
"a",
"given",
"set",
"of",
"keys",
".",
"Return",
"True",
"if",
"valid",
"Return",
"False",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/audit.py#L97-L155 | train |
blockstack/blockstack-core | api/resolver.py | is_profile_in_legacy_format | def is_profile_in_legacy_format(profile):
"""
Is a given profile JSON object in legacy format?
"""
if isinstance(profile, dict):
pass
elif isinstance(profile, (str, unicode)):
try:
profile = json.loads(profile)
except ValueError:
return False
else:... | python | def is_profile_in_legacy_format(profile):
"""
Is a given profile JSON object in legacy format?
"""
if isinstance(profile, dict):
pass
elif isinstance(profile, (str, unicode)):
try:
profile = json.loads(profile)
except ValueError:
return False
else:... | [
"def",
"is_profile_in_legacy_format",
"(",
"profile",
")",
":",
"if",
"isinstance",
"(",
"profile",
",",
"dict",
")",
":",
"pass",
"elif",
"isinstance",
"(",
"profile",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"try",
":",
"profile",
"=",
"json",
... | Is a given profile JSON object in legacy format? | [
"Is",
"a",
"given",
"profile",
"JSON",
"object",
"in",
"legacy",
"format?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/resolver.py#L114-L147 | train |
blockstack/blockstack-core | api/resolver.py | format_profile | def format_profile(profile, fqa, zone_file, address, public_key):
""" Process profile data and
1) Insert verifications
2) Check if profile data is valid JSON
"""
# if the zone file is a string, then parse it
if isinstance(zone_file, (str,unicode)):
try:
zone_fil... | python | def format_profile(profile, fqa, zone_file, address, public_key):
""" Process profile data and
1) Insert verifications
2) Check if profile data is valid JSON
"""
# if the zone file is a string, then parse it
if isinstance(zone_file, (str,unicode)):
try:
zone_fil... | [
"def",
"format_profile",
"(",
"profile",
",",
"fqa",
",",
"zone_file",
",",
"address",
",",
"public_key",
")",
":",
"if",
"isinstance",
"(",
"zone_file",
",",
"(",
"str",
",",
"unicode",
")",
")",
":",
"try",
":",
"zone_file",
"=",
"blockstack_zones",
".... | Process profile data and
1) Insert verifications
2) Check if profile data is valid JSON | [
"Process",
"profile",
"data",
"and",
"1",
")",
"Insert",
"verifications",
"2",
")",
"Check",
"if",
"profile",
"data",
"is",
"valid",
"JSON"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/resolver.py#L149-L182 | train |
blockstack/blockstack-core | api/resolver.py | get_users | def get_users(username):
""" Fetch data from username in .id namespace
"""
reply = {}
log.debug('Begin /v[x]/users/' + username)
if username is None:
reply['error'] = "No username given"
return jsonify(reply), 404
if ',' in username:
reply['error'] = 'Multiple username... | python | def get_users(username):
""" Fetch data from username in .id namespace
"""
reply = {}
log.debug('Begin /v[x]/users/' + username)
if username is None:
reply['error'] = "No username given"
return jsonify(reply), 404
if ',' in username:
reply['error'] = 'Multiple username... | [
"def",
"get_users",
"(",
"username",
")",
":",
"reply",
"=",
"{",
"}",
"log",
".",
"debug",
"(",
"'Begin /v[x]/users/'",
"+",
"username",
")",
"if",
"username",
"is",
"None",
":",
"reply",
"[",
"'error'",
"]",
"=",
"\"No username given\"",
"return",
"jsoni... | Fetch data from username in .id namespace | [
"Fetch",
"data",
"from",
"username",
"in",
".",
"id",
"namespace"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/api/resolver.py#L250-L281 | train |
blockstack/blockstack-core | blockstack/lib/operations/nameimport.py | is_earlier_than | def is_earlier_than( nameop1, block_id, vtxindex ):
"""
Does nameop1 come before bock_id and vtxindex?
"""
return nameop1['block_number'] < block_id or (nameop1['block_number'] == block_id and nameop1['vtxindex'] < vtxindex) | python | def is_earlier_than( nameop1, block_id, vtxindex ):
"""
Does nameop1 come before bock_id and vtxindex?
"""
return nameop1['block_number'] < block_id or (nameop1['block_number'] == block_id and nameop1['vtxindex'] < vtxindex) | [
"def",
"is_earlier_than",
"(",
"nameop1",
",",
"block_id",
",",
"vtxindex",
")",
":",
"return",
"nameop1",
"[",
"'block_number'",
"]",
"<",
"block_id",
"or",
"(",
"nameop1",
"[",
"'block_number'",
"]",
"==",
"block_id",
"and",
"nameop1",
"[",
"'vtxindex'",
"... | Does nameop1 come before bock_id and vtxindex? | [
"Does",
"nameop1",
"come",
"before",
"bock_id",
"and",
"vtxindex?"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/nameimport.py#L107-L111 | train |
blockstack/blockstack-core | blockstack/lib/operations/namespacereveal.py | namespacereveal_sanity_check | def namespacereveal_sanity_check( namespace_id, version, lifetime, coeff, base, bucket_exponents, nonalpha_discount, no_vowel_discount ):
"""
Verify the validity of a namespace reveal.
Return True if valid
Raise an Exception if not valid.
"""
# sanity check
if not is_b40( namespace_id ) or "+" in ... | python | def namespacereveal_sanity_check( namespace_id, version, lifetime, coeff, base, bucket_exponents, nonalpha_discount, no_vowel_discount ):
"""
Verify the validity of a namespace reveal.
Return True if valid
Raise an Exception if not valid.
"""
# sanity check
if not is_b40( namespace_id ) or "+" in ... | [
"def",
"namespacereveal_sanity_check",
"(",
"namespace_id",
",",
"version",
",",
"lifetime",
",",
"coeff",
",",
"base",
",",
"bucket_exponents",
",",
"nonalpha_discount",
",",
"no_vowel_discount",
")",
":",
"if",
"not",
"is_b40",
"(",
"namespace_id",
")",
"or",
... | Verify the validity of a namespace reveal.
Return True if valid
Raise an Exception if not valid. | [
"Verify",
"the",
"validity",
"of",
"a",
"namespace",
"reveal",
".",
"Return",
"True",
"if",
"valid",
"Raise",
"an",
"Exception",
"if",
"not",
"valid",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/namespacereveal.py#L66-L107 | train |
blockstack/blockstack-core | blockstack/lib/operations/preorder.py | check | def check( state_engine, nameop, block_id, checked_ops ):
"""
Verify that a preorder of a name at a particular block number is well-formed
NOTE: these *can't* be incorporated into namespace-imports,
since we have no way of knowning which namespace the
nameop belongs to (it is blinded until registra... | python | def check( state_engine, nameop, block_id, checked_ops ):
"""
Verify that a preorder of a name at a particular block number is well-formed
NOTE: these *can't* be incorporated into namespace-imports,
since we have no way of knowning which namespace the
nameop belongs to (it is blinded until registra... | [
"def",
"check",
"(",
"state_engine",
",",
"nameop",
",",
"block_id",
",",
"checked_ops",
")",
":",
"from",
".",
"register",
"import",
"get_num_names_owned",
"preorder_name_hash",
"=",
"nameop",
"[",
"'preorder_hash'",
"]",
"consensus_hash",
"=",
"nameop",
"[",
"... | Verify that a preorder of a name at a particular block number is well-formed
NOTE: these *can't* be incorporated into namespace-imports,
since we have no way of knowning which namespace the
nameop belongs to (it is blinded until registration).
But that's okay--we don't need to preorder names during
... | [
"Verify",
"that",
"a",
"preorder",
"of",
"a",
"name",
"at",
"a",
"particular",
"block",
"number",
"is",
"well",
"-",
"formed"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/preorder.py#L53-L145 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_create | def namedb_create(path, genesis_block):
"""
Create a sqlite3 db at the given path.
Create all the tables and indexes we need.
"""
global BLOCKSTACK_DB_SCRIPT
if os.path.exists( path ):
raise Exception("Database '%s' already exists" % path)
lines = [l + ";" for l in BLOCKSTACK_DB_S... | python | def namedb_create(path, genesis_block):
"""
Create a sqlite3 db at the given path.
Create all the tables and indexes we need.
"""
global BLOCKSTACK_DB_SCRIPT
if os.path.exists( path ):
raise Exception("Database '%s' already exists" % path)
lines = [l + ";" for l in BLOCKSTACK_DB_S... | [
"def",
"namedb_create",
"(",
"path",
",",
"genesis_block",
")",
":",
"global",
"BLOCKSTACK_DB_SCRIPT",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"Exception",
"(",
"\"Database '%s' already exists\"",
"%",
"path",
")",
"lines",
"=",... | Create a sqlite3 db at the given path.
Create all the tables and indexes we need. | [
"Create",
"a",
"sqlite3",
"db",
"at",
"the",
"given",
"path",
".",
"Create",
"all",
"the",
"tables",
"and",
"indexes",
"we",
"need",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L412-L433 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_open | def namedb_open( path ):
"""
Open a connection to our database
"""
con = sqlite3.connect( path, isolation_level=None, timeout=2**30 )
db_query_execute(con, 'pragma mmap_size=536870912', ())
con.row_factory = namedb_row_factory
version = namedb_get_version(con)
if not semver_equal(versio... | python | def namedb_open( path ):
"""
Open a connection to our database
"""
con = sqlite3.connect( path, isolation_level=None, timeout=2**30 )
db_query_execute(con, 'pragma mmap_size=536870912', ())
con.row_factory = namedb_row_factory
version = namedb_get_version(con)
if not semver_equal(versio... | [
"def",
"namedb_open",
"(",
"path",
")",
":",
"con",
"=",
"sqlite3",
".",
"connect",
"(",
"path",
",",
"isolation_level",
"=",
"None",
",",
"timeout",
"=",
"2",
"**",
"30",
")",
"db_query_execute",
"(",
"con",
",",
"'pragma mmap_size=536870912'",
",",
"(",
... | Open a connection to our database | [
"Open",
"a",
"connection",
"to",
"our",
"database"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L436-L449 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_insert_prepare | def namedb_insert_prepare( cur, record, table_name ):
"""
Prepare to insert a record, but make sure
that all of the column names have values first!
Return an INSERT INTO statement on success.
Raise an exception if not.
"""
namedb_assert_fields_match( cur, record, table_name )
col... | python | def namedb_insert_prepare( cur, record, table_name ):
"""
Prepare to insert a record, but make sure
that all of the column names have values first!
Return an INSERT INTO statement on success.
Raise an exception if not.
"""
namedb_assert_fields_match( cur, record, table_name )
col... | [
"def",
"namedb_insert_prepare",
"(",
"cur",
",",
"record",
",",
"table_name",
")",
":",
"namedb_assert_fields_match",
"(",
"cur",
",",
"record",
",",
"table_name",
")",
"columns",
"=",
"record",
".",
"keys",
"(",
")",
"columns",
".",
"sort",
"(",
")",
"val... | Prepare to insert a record, but make sure
that all of the column names have values first!
Return an INSERT INTO statement on success.
Raise an exception if not. | [
"Prepare",
"to",
"insert",
"a",
"record",
"but",
"make",
"sure",
"that",
"all",
"of",
"the",
"column",
"names",
"have",
"values",
"first!"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L530-L560 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_update_must_equal | def namedb_update_must_equal( rec, change_fields ):
"""
Generate the set of fields that must stay the same across an update.
"""
must_equal = []
if len(change_fields) != 0:
given = rec.keys()
for k in given:
if k not in change_fields:
must_equal.appen... | python | def namedb_update_must_equal( rec, change_fields ):
"""
Generate the set of fields that must stay the same across an update.
"""
must_equal = []
if len(change_fields) != 0:
given = rec.keys()
for k in given:
if k not in change_fields:
must_equal.appen... | [
"def",
"namedb_update_must_equal",
"(",
"rec",
",",
"change_fields",
")",
":",
"must_equal",
"=",
"[",
"]",
"if",
"len",
"(",
"change_fields",
")",
"!=",
"0",
":",
"given",
"=",
"rec",
".",
"keys",
"(",
")",
"for",
"k",
"in",
"given",
":",
"if",
"k",... | Generate the set of fields that must stay the same across an update. | [
"Generate",
"the",
"set",
"of",
"fields",
"that",
"must",
"stay",
"the",
"same",
"across",
"an",
"update",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L659-L671 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_delete_prepare | def namedb_delete_prepare( cur, primary_key, primary_key_value, table_name ):
"""
Prepare to delete a record, but make sure the fields in record
correspond to actual columns.
Return a DELETE FROM ... WHERE statement on success.
Raise an Exception if not.
DO NOT CALL THIS METHOD DIRETLY
... | python | def namedb_delete_prepare( cur, primary_key, primary_key_value, table_name ):
"""
Prepare to delete a record, but make sure the fields in record
correspond to actual columns.
Return a DELETE FROM ... WHERE statement on success.
Raise an Exception if not.
DO NOT CALL THIS METHOD DIRETLY
... | [
"def",
"namedb_delete_prepare",
"(",
"cur",
",",
"primary_key",
",",
"primary_key_value",
",",
"table_name",
")",
":",
"namedb_assert_fields_match",
"(",
"cur",
",",
"{",
"primary_key",
":",
"primary_key_value",
"}",
",",
"table_name",
",",
"columns_match_record",
"... | Prepare to delete a record, but make sure the fields in record
correspond to actual columns.
Return a DELETE FROM ... WHERE statement on success.
Raise an Exception if not.
DO NOT CALL THIS METHOD DIRETLY | [
"Prepare",
"to",
"delete",
"a",
"record",
"but",
"make",
"sure",
"the",
"fields",
"in",
"record",
"correspond",
"to",
"actual",
"columns",
".",
"Return",
"a",
"DELETE",
"FROM",
"...",
"WHERE",
"statement",
"on",
"success",
".",
"Raise",
"an",
"Exception",
... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L674-L689 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_query_execute | def namedb_query_execute( cur, query, values, abort=True):
"""
Execute a query. If it fails, abort. Retry with timeouts on lock
DO NOT CALL THIS DIRECTLY.
"""
return db_query_execute(cur, query, values, abort=abort) | python | def namedb_query_execute( cur, query, values, abort=True):
"""
Execute a query. If it fails, abort. Retry with timeouts on lock
DO NOT CALL THIS DIRECTLY.
"""
return db_query_execute(cur, query, values, abort=abort) | [
"def",
"namedb_query_execute",
"(",
"cur",
",",
"query",
",",
"values",
",",
"abort",
"=",
"True",
")",
":",
"return",
"db_query_execute",
"(",
"cur",
",",
"query",
",",
"values",
",",
"abort",
"=",
"abort",
")"
] | Execute a query. If it fails, abort. Retry with timeouts on lock
DO NOT CALL THIS DIRECTLY. | [
"Execute",
"a",
"query",
".",
"If",
"it",
"fails",
"abort",
".",
"Retry",
"with",
"timeouts",
"on",
"lock"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L700-L706 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_preorder_insert | def namedb_preorder_insert( cur, preorder_rec ):
"""
Add a name or namespace preorder record, if it doesn't exist already.
DO NOT CALL THIS DIRECTLY.
"""
preorder_row = copy.deepcopy( preorder_rec )
assert 'preorder_hash' in preorder_row, "BUG: missing preorder_hash"
try:
pre... | python | def namedb_preorder_insert( cur, preorder_rec ):
"""
Add a name or namespace preorder record, if it doesn't exist already.
DO NOT CALL THIS DIRECTLY.
"""
preorder_row = copy.deepcopy( preorder_rec )
assert 'preorder_hash' in preorder_row, "BUG: missing preorder_hash"
try:
pre... | [
"def",
"namedb_preorder_insert",
"(",
"cur",
",",
"preorder_rec",
")",
":",
"preorder_row",
"=",
"copy",
".",
"deepcopy",
"(",
"preorder_rec",
")",
"assert",
"'preorder_hash'",
"in",
"preorder_row",
",",
"\"BUG: missing preorder_hash\"",
"try",
":",
"preorder_query",
... | Add a name or namespace preorder record, if it doesn't exist already.
DO NOT CALL THIS DIRECTLY. | [
"Add",
"a",
"name",
"or",
"namespace",
"preorder",
"record",
"if",
"it",
"doesn",
"t",
"exist",
"already",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L709-L728 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_preorder_remove | def namedb_preorder_remove( cur, preorder_hash ):
"""
Remove a preorder hash.
DO NOT CALL THIS DIRECTLY.
"""
try:
query, values = namedb_delete_prepare( cur, 'preorder_hash', preorder_hash, 'preorders' )
except Exception, e:
log.exception(e)
log.error("FATAL: Failed to d... | python | def namedb_preorder_remove( cur, preorder_hash ):
"""
Remove a preorder hash.
DO NOT CALL THIS DIRECTLY.
"""
try:
query, values = namedb_delete_prepare( cur, 'preorder_hash', preorder_hash, 'preorders' )
except Exception, e:
log.exception(e)
log.error("FATAL: Failed to d... | [
"def",
"namedb_preorder_remove",
"(",
"cur",
",",
"preorder_hash",
")",
":",
"try",
":",
"query",
",",
"values",
"=",
"namedb_delete_prepare",
"(",
"cur",
",",
"'preorder_hash'",
",",
"preorder_hash",
",",
"'preorders'",
")",
"except",
"Exception",
",",
"e",
"... | Remove a preorder hash.
DO NOT CALL THIS DIRECTLY. | [
"Remove",
"a",
"preorder",
"hash",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L731-L746 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_name_insert | def namedb_name_insert( cur, input_name_rec ):
"""
Add the given name record to the database,
if it doesn't exist already.
"""
name_rec = copy.deepcopy( input_name_rec )
namedb_name_fields_check( name_rec )
try:
query, values = namedb_insert_prepare( cur, name_rec, "name_records... | python | def namedb_name_insert( cur, input_name_rec ):
"""
Add the given name record to the database,
if it doesn't exist already.
"""
name_rec = copy.deepcopy( input_name_rec )
namedb_name_fields_check( name_rec )
try:
query, values = namedb_insert_prepare( cur, name_rec, "name_records... | [
"def",
"namedb_name_insert",
"(",
"cur",
",",
"input_name_rec",
")",
":",
"name_rec",
"=",
"copy",
".",
"deepcopy",
"(",
"input_name_rec",
")",
"namedb_name_fields_check",
"(",
"name_rec",
")",
"try",
":",
"query",
",",
"values",
"=",
"namedb_insert_prepare",
"(... | Add the given name record to the database,
if it doesn't exist already. | [
"Add",
"the",
"given",
"name",
"record",
"to",
"the",
"database",
"if",
"it",
"doesn",
"t",
"exist",
"already",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L775-L793 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_name_update | def namedb_name_update( cur, opcode, input_opdata, only_if={}, constraints_ignored=[] ):
"""
Update an existing name in the database.
If non-empty, only update the given fields.
DO NOT CALL THIS METHOD DIRECTLY.
"""
opdata = copy.deepcopy( input_opdata )
namedb_name_fields_check( opdata )
... | python | def namedb_name_update( cur, opcode, input_opdata, only_if={}, constraints_ignored=[] ):
"""
Update an existing name in the database.
If non-empty, only update the given fields.
DO NOT CALL THIS METHOD DIRECTLY.
"""
opdata = copy.deepcopy( input_opdata )
namedb_name_fields_check( opdata )
... | [
"def",
"namedb_name_update",
"(",
"cur",
",",
"opcode",
",",
"input_opdata",
",",
"only_if",
"=",
"{",
"}",
",",
"constraints_ignored",
"=",
"[",
"]",
")",
":",
"opdata",
"=",
"copy",
".",
"deepcopy",
"(",
"input_opdata",
")",
"namedb_name_fields_check",
"("... | Update an existing name in the database.
If non-empty, only update the given fields.
DO NOT CALL THIS METHOD DIRECTLY. | [
"Update",
"an",
"existing",
"name",
"in",
"the",
"database",
".",
"If",
"non",
"-",
"empty",
"only",
"update",
"the",
"given",
"fields",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L796-L837 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_state_mutation_sanity_check | def namedb_state_mutation_sanity_check( opcode, op_data ):
"""
Make sure all mutate fields for this operation are present.
Return True if so
Raise exception if not
"""
# sanity check: each mutate field in the operation must be defined in op_data, even if it's null.
missing = []
mutate_... | python | def namedb_state_mutation_sanity_check( opcode, op_data ):
"""
Make sure all mutate fields for this operation are present.
Return True if so
Raise exception if not
"""
# sanity check: each mutate field in the operation must be defined in op_data, even if it's null.
missing = []
mutate_... | [
"def",
"namedb_state_mutation_sanity_check",
"(",
"opcode",
",",
"op_data",
")",
":",
"missing",
"=",
"[",
"]",
"mutate_fields",
"=",
"op_get_mutate_fields",
"(",
"opcode",
")",
"for",
"field",
"in",
"mutate_fields",
":",
"if",
"field",
"not",
"in",
"op_data",
... | Make sure all mutate fields for this operation are present.
Return True if so
Raise exception if not | [
"Make",
"sure",
"all",
"mutate",
"fields",
"for",
"this",
"operation",
"are",
"present",
".",
"Return",
"True",
"if",
"so",
"Raise",
"exception",
"if",
"not"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L963-L978 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_last_name_import | def namedb_get_last_name_import(cur, name, block_id, vtxindex):
"""
Find the last name import for this name
"""
query = 'SELECT history_data FROM history WHERE history_id = ? AND (block_id < ? OR (block_id = ? AND vtxindex < ?)) ' + \
'ORDER BY block_id DESC,vtxindex DESC LIMIT 1;'
args... | python | def namedb_get_last_name_import(cur, name, block_id, vtxindex):
"""
Find the last name import for this name
"""
query = 'SELECT history_data FROM history WHERE history_id = ? AND (block_id < ? OR (block_id = ? AND vtxindex < ?)) ' + \
'ORDER BY block_id DESC,vtxindex DESC LIMIT 1;'
args... | [
"def",
"namedb_get_last_name_import",
"(",
"cur",
",",
"name",
",",
"block_id",
",",
"vtxindex",
")",
":",
"query",
"=",
"'SELECT history_data FROM history WHERE history_id = ? AND (block_id < ? OR (block_id = ? AND vtxindex < ?)) '",
"+",
"'ORDER BY block_id DESC,vtxindex DESC LIMIT... | Find the last name import for this name | [
"Find",
"the",
"last",
"name",
"import",
"for",
"this",
"name"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1328-L1343 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_account_transaction_save | def namedb_account_transaction_save(cur, address, token_type, new_credit_value, new_debit_value, block_id, vtxindex, txid, existing_account):
"""
Insert the new state of an account at a particular point in time.
The data must be for a never-before-seen (txid,block_id,vtxindex) set in the accounts table, bu... | python | def namedb_account_transaction_save(cur, address, token_type, new_credit_value, new_debit_value, block_id, vtxindex, txid, existing_account):
"""
Insert the new state of an account at a particular point in time.
The data must be for a never-before-seen (txid,block_id,vtxindex) set in the accounts table, bu... | [
"def",
"namedb_account_transaction_save",
"(",
"cur",
",",
"address",
",",
"token_type",
",",
"new_credit_value",
",",
"new_debit_value",
",",
"block_id",
",",
"vtxindex",
",",
"txid",
",",
"existing_account",
")",
":",
"if",
"existing_account",
"is",
"None",
":",... | Insert the new state of an account at a particular point in time.
The data must be for a never-before-seen (txid,block_id,vtxindex) set in the accounts table, but must
correspond to an entry in the history table.
If existing_account is not None, then copy all other remaining fields from it.
Return Tr... | [
"Insert",
"the",
"new",
"state",
"of",
"an",
"account",
"at",
"a",
"particular",
"point",
"in",
"time",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1420-L1456 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_account_debit | def namedb_account_debit(cur, account_addr, token_type, amount, block_id, vtxindex, txid):
"""
Debit an account at a particular point in time by the given amount.
Insert a new history entry for the account into the accounts table.
The account must exist
Abort the program if the account balance goe... | python | def namedb_account_debit(cur, account_addr, token_type, amount, block_id, vtxindex, txid):
"""
Debit an account at a particular point in time by the given amount.
Insert a new history entry for the account into the accounts table.
The account must exist
Abort the program if the account balance goe... | [
"def",
"namedb_account_debit",
"(",
"cur",
",",
"account_addr",
",",
"token_type",
",",
"amount",
",",
"block_id",
",",
"vtxindex",
",",
"txid",
")",
":",
"account",
"=",
"namedb_get_account",
"(",
"cur",
",",
"account_addr",
",",
"token_type",
")",
"if",
"a... | Debit an account at a particular point in time by the given amount.
Insert a new history entry for the account into the accounts table.
The account must exist
Abort the program if the account balance goes negative, or the count does not exist | [
"Debit",
"an",
"account",
"at",
"a",
"particular",
"point",
"in",
"time",
"by",
"the",
"given",
"amount",
".",
"Insert",
"a",
"new",
"history",
"entry",
"for",
"the",
"account",
"into",
"the",
"accounts",
"table",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1459-L1492 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_accounts_vest | def namedb_accounts_vest(cur, block_height):
"""
Vest tokens at this block to all recipients.
Goes through the vesting table and debits each account that should vest on this block.
"""
sql = 'SELECT * FROM account_vesting WHERE block_id = ?'
args = (block_height,)
vesting_rows = namedb_quer... | python | def namedb_accounts_vest(cur, block_height):
"""
Vest tokens at this block to all recipients.
Goes through the vesting table and debits each account that should vest on this block.
"""
sql = 'SELECT * FROM account_vesting WHERE block_id = ?'
args = (block_height,)
vesting_rows = namedb_quer... | [
"def",
"namedb_accounts_vest",
"(",
"cur",
",",
"block_height",
")",
":",
"sql",
"=",
"'SELECT * FROM account_vesting WHERE block_id = ?'",
"args",
"=",
"(",
"block_height",
",",
")",
"vesting_rows",
"=",
"namedb_query_execute",
"(",
"cur",
",",
"sql",
",",
"args",
... | Vest tokens at this block to all recipients.
Goes through the vesting table and debits each account that should vest on this block. | [
"Vest",
"tokens",
"at",
"this",
"block",
"to",
"all",
"recipients",
".",
"Goes",
"through",
"the",
"vesting",
"table",
"and",
"debits",
"each",
"account",
"that",
"should",
"vest",
"on",
"this",
"block",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1538-L1568 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_is_history_snapshot | def namedb_is_history_snapshot( history_snapshot ):
"""
Given a dict, verify that it is a history snapshot.
It must have all consensus fields.
Return True if so.
Raise an exception of it doesn't.
"""
# sanity check: each mutate field in the operation must be defined in op_data, even if... | python | def namedb_is_history_snapshot( history_snapshot ):
"""
Given a dict, verify that it is a history snapshot.
It must have all consensus fields.
Return True if so.
Raise an exception of it doesn't.
"""
# sanity check: each mutate field in the operation must be defined in op_data, even if... | [
"def",
"namedb_is_history_snapshot",
"(",
"history_snapshot",
")",
":",
"missing",
"=",
"[",
"]",
"assert",
"'op'",
"in",
"history_snapshot",
".",
"keys",
"(",
")",
",",
"\"BUG: no op given\"",
"opcode",
"=",
"op_get_opcode_name",
"(",
"history_snapshot",
"[",
"'o... | Given a dict, verify that it is a history snapshot.
It must have all consensus fields.
Return True if so.
Raise an exception of it doesn't. | [
"Given",
"a",
"dict",
"verify",
"that",
"it",
"is",
"a",
"history",
"snapshot",
".",
"It",
"must",
"have",
"all",
"consensus",
"fields",
".",
"Return",
"True",
"if",
"so",
".",
"Raise",
"an",
"exception",
"of",
"it",
"doesn",
"t",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1571-L1593 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_account_tokens | def namedb_get_account_tokens(cur, address):
"""
Get an account's tokens
Returns the list of tokens on success
Returns None if not found
"""
sql = 'SELECT DISTINCT type FROM accounts WHERE address = ?;'
args = (address,)
rows = namedb_query_execute(cur, sql, args)
ret = []
for r... | python | def namedb_get_account_tokens(cur, address):
"""
Get an account's tokens
Returns the list of tokens on success
Returns None if not found
"""
sql = 'SELECT DISTINCT type FROM accounts WHERE address = ?;'
args = (address,)
rows = namedb_query_execute(cur, sql, args)
ret = []
for r... | [
"def",
"namedb_get_account_tokens",
"(",
"cur",
",",
"address",
")",
":",
"sql",
"=",
"'SELECT DISTINCT type FROM accounts WHERE address = ?;'",
"args",
"=",
"(",
"address",
",",
")",
"rows",
"=",
"namedb_query_execute",
"(",
"cur",
",",
"sql",
",",
"args",
")",
... | Get an account's tokens
Returns the list of tokens on success
Returns None if not found | [
"Get",
"an",
"account",
"s",
"tokens",
"Returns",
"the",
"list",
"of",
"tokens",
"on",
"success",
"Returns",
"None",
"if",
"not",
"found"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1742-L1756 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_account | def namedb_get_account(cur, address, token_type):
"""
Get an account, given the address.
Returns the account row on success
Returns None if not found
"""
sql = 'SELECT * FROM accounts WHERE address = ? AND type = ? ORDER BY block_id DESC, vtxindex DESC LIMIT 1;'
args = (address,token_type)
... | python | def namedb_get_account(cur, address, token_type):
"""
Get an account, given the address.
Returns the account row on success
Returns None if not found
"""
sql = 'SELECT * FROM accounts WHERE address = ? AND type = ? ORDER BY block_id DESC, vtxindex DESC LIMIT 1;'
args = (address,token_type)
... | [
"def",
"namedb_get_account",
"(",
"cur",
",",
"address",
",",
"token_type",
")",
":",
"sql",
"=",
"'SELECT * FROM accounts WHERE address = ? AND type = ? ORDER BY block_id DESC, vtxindex DESC LIMIT 1;'",
"args",
"=",
"(",
"address",
",",
"token_type",
")",
"rows",
"=",
"n... | Get an account, given the address.
Returns the account row on success
Returns None if not found | [
"Get",
"an",
"account",
"given",
"the",
"address",
".",
"Returns",
"the",
"account",
"row",
"on",
"success",
"Returns",
"None",
"if",
"not",
"found"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1759-L1775 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_account_diff | def namedb_get_account_diff(current, prior):
"""
Figure out what the expenditure difference is between two accounts.
They must be for the same token type and address.
Calculates current - prior
"""
if current['address'] != prior['address'] or current['type'] != prior['type']:
raise Value... | python | def namedb_get_account_diff(current, prior):
"""
Figure out what the expenditure difference is between two accounts.
They must be for the same token type and address.
Calculates current - prior
"""
if current['address'] != prior['address'] or current['type'] != prior['type']:
raise Value... | [
"def",
"namedb_get_account_diff",
"(",
"current",
",",
"prior",
")",
":",
"if",
"current",
"[",
"'address'",
"]",
"!=",
"prior",
"[",
"'address'",
"]",
"or",
"current",
"[",
"'type'",
"]",
"!=",
"prior",
"[",
"'type'",
"]",
":",
"raise",
"ValueError",
"(... | Figure out what the expenditure difference is between two accounts.
They must be for the same token type and address.
Calculates current - prior | [
"Figure",
"out",
"what",
"the",
"expenditure",
"difference",
"is",
"between",
"two",
"accounts",
".",
"They",
"must",
"be",
"for",
"the",
"same",
"token",
"type",
"and",
"address",
".",
"Calculates",
"current",
"-",
"prior"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1808-L1818 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_account_history | def namedb_get_account_history(cur, address, offset=None, count=None):
"""
Get the history of an account's tokens
"""
sql = 'SELECT * FROM accounts WHERE address = ? ORDER BY block_id DESC, vtxindex DESC'
args = (address,)
if count is not None:
sql += ' LIMIT ?'
args += (count,)... | python | def namedb_get_account_history(cur, address, offset=None, count=None):
"""
Get the history of an account's tokens
"""
sql = 'SELECT * FROM accounts WHERE address = ? ORDER BY block_id DESC, vtxindex DESC'
args = (address,)
if count is not None:
sql += ' LIMIT ?'
args += (count,)... | [
"def",
"namedb_get_account_history",
"(",
"cur",
",",
"address",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
")",
":",
"sql",
"=",
"'SELECT * FROM accounts WHERE address = ? ORDER BY block_id DESC, vtxindex DESC'",
"args",
"=",
"(",
"address",
",",
")",
"... | Get the history of an account's tokens | [
"Get",
"the",
"history",
"of",
"an",
"account",
"s",
"tokens"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1821-L1845 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_all_account_addresses | def namedb_get_all_account_addresses(cur):
"""
TESTING ONLY
get all account addresses
"""
assert BLOCKSTACK_TEST, 'BUG: this method is only available in test mode'
sql = 'SELECT DISTINCT address FROM accounts;'
args = ()
rows = namedb_query_execute(cur, sql, args)
ret = []
for r... | python | def namedb_get_all_account_addresses(cur):
"""
TESTING ONLY
get all account addresses
"""
assert BLOCKSTACK_TEST, 'BUG: this method is only available in test mode'
sql = 'SELECT DISTINCT address FROM accounts;'
args = ()
rows = namedb_query_execute(cur, sql, args)
ret = []
for r... | [
"def",
"namedb_get_all_account_addresses",
"(",
"cur",
")",
":",
"assert",
"BLOCKSTACK_TEST",
",",
"'BUG: this method is only available in test mode'",
"sql",
"=",
"'SELECT DISTINCT address FROM accounts;'",
"args",
"=",
"(",
")",
"rows",
"=",
"namedb_query_execute",
"(",
"... | TESTING ONLY
get all account addresses | [
"TESTING",
"ONLY",
"get",
"all",
"account",
"addresses"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L1848-L1862 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_name_at | def namedb_get_name_at(cur, name, block_number, include_expired=False):
"""
Get the sequence of states that a name record was in at a particular block height.
There can be more than one if the name changed during the block.
Returns only unexpired names by default. Can return expired names with include... | python | def namedb_get_name_at(cur, name, block_number, include_expired=False):
"""
Get the sequence of states that a name record was in at a particular block height.
There can be more than one if the name changed during the block.
Returns only unexpired names by default. Can return expired names with include... | [
"def",
"namedb_get_name_at",
"(",
"cur",
",",
"name",
",",
"block_number",
",",
"include_expired",
"=",
"False",
")",
":",
"if",
"not",
"include_expired",
":",
"name_rec",
"=",
"namedb_get_name",
"(",
"cur",
",",
"name",
",",
"block_number",
",",
"include_expi... | Get the sequence of states that a name record was in at a particular block height.
There can be more than one if the name changed during the block.
Returns only unexpired names by default. Can return expired names with include_expired=True
Returns None if this name does not exist at this block height. | [
"Get",
"the",
"sequence",
"of",
"states",
"that",
"a",
"name",
"record",
"was",
"in",
"at",
"a",
"particular",
"block",
"height",
".",
"There",
"can",
"be",
"more",
"than",
"one",
"if",
"the",
"name",
"changed",
"during",
"the",
"block",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2150-L2171 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_namespace_at | def namedb_get_namespace_at(cur, namespace_id, block_number, include_expired=False):
"""
Get the sequence of states that a namespace record was in at a particular block height.
There can be more than one if the namespace changed durnig the block.
Returns only unexpired namespaces by default. Can r... | python | def namedb_get_namespace_at(cur, namespace_id, block_number, include_expired=False):
"""
Get the sequence of states that a namespace record was in at a particular block height.
There can be more than one if the namespace changed durnig the block.
Returns only unexpired namespaces by default. Can r... | [
"def",
"namedb_get_namespace_at",
"(",
"cur",
",",
"namespace_id",
",",
"block_number",
",",
"include_expired",
"=",
"False",
")",
":",
"if",
"not",
"include_expired",
":",
"namespace_rec",
"=",
"namedb_get_namespace",
"(",
"cur",
",",
"namespace_id",
",",
"block_... | Get the sequence of states that a namespace record was in at a particular block height.
There can be more than one if the namespace changed durnig the block.
Returns only unexpired namespaces by default. Can return expired namespaces with include_expired=True | [
"Get",
"the",
"sequence",
"of",
"states",
"that",
"a",
"namespace",
"record",
"was",
"in",
"at",
"a",
"particular",
"block",
"height",
".",
"There",
"can",
"be",
"more",
"than",
"one",
"if",
"the",
"namespace",
"changed",
"durnig",
"the",
"block",
".",
"... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2174-L2194 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_account_balance | def namedb_get_account_balance(account):
"""
Get the balance of an account for a particular type of token.
This is its credits minus its debits.
Returns the current balance on success.
Aborts on error, or if the balance is somehow negative.
"""
# NOTE: this is only possible because Python do... | python | def namedb_get_account_balance(account):
"""
Get the balance of an account for a particular type of token.
This is its credits minus its debits.
Returns the current balance on success.
Aborts on error, or if the balance is somehow negative.
"""
# NOTE: this is only possible because Python do... | [
"def",
"namedb_get_account_balance",
"(",
"account",
")",
":",
"balance",
"=",
"account",
"[",
"'credit_value'",
"]",
"-",
"account",
"[",
"'debit_value'",
"]",
"if",
"balance",
"<",
"0",
":",
"log",
".",
"fatal",
"(",
"\"Balance of {} is {} (credits = {}, debits ... | Get the balance of an account for a particular type of token.
This is its credits minus its debits.
Returns the current balance on success.
Aborts on error, or if the balance is somehow negative. | [
"Get",
"the",
"balance",
"of",
"an",
"account",
"for",
"a",
"particular",
"type",
"of",
"token",
".",
"This",
"is",
"its",
"credits",
"minus",
"its",
"debits",
".",
"Returns",
"the",
"current",
"balance",
"on",
"success",
".",
"Aborts",
"on",
"error",
"o... | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2197-L2211 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_preorder | def namedb_get_preorder(cur, preorder_hash, current_block_number, include_expired=False, expiry_time=None):
"""
Get a preorder record by hash.
If include_expired is set, then so must expiry_time
Return None if not found.
"""
select_query = None
args = None
if include_expired:
... | python | def namedb_get_preorder(cur, preorder_hash, current_block_number, include_expired=False, expiry_time=None):
"""
Get a preorder record by hash.
If include_expired is set, then so must expiry_time
Return None if not found.
"""
select_query = None
args = None
if include_expired:
... | [
"def",
"namedb_get_preorder",
"(",
"cur",
",",
"preorder_hash",
",",
"current_block_number",
",",
"include_expired",
"=",
"False",
",",
"expiry_time",
"=",
"None",
")",
":",
"select_query",
"=",
"None",
"args",
"=",
"None",
"if",
"include_expired",
":",
"select_... | Get a preorder record by hash.
If include_expired is set, then so must expiry_time
Return None if not found. | [
"Get",
"a",
"preorder",
"record",
"by",
"hash",
".",
"If",
"include_expired",
"is",
"set",
"then",
"so",
"must",
"expiry_time",
"Return",
"None",
"if",
"not",
"found",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2214-L2242 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_num_historic_names_by_address | def namedb_get_num_historic_names_by_address( cur, address ):
"""
Get the number of names owned by an address throughout history
"""
select_query = "SELECT COUNT(*) FROM name_records JOIN history ON name_records.name = history.history_id " + \
"WHERE history.creator_address = ?;"
... | python | def namedb_get_num_historic_names_by_address( cur, address ):
"""
Get the number of names owned by an address throughout history
"""
select_query = "SELECT COUNT(*) FROM name_records JOIN history ON name_records.name = history.history_id " + \
"WHERE history.creator_address = ?;"
... | [
"def",
"namedb_get_num_historic_names_by_address",
"(",
"cur",
",",
"address",
")",
":",
"select_query",
"=",
"\"SELECT COUNT(*) FROM name_records JOIN history ON name_records.name = history.history_id \"",
"+",
"\"WHERE history.creator_address = ?;\"",
"args",
"=",
"(",
"address",
... | Get the number of names owned by an address throughout history | [
"Get",
"the",
"number",
"of",
"names",
"owned",
"by",
"an",
"address",
"throughout",
"history"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2269-L2280 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_num_names | def namedb_get_num_names( cur, current_block, include_expired=False ):
"""
Get the number of names that exist at the current block
"""
unexpired_query = ""
unexpired_args = ()
if not include_expired:
# count all names, including expired ones
unexpired_query, unexpired_args = nam... | python | def namedb_get_num_names( cur, current_block, include_expired=False ):
"""
Get the number of names that exist at the current block
"""
unexpired_query = ""
unexpired_args = ()
if not include_expired:
# count all names, including expired ones
unexpired_query, unexpired_args = nam... | [
"def",
"namedb_get_num_names",
"(",
"cur",
",",
"current_block",
",",
"include_expired",
"=",
"False",
")",
":",
"unexpired_query",
"=",
"\"\"",
"unexpired_args",
"=",
"(",
")",
"if",
"not",
"include_expired",
":",
"unexpired_query",
",",
"unexpired_args",
"=",
... | Get the number of names that exist at the current block | [
"Get",
"the",
"number",
"of",
"names",
"that",
"exist",
"at",
"the",
"current",
"block"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2458-L2474 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_all_names | def namedb_get_all_names( cur, current_block, offset=None, count=None, include_expired=False ):
"""
Get a list of all names in the database, optionally
paginated with offset and count. Exclude expired names. Include revoked names.
"""
unexpired_query = ""
unexpired_args = ()
if not inclu... | python | def namedb_get_all_names( cur, current_block, offset=None, count=None, include_expired=False ):
"""
Get a list of all names in the database, optionally
paginated with offset and count. Exclude expired names. Include revoked names.
"""
unexpired_query = ""
unexpired_args = ()
if not inclu... | [
"def",
"namedb_get_all_names",
"(",
"cur",
",",
"current_block",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
",",
"include_expired",
"=",
"False",
")",
":",
"unexpired_query",
"=",
"\"\"",
"unexpired_args",
"=",
"(",
")",
"if",
"not",
"include_exp... | Get a list of all names in the database, optionally
paginated with offset and count. Exclude expired names. Include revoked names. | [
"Get",
"a",
"list",
"of",
"all",
"names",
"in",
"the",
"database",
"optionally",
"paginated",
"with",
"offset",
"and",
"count",
".",
"Exclude",
"expired",
"names",
".",
"Include",
"revoked",
"names",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2477-L2505 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_num_names_in_namespace | def namedb_get_num_names_in_namespace( cur, namespace_id, current_block ):
"""
Get the number of names in a given namespace
"""
unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
query = "SELECT COUNT(name_records.name) FROM name_records JOIN namespaces ON name_r... | python | def namedb_get_num_names_in_namespace( cur, namespace_id, current_block ):
"""
Get the number of names in a given namespace
"""
unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
query = "SELECT COUNT(name_records.name) FROM name_records JOIN namespaces ON name_r... | [
"def",
"namedb_get_num_names_in_namespace",
"(",
"cur",
",",
"namespace_id",
",",
"current_block",
")",
":",
"unexpired_query",
",",
"unexpired_args",
"=",
"namedb_select_where_unexpired_names",
"(",
"current_block",
")",
"query",
"=",
"\"SELECT COUNT(name_records.name) FROM ... | Get the number of names in a given namespace | [
"Get",
"the",
"number",
"of",
"names",
"in",
"a",
"given",
"namespace"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2508-L2518 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_names_in_namespace | def namedb_get_names_in_namespace( cur, namespace_id, current_block, offset=None, count=None ):
"""
Get a list of all names in a namespace, optionally
paginated with offset and count. Exclude expired names
"""
unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
... | python | def namedb_get_names_in_namespace( cur, namespace_id, current_block, offset=None, count=None ):
"""
Get a list of all names in a namespace, optionally
paginated with offset and count. Exclude expired names
"""
unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
... | [
"def",
"namedb_get_names_in_namespace",
"(",
"cur",
",",
"namespace_id",
",",
"current_block",
",",
"offset",
"=",
"None",
",",
"count",
"=",
"None",
")",
":",
"unexpired_query",
",",
"unexpired_args",
"=",
"namedb_select_where_unexpired_names",
"(",
"current_block",
... | Get a list of all names in a namespace, optionally
paginated with offset and count. Exclude expired names | [
"Get",
"a",
"list",
"of",
"all",
"names",
"in",
"a",
"namespace",
"optionally",
"paginated",
"with",
"offset",
"and",
"count",
".",
"Exclude",
"expired",
"names"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2521-L2543 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_all_namespace_ids | def namedb_get_all_namespace_ids( cur ):
"""
Get a list of all READY namespace IDs.
"""
query = "SELECT namespace_id FROM namespaces WHERE op = ?;"
args = (NAMESPACE_READY,)
namespace_rows = namedb_query_execute( cur, query, args )
ret = []
for namespace_row in namespace_rows:
... | python | def namedb_get_all_namespace_ids( cur ):
"""
Get a list of all READY namespace IDs.
"""
query = "SELECT namespace_id FROM namespaces WHERE op = ?;"
args = (NAMESPACE_READY,)
namespace_rows = namedb_query_execute( cur, query, args )
ret = []
for namespace_row in namespace_rows:
... | [
"def",
"namedb_get_all_namespace_ids",
"(",
"cur",
")",
":",
"query",
"=",
"\"SELECT namespace_id FROM namespaces WHERE op = ?;\"",
"args",
"=",
"(",
"NAMESPACE_READY",
",",
")",
"namespace_rows",
"=",
"namedb_query_execute",
"(",
"cur",
",",
"query",
",",
"args",
")"... | Get a list of all READY namespace IDs. | [
"Get",
"a",
"list",
"of",
"all",
"READY",
"namespace",
"IDs",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2546-L2559 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_all_preordered_namespace_hashes | def namedb_get_all_preordered_namespace_hashes( cur, current_block ):
"""
Get a list of all preordered namespace hashes that haven't expired yet.
Used for testing
"""
query = "SELECT preorder_hash FROM preorders WHERE op = ? AND block_number >= ? AND block_number < ?;"
args = (NAMESPACE_PREORDER... | python | def namedb_get_all_preordered_namespace_hashes( cur, current_block ):
"""
Get a list of all preordered namespace hashes that haven't expired yet.
Used for testing
"""
query = "SELECT preorder_hash FROM preorders WHERE op = ? AND block_number >= ? AND block_number < ?;"
args = (NAMESPACE_PREORDER... | [
"def",
"namedb_get_all_preordered_namespace_hashes",
"(",
"cur",
",",
"current_block",
")",
":",
"query",
"=",
"\"SELECT preorder_hash FROM preorders WHERE op = ? AND block_number >= ? AND block_number < ?;\"",
"args",
"=",
"(",
"NAMESPACE_PREORDER",
",",
"current_block",
",",
"c... | Get a list of all preordered namespace hashes that haven't expired yet.
Used for testing | [
"Get",
"a",
"list",
"of",
"all",
"preordered",
"namespace",
"hashes",
"that",
"haven",
"t",
"expired",
"yet",
".",
"Used",
"for",
"testing"
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2562-L2575 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_all_revealed_namespace_ids | def namedb_get_all_revealed_namespace_ids( self, current_block ):
"""
Get all non-expired revealed namespaces.
"""
query = "SELECT namespace_id FROM namespaces WHERE op = ? AND reveal_block < ?;"
args = (NAMESPACE_REVEAL, current_block + NAMESPACE_REVEAL_EXPIRE )
namespace_rows = namedb_qu... | python | def namedb_get_all_revealed_namespace_ids( self, current_block ):
"""
Get all non-expired revealed namespaces.
"""
query = "SELECT namespace_id FROM namespaces WHERE op = ? AND reveal_block < ?;"
args = (NAMESPACE_REVEAL, current_block + NAMESPACE_REVEAL_EXPIRE )
namespace_rows = namedb_qu... | [
"def",
"namedb_get_all_revealed_namespace_ids",
"(",
"self",
",",
"current_block",
")",
":",
"query",
"=",
"\"SELECT namespace_id FROM namespaces WHERE op = ? AND reveal_block < ?;\"",
"args",
"=",
"(",
"NAMESPACE_REVEAL",
",",
"current_block",
"+",
"NAMESPACE_REVEAL_EXPIRE",
"... | Get all non-expired revealed namespaces. | [
"Get",
"all",
"non",
"-",
"expired",
"revealed",
"namespaces",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2578-L2591 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_all_importing_namespace_hashes | def namedb_get_all_importing_namespace_hashes( self, current_block ):
"""
Get the list of all non-expired preordered and revealed namespace hashes.
"""
query = "SELECT preorder_hash FROM namespaces WHERE (op = ? AND reveal_block < ?) OR (op = ? AND block_number < ?);"
args = (NAMESPACE_REVEAL, curr... | python | def namedb_get_all_importing_namespace_hashes( self, current_block ):
"""
Get the list of all non-expired preordered and revealed namespace hashes.
"""
query = "SELECT preorder_hash FROM namespaces WHERE (op = ? AND reveal_block < ?) OR (op = ? AND block_number < ?);"
args = (NAMESPACE_REVEAL, curr... | [
"def",
"namedb_get_all_importing_namespace_hashes",
"(",
"self",
",",
"current_block",
")",
":",
"query",
"=",
"\"SELECT preorder_hash FROM namespaces WHERE (op = ? AND reveal_block < ?) OR (op = ? AND block_number < ?);\"",
"args",
"=",
"(",
"NAMESPACE_REVEAL",
",",
"current_block",... | Get the list of all non-expired preordered and revealed namespace hashes. | [
"Get",
"the",
"list",
"of",
"all",
"non",
"-",
"expired",
"preordered",
"and",
"revealed",
"namespace",
"hashes",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2594-L2607 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_names_by_sender | def namedb_get_names_by_sender( cur, sender, current_block ):
"""
Given a sender pubkey script, find all the non-expired non-revoked names owned by it.
Return None if the sender owns no names.
"""
unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
query = "S... | python | def namedb_get_names_by_sender( cur, sender, current_block ):
"""
Given a sender pubkey script, find all the non-expired non-revoked names owned by it.
Return None if the sender owns no names.
"""
unexpired_query, unexpired_args = namedb_select_where_unexpired_names( current_block )
query = "S... | [
"def",
"namedb_get_names_by_sender",
"(",
"cur",
",",
"sender",
",",
"current_block",
")",
":",
"unexpired_query",
",",
"unexpired_args",
"=",
"namedb_select_where_unexpired_names",
"(",
"current_block",
")",
"query",
"=",
"\"SELECT name_records.name FROM name_records JOIN na... | Given a sender pubkey script, find all the non-expired non-revoked names owned by it.
Return None if the sender owns no names. | [
"Given",
"a",
"sender",
"pubkey",
"script",
"find",
"all",
"the",
"non",
"-",
"expired",
"non",
"-",
"revoked",
"names",
"owned",
"by",
"it",
".",
"Return",
"None",
"if",
"the",
"sender",
"owns",
"no",
"names",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2610-L2629 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_namespace_preorder | def namedb_get_namespace_preorder( db, namespace_preorder_hash, current_block ):
"""
Get a namespace preorder, given its hash.
Return the preorder record on success.
Return None if not found, or if it expired, or if the namespace was revealed or readied.
"""
cur = db.cursor()
select_query ... | python | def namedb_get_namespace_preorder( db, namespace_preorder_hash, current_block ):
"""
Get a namespace preorder, given its hash.
Return the preorder record on success.
Return None if not found, or if it expired, or if the namespace was revealed or readied.
"""
cur = db.cursor()
select_query ... | [
"def",
"namedb_get_namespace_preorder",
"(",
"db",
",",
"namespace_preorder_hash",
",",
"current_block",
")",
":",
"cur",
"=",
"db",
".",
"cursor",
"(",
")",
"select_query",
"=",
"\"SELECT * FROM preorders WHERE preorder_hash = ? AND op = ? AND block_number < ?;\"",
"args",
... | Get a namespace preorder, given its hash.
Return the preorder record on success.
Return None if not found, or if it expired, or if the namespace was revealed or readied. | [
"Get",
"a",
"namespace",
"preorder",
"given",
"its",
"hash",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2676-L2708 | train |
blockstack/blockstack-core | blockstack/lib/nameset/db.py | namedb_get_namespace_ready | def namedb_get_namespace_ready( cur, namespace_id, include_history=True ):
"""
Get a ready namespace, and optionally its history.
Only return a namespace if it is ready.
"""
select_query = "SELECT * FROM namespaces WHERE namespace_id = ? AND op = ?;"
namespace_rows = namedb_query_execute( cur, ... | python | def namedb_get_namespace_ready( cur, namespace_id, include_history=True ):
"""
Get a ready namespace, and optionally its history.
Only return a namespace if it is ready.
"""
select_query = "SELECT * FROM namespaces WHERE namespace_id = ? AND op = ?;"
namespace_rows = namedb_query_execute( cur, ... | [
"def",
"namedb_get_namespace_ready",
"(",
"cur",
",",
"namespace_id",
",",
"include_history",
"=",
"True",
")",
":",
"select_query",
"=",
"\"SELECT * FROM namespaces WHERE namespace_id = ? AND op = ?;\"",
"namespace_rows",
"=",
"namedb_query_execute",
"(",
"cur",
",",
"sele... | Get a ready namespace, and optionally its history.
Only return a namespace if it is ready. | [
"Get",
"a",
"ready",
"namespace",
"and",
"optionally",
"its",
"history",
".",
"Only",
"return",
"a",
"namespace",
"if",
"it",
"is",
"ready",
"."
] | 1dcfdd39b152d29ce13e736a6a1a0981401a0505 | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2740-L2762 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.