id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
230,700
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
230,701
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'", "]", "# deny updates if we exceed quota--the only lega...
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
230,702
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
230,703
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
230,704
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 the zone file is a string, then parse it ", "if", "isinstance", "(", "zone_file", ",", "(", "str", ",", "unicode", ")", ")", ":", "try", "...
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
230,705
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
230,706
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
230,707
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", ")", ":", "# sanity check ", "if", "not", "is_b40", "(", "namespace_i...
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
230,708
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
230,709
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
230,710
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
230,711
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
230,712
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
230,713
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", ")", ":", "# primary key corresponds to a real column ", "namedb_assert_fields_match", "(", "cur", ",", "{", "primary_key", ":", "primary_key_value", "}", ",", "...
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
230,714
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
230,715
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
230,716
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
230,717
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
230,718
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
230,719
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", ")", ":", "# sanity check: each mutate field in the operation must be defined in op_data, even if it's null.", "missing", "=", "[", "]", "mutate_fields", "=", "op_get_mutate_fields", "(", "opcode", ")", ...
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
230,720
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
230,721
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
230,722
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
230,723
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
230,724
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", ")", ":", "# sanity check: each mutate field in the operation must be defined in op_data, even if it's null.", "missing", "=", "[", "]", "assert", "'op'", "in", "history_snapshot", ".", "keys", "(", ")", ",", "\"B...
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
230,725
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
230,726
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
230,727
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
230,728
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
230,729
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
230,730
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", ":", "# don't return anything if this name is expired.", "# however, we don't care if the name hasn't been created as of th...
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
230,731
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", ":", "# don't return anything if the namespace was expired at this block.", "# (but do return something here e...
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
230,732
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", ")", ":", "# NOTE: this is only possible because Python does not overflow :P", "balance", "=", "account", "[", "'credit_value'", "]", "-", "account", "[", "'debit_value'", "]", "if", "balance", "<", "0", ":", "log", ...
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
230,733
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
230,734
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
230,735
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", ":", "# count all names, including expired ones", "unexpir...
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
230,736
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
230,737
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
230,738
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
230,739
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
230,740
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
230,741
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
230,742
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
230,743
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
230,744
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
230,745
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
230,746
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_name_from_name_hash128
def namedb_get_name_from_name_hash128( cur, name_hash128, block_number ): """ Given the hexlified 128-bit hash of a name, get the name. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_query = "SELECT name FROM name_records JOIN namespaces ON name_re...
python
def namedb_get_name_from_name_hash128( cur, name_hash128, block_number ): """ Given the hexlified 128-bit hash of a name, get the name. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_query = "SELECT name FROM name_records JOIN namespaces ON name_re...
[ "def", "namedb_get_name_from_name_hash128", "(", "cur", ",", "name_hash128", ",", "block_number", ")", ":", "unexpired_query", ",", "unexpired_args", "=", "namedb_select_where_unexpired_names", "(", "block_number", ")", "select_query", "=", "\"SELECT name FROM name_records JO...
Given the hexlified 128-bit hash of a name, get the name.
[ "Given", "the", "hexlified", "128", "-", "bit", "hash", "of", "a", "name", "get", "the", "name", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2765-L2783
230,747
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_names_with_value_hash
def namedb_get_names_with_value_hash( cur, value_hash, block_number ): """ Get the names with the given value hash. Only includes current, non-revoked names. Return None if there are no names. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_quer...
python
def namedb_get_names_with_value_hash( cur, value_hash, block_number ): """ Get the names with the given value hash. Only includes current, non-revoked names. Return None if there are no names. """ unexpired_query, unexpired_args = namedb_select_where_unexpired_names( block_number ) select_quer...
[ "def", "namedb_get_names_with_value_hash", "(", "cur", ",", "value_hash", ",", "block_number", ")", ":", "unexpired_query", ",", "unexpired_args", "=", "namedb_select_where_unexpired_names", "(", "block_number", ")", "select_query", "=", "\"SELECT name FROM name_records JOIN ...
Get the names with the given value hash. Only includes current, non-revoked names. Return None if there are no names.
[ "Get", "the", "names", "with", "the", "given", "value", "hash", ".", "Only", "includes", "current", "non", "-", "revoked", "names", ".", "Return", "None", "if", "there", "are", "no", "names", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2786-L2806
230,748
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_value_hash_txids
def namedb_get_value_hash_txids(cur, value_hash): """ Get the list of txs that sent this value hash, ordered by block and vtxindex """ query = 'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;' args = (value_hash,) rows = namedb_query_execute(cur, query, args) txids...
python
def namedb_get_value_hash_txids(cur, value_hash): """ Get the list of txs that sent this value hash, ordered by block and vtxindex """ query = 'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;' args = (value_hash,) rows = namedb_query_execute(cur, query, args) txids...
[ "def", "namedb_get_value_hash_txids", "(", "cur", ",", "value_hash", ")", ":", "query", "=", "'SELECT txid FROM history WHERE value_hash = ? ORDER BY block_id,vtxindex;'", "args", "=", "(", "value_hash", ",", ")", "rows", "=", "namedb_query_execute", "(", "cur", ",", "q...
Get the list of txs that sent this value hash, ordered by block and vtxindex
[ "Get", "the", "list", "of", "txs", "that", "sent", "this", "value", "hash", "ordered", "by", "block", "and", "vtxindex" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2809-L2824
230,749
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_get_num_block_vtxs
def namedb_get_num_block_vtxs( cur, block_number ): """ How many virtual transactions were processed for this block? """ select_query = "SELECT vtxindex FROM history WHERE history_id = ?;" args = (block_number,) rows = namedb_query_execute( cur, select_query, args ) count = 0 for r in ...
python
def namedb_get_num_block_vtxs( cur, block_number ): """ How many virtual transactions were processed for this block? """ select_query = "SELECT vtxindex FROM history WHERE history_id = ?;" args = (block_number,) rows = namedb_query_execute( cur, select_query, args ) count = 0 for r in ...
[ "def", "namedb_get_num_block_vtxs", "(", "cur", ",", "block_number", ")", ":", "select_query", "=", "\"SELECT vtxindex FROM history WHERE history_id = ?;\"", "args", "=", "(", "block_number", ",", ")", "rows", "=", "namedb_query_execute", "(", "cur", ",", "select_query"...
How many virtual transactions were processed for this block?
[ "How", "many", "virtual", "transactions", "were", "processed", "for", "this", "block?" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2827-L2839
230,750
blockstack/blockstack-core
blockstack/lib/nameset/db.py
namedb_is_name_zonefile_hash
def namedb_is_name_zonefile_hash(cur, name, zonefile_hash): """ Determine if a zone file hash was sent by a name. Return True if so, false if not """ select_query = 'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?' select_args = (name,zonefile_hash) rows = name...
python
def namedb_is_name_zonefile_hash(cur, name, zonefile_hash): """ Determine if a zone file hash was sent by a name. Return True if so, false if not """ select_query = 'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?' select_args = (name,zonefile_hash) rows = name...
[ "def", "namedb_is_name_zonefile_hash", "(", "cur", ",", "name", ",", "zonefile_hash", ")", ":", "select_query", "=", "'SELECT COUNT(value_hash) FROM history WHERE history_id = ? AND value_hash = ?'", "select_args", "=", "(", "name", ",", "zonefile_hash", ")", "rows", "=", ...
Determine if a zone file hash was sent by a name. Return True if so, false if not
[ "Determine", "if", "a", "zone", "file", "hash", "was", "sent", "by", "a", "name", ".", "Return", "True", "if", "so", "false", "if", "not" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/db.py#L2842-L2857
230,751
blockstack/blockstack-core
blockstack/lib/operations/announce.py
process_announcement
def process_announcement( sender_namerec, op, working_dir ): """ If the announcement is valid, then immediately record it. """ node_config = get_blockstack_opts() # valid announcement announce_hash = op['message_hash'] announcer_id = op['announcer_id'] # verify that it came from thi...
python
def process_announcement( sender_namerec, op, working_dir ): """ If the announcement is valid, then immediately record it. """ node_config = get_blockstack_opts() # valid announcement announce_hash = op['message_hash'] announcer_id = op['announcer_id'] # verify that it came from thi...
[ "def", "process_announcement", "(", "sender_namerec", ",", "op", ",", "working_dir", ")", ":", "node_config", "=", "get_blockstack_opts", "(", ")", "# valid announcement", "announce_hash", "=", "op", "[", "'message_hash'", "]", "announcer_id", "=", "op", "[", "'an...
If the announcement is valid, then immediately record it.
[ "If", "the", "announcement", "is", "valid", "then", "immediately", "record", "it", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/announce.py#L39-L75
230,752
blockstack/blockstack-core
blockstack/lib/operations/announce.py
check
def check( state_engine, nameop, block_id, checked_ops ): """ Log an announcement from the blockstack developers, but first verify that it is correct. Return True if the announcement came from the announce IDs whitelist Return False otherwise """ sender = nameop['sender'] sending_blockc...
python
def check( state_engine, nameop, block_id, checked_ops ): """ Log an announcement from the blockstack developers, but first verify that it is correct. Return True if the announcement came from the announce IDs whitelist Return False otherwise """ sender = nameop['sender'] sending_blockc...
[ "def", "check", "(", "state_engine", ",", "nameop", ",", "block_id", ",", "checked_ops", ")", ":", "sender", "=", "nameop", "[", "'sender'", "]", "sending_blockchain_id", "=", "None", "found", "=", "False", "blockchain_namerec", "=", "None", "for", "blockchain...
Log an announcement from the blockstack developers, but first verify that it is correct. Return True if the announcement came from the announce IDs whitelist Return False otherwise
[ "Log", "an", "announcement", "from", "the", "blockstack", "developers", "but", "first", "verify", "that", "it", "is", "correct", ".", "Return", "True", "if", "the", "announcement", "came", "from", "the", "announce", "IDs", "whitelist", "Return", "False", "othe...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/announce.py#L157-L188
230,753
blockstack/blockstack-core
blockstack/lib/snv.py
get_bitcoind_client
def get_bitcoind_client(): """ Connect to the bitcoind node """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] bitcoind_user = bitcoind_opts['bitcoind_user'] bitcoind_passwd = bitcoind_opts['bitcoind_pass...
python
def get_bitcoind_client(): """ Connect to the bitcoind node """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] bitcoind_user = bitcoind_opts['bitcoind_user'] bitcoind_passwd = bitcoind_opts['bitcoind_pass...
[ "def", "get_bitcoind_client", "(", ")", ":", "bitcoind_opts", "=", "get_bitcoin_opts", "(", ")", "bitcoind_host", "=", "bitcoind_opts", "[", "'bitcoind_server'", "]", "bitcoind_port", "=", "bitcoind_opts", "[", "'bitcoind_port'", "]", "bitcoind_user", "=", "bitcoind_o...
Connect to the bitcoind node
[ "Connect", "to", "the", "bitcoind", "node" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L58-L68
230,754
blockstack/blockstack-core
blockstack/lib/snv.py
txid_to_block_data
def txid_to_block_data(txid, bitcoind_proxy, proxy=None): """ Given a txid, get its block's data. Use SPV to verify the information we receive from the (untrusted) bitcoind host. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Return the (block hash, block data, t...
python
def txid_to_block_data(txid, bitcoind_proxy, proxy=None): """ Given a txid, get its block's data. Use SPV to verify the information we receive from the (untrusted) bitcoind host. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Return the (block hash, block data, t...
[ "def", "txid_to_block_data", "(", "txid", ",", "bitcoind_proxy", ",", "proxy", "=", "None", ")", ":", "proxy", "=", "get_default_proxy", "(", ")", "if", "proxy", "is", "None", "else", "proxy", "timeout", "=", "1.0", "while", "True", ":", "try", ":", "unt...
Given a txid, get its block's data. Use SPV to verify the information we receive from the (untrusted) bitcoind host. @bitcoind_proxy must be a BitcoindConnection (from virtualchain.lib.session) Return the (block hash, block data, txdata) on success Return (None, None, None) on error
[ "Given", "a", "txid", "get", "its", "block", "s", "data", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L71-L150
230,755
blockstack/blockstack-core
blockstack/lib/snv.py
get_consensus_hash_from_tx
def get_consensus_hash_from_tx(tx): """ Given an SPV-verified transaction, extract its consensus hash. Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER, or NAME_TRANSFER. Return hex-encoded consensus hash on success. Return None on error. """ opcode, payload = parse_tx_...
python
def get_consensus_hash_from_tx(tx): """ Given an SPV-verified transaction, extract its consensus hash. Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER, or NAME_TRANSFER. Return hex-encoded consensus hash on success. Return None on error. """ opcode, payload = parse_tx_...
[ "def", "get_consensus_hash_from_tx", "(", "tx", ")", ":", "opcode", ",", "payload", "=", "parse_tx_op_return", "(", "tx", ")", "if", "opcode", "is", "None", "or", "payload", "is", "None", ":", "return", "None", "# only present in NAME_PREORDER, NAMESPACE_PREORDER, N...
Given an SPV-verified transaction, extract its consensus hash. Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER, or NAME_TRANSFER. Return hex-encoded consensus hash on success. Return None on error.
[ "Given", "an", "SPV", "-", "verified", "transaction", "extract", "its", "consensus", "hash", ".", "Only", "works", "of", "the", "tx", "encodes", "a", "NAME_PREORDER", "NAMESPACE_PREORDER", "or", "NAME_TRANSFER", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/snv.py#L278-L304
230,756
blockstack/blockstack-core
blockstack/lib/client.py
json_is_exception
def json_is_exception(resp): """ Is the given response object an exception traceback? Return True if so Return False if not """ if not json_is_error(resp): return False if 'traceback' not in resp.keys() or 'error' not in resp.keys(): return False return True
python
def json_is_exception(resp): """ Is the given response object an exception traceback? Return True if so Return False if not """ if not json_is_error(resp): return False if 'traceback' not in resp.keys() or 'error' not in resp.keys(): return False return True
[ "def", "json_is_exception", "(", "resp", ")", ":", "if", "not", "json_is_error", "(", "resp", ")", ":", "return", "False", "if", "'traceback'", "not", "in", "resp", ".", "keys", "(", ")", "or", "'error'", "not", "in", "resp", ".", "keys", "(", ")", "...
Is the given response object an exception traceback? Return True if so Return False if not
[ "Is", "the", "given", "response", "object", "an", "exception", "traceback?" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L240-L254
230,757
blockstack/blockstack-core
blockstack/lib/client.py
put_zonefiles
def put_zonefiles(hostport, zonefile_data_list, timeout=30, my_hostport=None, proxy=None): """ Push one or more zonefiles to the given server. Each zone file in the list must be base64-encoded Return {'status': True, 'saved': [...]} on success Return {'error': ...} on error """ assert hostp...
python
def put_zonefiles(hostport, zonefile_data_list, timeout=30, my_hostport=None, proxy=None): """ Push one or more zonefiles to the given server. Each zone file in the list must be base64-encoded Return {'status': True, 'saved': [...]} on success Return {'error': ...} on error """ assert hostp...
[ "def", "put_zonefiles", "(", "hostport", ",", "zonefile_data_list", ",", "timeout", "=", "30", ",", "my_hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "hostport", "or", "proxy", ",", "'need either hostport or proxy'", "saved_schema", "=",...
Push one or more zonefiles to the given server. Each zone file in the list must be base64-encoded Return {'status': True, 'saved': [...]} on success Return {'error': ...} on error
[ "Push", "one", "or", "more", "zonefiles", "to", "the", "given", "server", ".", "Each", "zone", "file", "in", "the", "list", "must", "be", "base64", "-", "encoded" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L879-L945
230,758
blockstack/blockstack-core
blockstack/lib/client.py
get_zonefiles_by_block
def get_zonefiles_by_block(from_block, to_block, hostport=None, proxy=None): """ Get zonefile information for zonefiles announced in [@from_block, @to_block] Returns { 'last_block' : server's last seen block, 'zonefile_info' : [ { 'zonefile_hash' : '...', 't...
python
def get_zonefiles_by_block(from_block, to_block, hostport=None, proxy=None): """ Get zonefile information for zonefiles announced in [@from_block, @to_block] Returns { 'last_block' : server's last seen block, 'zonefile_info' : [ { 'zonefile_hash' : '...', 't...
[ "def", "get_zonefiles_by_block", "(", "from_block", ",", "to_block", ",", "hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "hostport", "or", "proxy", ",", "'need either hostport or proxy'", "if", "proxy", "is", "None", ":", "proxy", "=",...
Get zonefile information for zonefiles announced in [@from_block, @to_block] Returns { 'last_block' : server's last seen block, 'zonefile_info' : [ { 'zonefile_hash' : '...', 'txid' : '...', 'block_height' : '...' } ] }
[ "Get", "zonefile", "information", "for", "zonefiles", "announced", "in", "[" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L948-L1005
230,759
blockstack/blockstack-core
blockstack/lib/client.py
get_account_tokens
def get_account_tokens(address, hostport=None, proxy=None): """ Get the types of tokens that an address owns Returns a list of token types """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) tokens_schema = { 'type': 'o...
python
def get_account_tokens(address, hostport=None, proxy=None): """ Get the types of tokens that an address owns Returns a list of token types """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) tokens_schema = { 'type': 'o...
[ "def", "get_account_tokens", "(", "address", ",", "hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect_hostport", "(", "ho...
Get the types of tokens that an address owns Returns a list of token types
[ "Get", "the", "types", "of", "tokens", "that", "an", "address", "owns", "Returns", "a", "list", "of", "token", "types" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L1378-L1441
230,760
blockstack/blockstack-core
blockstack/lib/client.py
get_account_balance
def get_account_balance(address, token_type, hostport=None, proxy=None): """ Get the balance of an account for a particular token Returns an int """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) balance_schema = { 'ty...
python
def get_account_balance(address, token_type, hostport=None, proxy=None): """ Get the balance of an account for a particular token Returns an int """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) balance_schema = { 'ty...
[ "def", "get_account_balance", "(", "address", ",", "token_type", ",", "hostport", "=", "None", ",", "proxy", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect...
Get the balance of an account for a particular token Returns an int
[ "Get", "the", "balance", "of", "an", "account", "for", "a", "particular", "token", "Returns", "an", "int" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L1504-L1558
230,761
blockstack/blockstack-core
blockstack/lib/client.py
get_name_DID
def get_name_DID(name, proxy=None, hostport=None): """ Get the DID for a name or subdomain Return the DID string on success Return None if not found """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) did_schema = { ...
python
def get_name_DID(name, proxy=None, hostport=None): """ Get the DID for a name or subdomain Return the DID string on success Return None if not found """ assert proxy or hostport, 'Need proxy or hostport' if proxy is None: proxy = connect_hostport(hostport) did_schema = { ...
[ "def", "get_name_DID", "(", "name", ",", "proxy", "=", "None", ",", "hostport", "=", "None", ")", ":", "assert", "proxy", "or", "hostport", ",", "'Need proxy or hostport'", "if", "proxy", "is", "None", ":", "proxy", "=", "connect_hostport", "(", "hostport", ...
Get the DID for a name or subdomain Return the DID string on success Return None if not found
[ "Get", "the", "DID", "for", "a", "name", "or", "subdomain", "Return", "the", "DID", "string", "on", "success", "Return", "None", "if", "not", "found" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L2473-L2536
230,762
blockstack/blockstack-core
blockstack/lib/client.py
get_JWT
def get_JWT(url, address=None): """ Given a URL, fetch and decode the JWT it points to. If address is given, then authenticate the JWT with the address. Return None if we could not fetch it, or unable to authenticate it. NOTE: the URL must be usable by the requests library """ jwt_txt = No...
python
def get_JWT(url, address=None): """ Given a URL, fetch and decode the JWT it points to. If address is given, then authenticate the JWT with the address. Return None if we could not fetch it, or unable to authenticate it. NOTE: the URL must be usable by the requests library """ jwt_txt = No...
[ "def", "get_JWT", "(", "url", ",", "address", "=", "None", ")", ":", "jwt_txt", "=", "None", "jwt", "=", "None", "log", ".", "debug", "(", "\"Try {}\"", ".", "format", "(", "url", ")", ")", "# special case: handle file://", "urlinfo", "=", "urllib2", "."...
Given a URL, fetch and decode the JWT it points to. If address is given, then authenticate the JWT with the address. Return None if we could not fetch it, or unable to authenticate it. NOTE: the URL must be usable by the requests library
[ "Given", "a", "URL", "fetch", "and", "decode", "the", "JWT", "it", "points", "to", ".", "If", "address", "is", "given", "then", "authenticate", "the", "JWT", "with", "the", "address", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L3460-L3554
230,763
blockstack/blockstack-core
blockstack/lib/client.py
decode_name_zonefile
def decode_name_zonefile(name, zonefile_txt): """ Decode a zone file for a name. Must be either a well-formed DNS zone file, or a legacy Onename profile. Return None on error """ user_zonefile = None try: # by default, it's a zonefile-formatted text file user_zonefile_defaul...
python
def decode_name_zonefile(name, zonefile_txt): """ Decode a zone file for a name. Must be either a well-formed DNS zone file, or a legacy Onename profile. Return None on error """ user_zonefile = None try: # by default, it's a zonefile-formatted text file user_zonefile_defaul...
[ "def", "decode_name_zonefile", "(", "name", ",", "zonefile_txt", ")", ":", "user_zonefile", "=", "None", "try", ":", "# by default, it's a zonefile-formatted text file", "user_zonefile_defaultdict", "=", "blockstack_zones", ".", "parse_zone_file", "(", "zonefile_txt", ")", ...
Decode a zone file for a name. Must be either a well-formed DNS zone file, or a legacy Onename profile. Return None on error
[ "Decode", "a", "zone", "file", "for", "a", "name", ".", "Must", "be", "either", "a", "well", "-", "formed", "DNS", "zone", "file", "or", "a", "legacy", "Onename", "profile", ".", "Return", "None", "on", "error" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/client.py#L3738-L3776
230,764
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._send_headers
def _send_headers(self, status_code=200, content_type='application/json', more_headers={}): """ Generate and reply headers """ self.send_response(status_code) self.send_header('content-type', content_type) self.send_header('Access-Control-Allow-Origin', '*') # CORS ...
python
def _send_headers(self, status_code=200, content_type='application/json', more_headers={}): """ Generate and reply headers """ self.send_response(status_code) self.send_header('content-type', content_type) self.send_header('Access-Control-Allow-Origin', '*') # CORS ...
[ "def", "_send_headers", "(", "self", ",", "status_code", "=", "200", ",", "content_type", "=", "'application/json'", ",", "more_headers", "=", "{", "}", ")", ":", "self", ".", "send_response", "(", "status_code", ")", "self", ".", "send_header", "(", "'conte...
Generate and reply headers
[ "Generate", "and", "reply", "headers" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L124-L134
230,765
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._reply_json
def _reply_json(self, json_payload, status_code=200): """ Return a JSON-serializable data structure """ self._send_headers(status_code=status_code) json_str = json.dumps(json_payload) self.wfile.write(json_str)
python
def _reply_json(self, json_payload, status_code=200): """ Return a JSON-serializable data structure """ self._send_headers(status_code=status_code) json_str = json.dumps(json_payload) self.wfile.write(json_str)
[ "def", "_reply_json", "(", "self", ",", "json_payload", ",", "status_code", "=", "200", ")", ":", "self", ".", "_send_headers", "(", "status_code", "=", "status_code", ")", "json_str", "=", "json", ".", "dumps", "(", "json_payload", ")", "self", ".", "wfil...
Return a JSON-serializable data structure
[ "Return", "a", "JSON", "-", "serializable", "data", "structure" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L137-L143
230,766
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._read_json
def _read_json(self, schema=None, maxlen=JSONRPC_MAX_SIZE): """ Read a JSON payload from the requester Return the parsed payload on success Return None on error """ # JSON post? request_type = self.headers.get('content-type', None) client_address_str = "{}...
python
def _read_json(self, schema=None, maxlen=JSONRPC_MAX_SIZE): """ Read a JSON payload from the requester Return the parsed payload on success Return None on error """ # JSON post? request_type = self.headers.get('content-type', None) client_address_str = "{}...
[ "def", "_read_json", "(", "self", ",", "schema", "=", "None", ",", "maxlen", "=", "JSONRPC_MAX_SIZE", ")", ":", "# JSON post?", "request_type", "=", "self", ".", "headers", ".", "get", "(", "'content-type'", ",", "None", ")", "client_address_str", "=", "\"{}...
Read a JSON payload from the requester Return the parsed payload on success Return None on error
[ "Read", "a", "JSON", "payload", "from", "the", "requester", "Return", "the", "parsed", "payload", "on", "success", "Return", "None", "on", "error" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L176-L217
230,767
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.parse_qs
def parse_qs(self, qs): """ Parse query string, but enforce one instance of each variable. Return a dict with the variables on success Return None on parse error """ qs_state = urllib2.urlparse.parse_qs(qs) ret = {} for qs_var, qs_value_list in qs_state.it...
python
def parse_qs(self, qs): """ Parse query string, but enforce one instance of each variable. Return a dict with the variables on success Return None on parse error """ qs_state = urllib2.urlparse.parse_qs(qs) ret = {} for qs_var, qs_value_list in qs_state.it...
[ "def", "parse_qs", "(", "self", ",", "qs", ")", ":", "qs_state", "=", "urllib2", ".", "urlparse", ".", "parse_qs", "(", "qs", ")", "ret", "=", "{", "}", "for", "qs_var", ",", "qs_value_list", "in", "qs_state", ".", "items", "(", ")", ":", "if", "le...
Parse query string, but enforce one instance of each variable. Return a dict with the variables on success Return None on parse error
[ "Parse", "query", "string", "but", "enforce", "one", "instance", "of", "each", "variable", ".", "Return", "a", "dict", "with", "the", "variables", "on", "success", "Return", "None", "on", "parse", "error" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L220-L234
230,768
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.get_path_and_qs
def get_path_and_qs(self): """ Parse and obtain the path and query values. We don't care about fragments. Return {'path': ..., 'qs_values': ...} on success Return {'error': ...} on error """ path_parts = self.path.split("?", 1) if len(path_parts) > 1: ...
python
def get_path_and_qs(self): """ Parse and obtain the path and query values. We don't care about fragments. Return {'path': ..., 'qs_values': ...} on success Return {'error': ...} on error """ path_parts = self.path.split("?", 1) if len(path_parts) > 1: ...
[ "def", "get_path_and_qs", "(", "self", ")", ":", "path_parts", "=", "self", ".", "path", ".", "split", "(", "\"?\"", ",", "1", ")", "if", "len", "(", "path_parts", ")", ">", "1", ":", "qs", "=", "path_parts", "[", "1", "]", ".", "split", "(", "\"...
Parse and obtain the path and query values. We don't care about fragments. Return {'path': ..., 'qs_values': ...} on success Return {'error': ...} on error
[ "Parse", "and", "obtain", "the", "path", "and", "query", "values", ".", "We", "don", "t", "care", "about", "fragments", "." ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L237-L261
230,769
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.OPTIONS_preflight
def OPTIONS_preflight( self, path_info ): """ Give back CORS preflight check headers """ self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') # CORS self.send_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE') self.send_hea...
python
def OPTIONS_preflight( self, path_info ): """ Give back CORS preflight check headers """ self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') # CORS self.send_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE') self.send_hea...
[ "def", "OPTIONS_preflight", "(", "self", ",", "path_info", ")", ":", "self", ".", "send_response", "(", "200", ")", "self", ".", "send_header", "(", "'Access-Control-Allow-Origin'", ",", "'*'", ")", "# CORS", "self", ".", "send_header", "(", "'Access-Control-All...
Give back CORS preflight check headers
[ "Give", "back", "CORS", "preflight", "check", "headers" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L290-L301
230,770
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_names_owned_by_address
def GET_names_owned_by_address( self, path_info, blockchain, address ): """ Get all names owned by an address Returns the list on success Return 404 on unsupported blockchain Return 502 on failure to get names for any non-specified reason """ if not check_address(...
python
def GET_names_owned_by_address( self, path_info, blockchain, address ): """ Get all names owned by an address Returns the list on success Return 404 on unsupported blockchain Return 502 on failure to get names for any non-specified reason """ if not check_address(...
[ "def", "GET_names_owned_by_address", "(", "self", ",", "path_info", ",", "blockchain", ",", "address", ")", ":", "if", "not", "check_address", "(", "address", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid address'", "}", ...
Get all names owned by an address Returns the list on success Return 404 on unsupported blockchain Return 502 on failure to get names for any non-specified reason
[ "Get", "all", "names", "owned", "by", "an", "address", "Returns", "the", "list", "on", "success", "Return", "404", "on", "unsupported", "blockchain", "Return", "502", "on", "failure", "to", "get", "names", "for", "any", "non", "-", "specified", "reason" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L304-L339
230,771
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_account_record
def GET_account_record(self, path_info, account_addr, token_type): """ Get the state of a particular token account Returns the account """ if not check_account_address(account_addr): return self._reply_json({'error': 'Invalid address'}, status_code=400) if no...
python
def GET_account_record(self, path_info, account_addr, token_type): """ Get the state of a particular token account Returns the account """ if not check_account_address(account_addr): return self._reply_json({'error': 'Invalid address'}, status_code=400) if no...
[ "def", "GET_account_record", "(", "self", ",", "path_info", ",", "account_addr", ",", "token_type", ")", ":", "if", "not", "check_account_address", "(", "account_addr", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid address'"...
Get the state of a particular token account Returns the account
[ "Get", "the", "state", "of", "a", "particular", "token", "account", "Returns", "the", "account" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L360-L378
230,772
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_names
def GET_names( self, path_info ): """ Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names """ include_expired = False qs_val...
python
def GET_names( self, path_info ): """ Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names """ include_expired = False qs_val...
[ "def", "GET_names", "(", "self", ",", "path_info", ")", ":", "include_expired", "=", "False", "qs_values", "=", "path_info", "[", "'qs_values'", "]", "page", "=", "qs_values", ".", "get", "(", "'page'", ",", "None", ")", "if", "page", "is", "None", ":", ...
Get all names in existence If `all=true` is set, then include expired names. Returns the list on success Returns 400 on invalid arguments Returns 502 on failure to get names
[ "Get", "all", "names", "in", "existence", "If", "all", "=", "true", "is", "set", "then", "include", "expired", "names", ".", "Returns", "the", "list", "on", "success", "Returns", "400", "on", "invalid", "arguments", "Returns", "502", "on", "failure", "to",...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L458-L496
230,773
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_name_history
def GET_name_history(self, path_info, name): """ Get the history of a name or subdomain. Requires 'page' in the query string return the history on success return 400 on invalid start_block or end_block return 502 on failure to query blockstack server """ i...
python
def GET_name_history(self, path_info, name): """ Get the history of a name or subdomain. Requires 'page' in the query string return the history on success return 400 on invalid start_block or end_block return 502 on failure to query blockstack server """ i...
[ "def", "GET_name_history", "(", "self", ",", "path_info", ",", "name", ")", ":", "if", "not", "check_name", "(", "name", ")", "and", "not", "check_subdomain", "(", "name", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invali...
Get the history of a name or subdomain. Requires 'page' in the query string return the history on success return 400 on invalid start_block or end_block return 502 on failure to query blockstack server
[ "Get", "the", "history", "of", "a", "name", "or", "subdomain", ".", "Requires", "page", "in", "the", "query", "string", "return", "the", "history", "on", "success", "return", "400", "on", "invalid", "start_block", "or", "end_block", "return", "502", "on", ...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L650-L683
230,774
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_name_zonefile_by_hash
def GET_name_zonefile_by_hash( self, path_info, name, zonefile_hash ): """ Get a historic zonefile for a name With `raw=1` on the query string, return the raw zone file Reply 200 with {'zonefile': zonefile} on success Reply 204 with {'error': ...} if the zone file is non-standar...
python
def GET_name_zonefile_by_hash( self, path_info, name, zonefile_hash ): """ Get a historic zonefile for a name With `raw=1` on the query string, return the raw zone file Reply 200 with {'zonefile': zonefile} on success Reply 204 with {'error': ...} if the zone file is non-standar...
[ "def", "GET_name_zonefile_by_hash", "(", "self", ",", "path_info", ",", "name", ",", "zonefile_hash", ")", ":", "if", "not", "check_name", "(", "name", ")", "and", "not", "check_subdomain", "(", "name", ")", ":", "return", "self", ".", "_reply_json", "(", ...
Get a historic zonefile for a name With `raw=1` on the query string, return the raw zone file Reply 200 with {'zonefile': zonefile} on success Reply 204 with {'error': ...} if the zone file is non-standard Reply 404 on not found Reply 502 on failure to fetch data
[ "Get", "a", "historic", "zonefile", "for", "a", "name", "With", "raw", "=", "1", "on", "the", "query", "string", "return", "the", "raw", "zone", "file" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L823-L879
230,775
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespaces
def GET_namespaces( self, path_info ): """ Get the list of all namespaces Reply all existing namespaces Reply 502 if we can't reach the server for whatever reason """ qs_values = path_info['qs_values'] offset = qs_values.get('offset', None) count = qs_valu...
python
def GET_namespaces( self, path_info ): """ Get the list of all namespaces Reply all existing namespaces Reply 502 if we can't reach the server for whatever reason """ qs_values = path_info['qs_values'] offset = qs_values.get('offset', None) count = qs_valu...
[ "def", "GET_namespaces", "(", "self", ",", "path_info", ")", ":", "qs_values", "=", "path_info", "[", "'qs_values'", "]", "offset", "=", "qs_values", ".", "get", "(", "'offset'", ",", "None", ")", "count", "=", "qs_values", ".", "get", "(", "'count'", ",...
Get the list of all namespaces Reply all existing namespaces Reply 502 if we can't reach the server for whatever reason
[ "Get", "the", "list", "of", "all", "namespaces", "Reply", "all", "existing", "namespaces", "Reply", "502", "if", "we", "can", "t", "reach", "the", "server", "for", "whatever", "reason" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L980-L998
230,776
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespace_info
def GET_namespace_info( self, path_info, namespace_id ): """ Look up a namespace's info Reply information about a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blocksatck server """ if not check_namespace(namespace_id...
python
def GET_namespace_info( self, path_info, namespace_id ): """ Look up a namespace's info Reply information about a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blocksatck server """ if not check_namespace(namespace_id...
[ "def", "GET_namespace_info", "(", "self", ",", "path_info", ",", "namespace_id", ")", ":", "if", "not", "check_namespace", "(", "namespace_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid namespace'", "}", ",", "status_c...
Look up a namespace's info Reply information about a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blocksatck server
[ "Look", "up", "a", "namespace", "s", "info", "Reply", "information", "about", "a", "namespace", "Reply", "404", "if", "the", "namespace", "doesn", "t", "exist", "Reply", "502", "for", "any", "error", "in", "talking", "to", "the", "blocksatck", "server" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1001-L1019
230,777
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespace_num_names
def GET_namespace_num_names(self, path_info, namespace_id): """ Get the number of names in a namespace Reply the number on success Reply 404 if the namespace does not exist Reply 502 on failure to talk to the blockstack server """ if not check_namespace(namespace_...
python
def GET_namespace_num_names(self, path_info, namespace_id): """ Get the number of names in a namespace Reply the number on success Reply 404 if the namespace does not exist Reply 502 on failure to talk to the blockstack server """ if not check_namespace(namespace_...
[ "def", "GET_namespace_num_names", "(", "self", ",", "path_info", ",", "namespace_id", ")", ":", "if", "not", "check_namespace", "(", "namespace_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid namespace'", "}", ",", "sta...
Get the number of names in a namespace Reply the number on success Reply 404 if the namespace does not exist Reply 502 on failure to talk to the blockstack server
[ "Get", "the", "number", "of", "names", "in", "a", "namespace", "Reply", "the", "number", "on", "success", "Reply", "404", "if", "the", "namespace", "does", "not", "exist", "Reply", "502", "on", "failure", "to", "talk", "to", "the", "blockstack", "server" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1022-L1038
230,778
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_namespace_names
def GET_namespace_names( self, path_info, namespace_id ): """ Get the list of names in a namespace Reply the list of names in a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blockstack server """ if not check_namespac...
python
def GET_namespace_names( self, path_info, namespace_id ): """ Get the list of names in a namespace Reply the list of names in a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blockstack server """ if not check_namespac...
[ "def", "GET_namespace_names", "(", "self", ",", "path_info", ",", "namespace_id", ")", ":", "if", "not", "check_namespace", "(", "namespace_id", ")", ":", "return", "self", ".", "_reply_json", "(", "{", "'error'", ":", "'Invalid namespace'", "}", ",", "status_...
Get the list of names in a namespace Reply the list of names in a namespace Reply 404 if the namespace doesn't exist Reply 502 for any error in talking to the blockstack server
[ "Get", "the", "list", "of", "names", "in", "a", "namespace", "Reply", "the", "list", "of", "names", "in", "a", "namespace", "Reply", "404", "if", "the", "namespace", "doesn", "t", "exist", "Reply", "502", "for", "any", "error", "in", "talking", "to", "...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1041-L1077
230,779
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_blockchain_ops
def GET_blockchain_ops( self, path_info, blockchain_name, blockheight ): """ Get the name's historic name operations Reply the list of nameops at the given block height Reply 404 for blockchains other than those supported Reply 502 for any error we have in talking to the blocksta...
python
def GET_blockchain_ops( self, path_info, blockchain_name, blockheight ): """ Get the name's historic name operations Reply the list of nameops at the given block height Reply 404 for blockchains other than those supported Reply 502 for any error we have in talking to the blocksta...
[ "def", "GET_blockchain_ops", "(", "self", ",", "path_info", ",", "blockchain_name", ",", "blockheight", ")", ":", "try", ":", "blockheight", "=", "int", "(", "blockheight", ")", "assert", "check_block", "(", "blockheight", ")", "except", ":", "return", "self",...
Get the name's historic name operations Reply the list of nameops at the given block height Reply 404 for blockchains other than those supported Reply 502 for any error we have in talking to the blockstack server
[ "Get", "the", "name", "s", "historic", "name", "operations", "Reply", "the", "list", "of", "nameops", "at", "the", "given", "block", "height", "Reply", "404", "for", "blockchains", "other", "than", "those", "supported", "Reply", "502", "for", "any", "error",...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1080-L1105
230,780
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler.GET_blockchain_name_record
def GET_blockchain_name_record( self, path_info, blockchain_name, name ): """ Get the name's blockchain record in full Reply the raw blockchain record on success Reply 404 if the name is not found Reply 502 if we have an error talking to the server """ if not chec...
python
def GET_blockchain_name_record( self, path_info, blockchain_name, name ): """ Get the name's blockchain record in full Reply the raw blockchain record on success Reply 404 if the name is not found Reply 502 if we have an error talking to the server """ if not chec...
[ "def", "GET_blockchain_name_record", "(", "self", ",", "path_info", ",", "blockchain_name", ",", "name", ")", ":", "if", "not", "check_name", "(", "name", ")", "and", "not", "check_subdomain", "(", "name", ")", ":", "return", "self", ".", "_reply_json", "(",...
Get the name's blockchain record in full Reply the raw blockchain record on success Reply 404 if the name is not found Reply 502 if we have an error talking to the server
[ "Get", "the", "name", "s", "blockchain", "record", "in", "full", "Reply", "the", "raw", "blockchain", "record", "on", "success", "Reply", "404", "if", "the", "name", "is", "not", "found", "Reply", "502", "if", "we", "have", "an", "error", "talking", "to"...
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1108-L1130
230,781
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpointHandler._get_balance
def _get_balance( self, get_address, min_confs ): """ Works only in test mode! Get the confirmed balance for an address """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] b...
python
def _get_balance( self, get_address, min_confs ): """ Works only in test mode! Get the confirmed balance for an address """ bitcoind_opts = get_bitcoin_opts() bitcoind_host = bitcoind_opts['bitcoind_server'] bitcoind_port = bitcoind_opts['bitcoind_port'] b...
[ "def", "_get_balance", "(", "self", ",", "get_address", ",", "min_confs", ")", ":", "bitcoind_opts", "=", "get_bitcoin_opts", "(", ")", "bitcoind_host", "=", "bitcoind_opts", "[", "'bitcoind_server'", "]", "bitcoind_port", "=", "bitcoind_opts", "[", "'bitcoind_port'...
Works only in test mode! Get the confirmed balance for an address
[ "Works", "only", "in", "test", "mode!", "Get", "the", "confirmed", "balance", "for", "an", "address" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1210-L1233
230,782
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpoint.bind
def bind(self): """ Bind to our port """ log.debug("Set SO_REUSADDR") self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) # we want daemon threads, so we join on abrupt shutdown (applies if multithreaded) self.daemon_threads = True ...
python
def bind(self): """ Bind to our port """ log.debug("Set SO_REUSADDR") self.socket.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 ) # we want daemon threads, so we join on abrupt shutdown (applies if multithreaded) self.daemon_threads = True ...
[ "def", "bind", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Set SO_REUSADDR\"", ")", "self", ".", "socket", ".", "setsockopt", "(", "socket", ".", "SOL_SOCKET", ",", "socket", ".", "SO_REUSEADDR", ",", "1", ")", "# we want daemon threads, so we join on ...
Bind to our port
[ "Bind", "to", "our", "port" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1624-L1635
230,783
blockstack/blockstack-core
blockstack/lib/rpc.py
BlockstackAPIEndpoint.overloaded
def overloaded(self, client_addr): """ Deflect if we have too many inbound requests """ overloaded_txt = 'HTTP/1.0 429 Too Many Requests\r\nServer: BaseHTTP/0.3 Python/2.7.14+\r\nContent-type: text/plain\r\nContent-length: 17\r\n\r\nToo many requests' if BLOCKSTACK_TEST: ...
python
def overloaded(self, client_addr): """ Deflect if we have too many inbound requests """ overloaded_txt = 'HTTP/1.0 429 Too Many Requests\r\nServer: BaseHTTP/0.3 Python/2.7.14+\r\nContent-type: text/plain\r\nContent-length: 17\r\n\r\nToo many requests' if BLOCKSTACK_TEST: ...
[ "def", "overloaded", "(", "self", ",", "client_addr", ")", ":", "overloaded_txt", "=", "'HTTP/1.0 429 Too Many Requests\\r\\nServer: BaseHTTP/0.3 Python/2.7.14+\\r\\nContent-type: text/plain\\r\\nContent-length: 17\\r\\n\\r\\nToo many requests'", "if", "BLOCKSTACK_TEST", ":", "log", "....
Deflect if we have too many inbound requests
[ "Deflect", "if", "we", "have", "too", "many", "inbound", "requests" ]
1dcfdd39b152d29ce13e736a6a1a0981401a0505
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/rpc.py#L1638-L1646
230,784
ansible/ansible-container
container/utils/_text.py
to_bytes
def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a byte string :arg obj: An object to make sure is a byte string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used...
python
def to_bytes(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a byte string :arg obj: An object to make sure is a byte string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used...
[ "def", "to_bytes", "(", "obj", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "None", ",", "nonstring", "=", "'simplerepr'", ")", ":", "if", "isinstance", "(", "obj", ",", "binary_type", ")", ":", "return", "obj", "# We're given a text string", "# If i...
Make sure that a string is a byte string :arg obj: An object to make sure is a byte string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used as a traceback-free version of ``str(obj)``. :kwarg encoding: The en...
[ "Make", "sure", "that", "a", "string", "is", "a", "byte", "string" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/_text.py#L52-L163
230,785
ansible/ansible-container
container/utils/_text.py
to_text
def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a text string :arg obj: An object to make sure is a text string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used ...
python
def to_text(obj, encoding='utf-8', errors=None, nonstring='simplerepr'): """Make sure that a string is a text string :arg obj: An object to make sure is a text string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used ...
[ "def", "to_text", "(", "obj", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "None", ",", "nonstring", "=", "'simplerepr'", ")", ":", "if", "isinstance", "(", "obj", ",", "text_type", ")", ":", "return", "obj", "if", "errors", "in", "_COMPOSED_ERRO...
Make sure that a string is a text string :arg obj: An object to make sure is a text string. In most cases this will be either a text string or a byte string. However, with ``nonstring='simplerepr'``, this can be used as a traceback-free version of ``str(obj)``. :kwarg encoding: The en...
[ "Make", "sure", "that", "a", "string", "is", "a", "text", "string" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/_text.py#L166-L254
230,786
ansible/ansible-container
container/core.py
push_images
def push_images(base_path, image_namespace, engine_obj, config, **kwargs): """ Pushes images to a Docker registry. Returns dict containing attributes used to push images. """ config_path = kwargs.get('config_path', engine_obj.auth_config_path) username = kwargs.get('username') password = kwargs.get('pas...
python
def push_images(base_path, image_namespace, engine_obj, config, **kwargs): """ Pushes images to a Docker registry. Returns dict containing attributes used to push images. """ config_path = kwargs.get('config_path', engine_obj.auth_config_path) username = kwargs.get('username') password = kwargs.get('pas...
[ "def", "push_images", "(", "base_path", ",", "image_namespace", ",", "engine_obj", ",", "config", ",", "*", "*", "kwargs", ")", ":", "config_path", "=", "kwargs", ".", "get", "(", "'config_path'", ",", "engine_obj", ".", "auth_config_path", ")", "username", ...
Pushes images to a Docker registry. Returns dict containing attributes used to push images.
[ "Pushes", "images", "to", "a", "Docker", "registry", ".", "Returns", "dict", "containing", "attributes", "used", "to", "push", "images", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L394-L467
230,787
ansible/ansible-container
container/core.py
remove_existing_container
def remove_existing_container(engine_obj, service_name, remove_volumes=False): """ Remove a container for an existing service. Handy for removing an existing conductor. """ conductor_container_id = engine_obj.get_container_id_for_service(service_name) if engine_obj.service_is_running(service_name): ...
python
def remove_existing_container(engine_obj, service_name, remove_volumes=False): """ Remove a container for an existing service. Handy for removing an existing conductor. """ conductor_container_id = engine_obj.get_container_id_for_service(service_name) if engine_obj.service_is_running(service_name): ...
[ "def", "remove_existing_container", "(", "engine_obj", ",", "service_name", ",", "remove_volumes", "=", "False", ")", ":", "conductor_container_id", "=", "engine_obj", ".", "get_container_id_for_service", "(", "service_name", ")", "if", "engine_obj", ".", "service_is_ru...
Remove a container for an existing service. Handy for removing an existing conductor.
[ "Remove", "a", "container", "for", "an", "existing", "service", ".", "Handy", "for", "removing", "an", "existing", "conductor", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L510-L518
230,788
ansible/ansible-container
container/core.py
resolve_push_to
def resolve_push_to(push_to, default_url, default_namespace): ''' Given a push-to value, return the registry and namespace. :param push_to: string: User supplied --push-to value. :param default_url: string: Container engine's default_index value (e.g. docker.io). :return: tuple: registry_url, names...
python
def resolve_push_to(push_to, default_url, default_namespace): ''' Given a push-to value, return the registry and namespace. :param push_to: string: User supplied --push-to value. :param default_url: string: Container engine's default_index value (e.g. docker.io). :return: tuple: registry_url, names...
[ "def", "resolve_push_to", "(", "push_to", ",", "default_url", ",", "default_namespace", ")", ":", "protocol", "=", "'http://'", "if", "push_to", ".", "startswith", "(", "'http://'", ")", "else", "'https://'", "url", "=", "push_to", "=", "REMOVE_HTTP", ".", "su...
Given a push-to value, return the registry and namespace. :param push_to: string: User supplied --push-to value. :param default_url: string: Container engine's default_index value (e.g. docker.io). :return: tuple: registry_url, namespace
[ "Given", "a", "push", "-", "to", "value", "return", "the", "registry", "and", "namespace", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L522-L546
230,789
ansible/ansible-container
container/core.py
conductorcmd_push
def conductorcmd_push(engine_name, project_name, services, **kwargs): """ Push images to a registry """ username = kwargs.pop('username') password = kwargs.pop('password') email = kwargs.pop('email') url = kwargs.pop('url') namespace = kwargs.pop('namespace') tag = kwargs.pop('tag') conf...
python
def conductorcmd_push(engine_name, project_name, services, **kwargs): """ Push images to a registry """ username = kwargs.pop('username') password = kwargs.pop('password') email = kwargs.pop('email') url = kwargs.pop('url') namespace = kwargs.pop('namespace') tag = kwargs.pop('tag') conf...
[ "def", "conductorcmd_push", "(", "engine_name", ",", "project_name", ",", "services", ",", "*", "*", "kwargs", ")", ":", "username", "=", "kwargs", ".", "pop", "(", "'username'", ")", "password", "=", "kwargs", ".", "pop", "(", "'password'", ")", "email", ...
Push images to a registry
[ "Push", "images", "to", "a", "registry" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/core.py#L1038-L1069
230,790
ansible/ansible-container
container/openshift/deploy.py
Deploy.get_route_templates
def get_route_templates(self): """ Generate Openshift route templates or playbook tasks. Each port on a service definition found in container.yml represents an externally exposed port. """ def _get_published_ports(service_config): result = [] for port in s...
python
def get_route_templates(self): """ Generate Openshift route templates or playbook tasks. Each port on a service definition found in container.yml represents an externally exposed port. """ def _get_published_ports(service_config): result = [] for port in s...
[ "def", "get_route_templates", "(", "self", ")", ":", "def", "_get_published_ports", "(", "service_config", ")", ":", "result", "=", "[", "]", "for", "port", "in", "service_config", ".", "get", "(", "'ports'", ",", "[", "]", ")", ":", "protocol", "=", "'T...
Generate Openshift route templates or playbook tasks. Each port on a service definition found in container.yml represents an externally exposed port.
[ "Generate", "Openshift", "route", "templates", "or", "playbook", "tasks", ".", "Each", "port", "on", "a", "service", "definition", "found", "in", "container", ".", "yml", "represents", "an", "externally", "exposed", "port", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/openshift/deploy.py#L56-L117
230,791
ansible/ansible-container
container/docker/importer.py
DockerfileParser.preparse_iter
def preparse_iter(self): """ Comments can be anywhere. So break apart the Dockerfile into significant lines and any comments that precede them. And if a line is a carryover from the previous via an escaped-newline, bring the directive with it. """ to_yield = {} la...
python
def preparse_iter(self): """ Comments can be anywhere. So break apart the Dockerfile into significant lines and any comments that precede them. And if a line is a carryover from the previous via an escaped-newline, bring the directive with it. """ to_yield = {} la...
[ "def", "preparse_iter", "(", "self", ")", ":", "to_yield", "=", "{", "}", "last_directive", "=", "None", "lines_processed", "=", "0", "for", "line", "in", "self", ".", "lines_iter", "(", ")", ":", "if", "not", "line", ":", "continue", "if", "line", "."...
Comments can be anywhere. So break apart the Dockerfile into significant lines and any comments that precede them. And if a line is a carryover from the previous via an escaped-newline, bring the directive with it.
[ "Comments", "can", "be", "anywhere", ".", "So", "break", "apart", "the", "Dockerfile", "into", "significant", "lines", "and", "any", "comments", "that", "precede", "them", ".", "And", "if", "a", "line", "is", "a", "carryover", "from", "the", "previous", "v...
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/importer.py#L120-L155
230,792
ansible/ansible-container
container/docker/engine.py
Engine.run_container
def run_container(self, image_id, service_name, **kwargs): """Run a particular container. The kwargs argument contains individual parameter overrides from the service definition.""" run_kwargs = self.run_kwargs_for_service(service_name) run_kwargs.update(kwargs, relax=True) logge...
python
def run_container(self, image_id, service_name, **kwargs): """Run a particular container. The kwargs argument contains individual parameter overrides from the service definition.""" run_kwargs = self.run_kwargs_for_service(service_name) run_kwargs.update(kwargs, relax=True) logge...
[ "def", "run_container", "(", "self", ",", "image_id", ",", "service_name", ",", "*", "*", "kwargs", ")", ":", "run_kwargs", "=", "self", ".", "run_kwargs_for_service", "(", "service_name", ")", "run_kwargs", ".", "update", "(", "kwargs", ",", "relax", "=", ...
Run a particular container. The kwargs argument contains individual parameter overrides from the service definition.
[ "Run", "a", "particular", "container", ".", "The", "kwargs", "argument", "contains", "individual", "parameter", "overrides", "from", "the", "service", "definition", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L265-L281
230,793
ansible/ansible-container
container/docker/engine.py
Engine.push
def push(self, image_id, service_name, tag=None, namespace=None, url=None, username=None, password=None, repository_prefix=None, **kwargs): """ Push an image to a remote registry. """ auth_config = { 'username': username, 'password': password ...
python
def push(self, image_id, service_name, tag=None, namespace=None, url=None, username=None, password=None, repository_prefix=None, **kwargs): """ Push an image to a remote registry. """ auth_config = { 'username': username, 'password': password ...
[ "def", "push", "(", "self", ",", "image_id", ",", "service_name", ",", "tag", "=", "None", ",", "namespace", "=", "None", ",", "url", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "repository_prefix", "=", "None", ",", ...
Push an image to a remote registry.
[ "Push", "an", "image", "to", "a", "remote", "registry", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L895-L941
230,794
ansible/ansible-container
container/docker/engine.py
Engine.login
def login(self, username, password, email, url, config_path): """ If username and password are provided, authenticate with the registry. Otherwise, check the config file for existing authentication data. """ if username and password: try: self.client.l...
python
def login(self, username, password, email, url, config_path): """ If username and password are provided, authenticate with the registry. Otherwise, check the config file for existing authentication data. """ if username and password: try: self.client.l...
[ "def", "login", "(", "self", ",", "username", ",", "password", ",", "email", ",", "url", ",", "config_path", ")", ":", "if", "username", "and", "password", ":", "try", ":", "self", ".", "client", ".", "login", "(", "username", "=", "username", ",", "...
If username and password are provided, authenticate with the registry. Otherwise, check the config file for existing authentication data.
[ "If", "username", "and", "password", "are", "provided", "authenticate", "with", "the", "registry", ".", "Otherwise", "check", "the", "config", "file", "for", "existing", "authentication", "data", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L1186-L1208
230,795
ansible/ansible-container
container/docker/engine.py
Engine._update_config_file
def _update_config_file(username, password, email, url, config_path): """Update the config file with the authorization.""" try: # read the existing config config = json.load(open(config_path, "r")) except ValueError: config = dict() if not config.get(...
python
def _update_config_file(username, password, email, url, config_path): """Update the config file with the authorization.""" try: # read the existing config config = json.load(open(config_path, "r")) except ValueError: config = dict() if not config.get(...
[ "def", "_update_config_file", "(", "username", ",", "password", ",", "email", ",", "url", ",", "config_path", ")", ":", "try", ":", "# read the existing config", "config", "=", "json", ".", "load", "(", "open", "(", "config_path", ",", "\"r\"", ")", ")", "...
Update the config file with the authorization.
[ "Update", "the", "config", "file", "with", "the", "authorization", "." ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L1212-L1235
230,796
ansible/ansible-container
container/docker/engine.py
Engine._get_registry_auth
def _get_registry_auth(registry_url, config_path): """ Retrieve from the config file the current authentication for a given URL, and return the username, password """ username = None password = None try: docker_config = json.load(open(config_path)) ...
python
def _get_registry_auth(registry_url, config_path): """ Retrieve from the config file the current authentication for a given URL, and return the username, password """ username = None password = None try: docker_config = json.load(open(config_path)) ...
[ "def", "_get_registry_auth", "(", "registry_url", ",", "config_path", ")", ":", "username", "=", "None", "password", "=", "None", "try", ":", "docker_config", "=", "json", ".", "load", "(", "open", "(", "config_path", ")", ")", "except", "ValueError", ":", ...
Retrieve from the config file the current authentication for a given URL, and return the username, password
[ "Retrieve", "from", "the", "config", "file", "the", "current", "authentication", "for", "a", "given", "URL", "and", "return", "the", "username", "password" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/docker/engine.py#L1239-L1256
230,797
ansible/ansible-container
container/utils/__init__.py
resolve_role_to_path
def resolve_role_to_path(role): """ Given a role definition from a service's list of roles, returns the file path to the role """ loader = DataLoader() try: variable_manager = VariableManager(loader=loader) except TypeError: # If Ansible prior to ansible/ansible@8f97aef1a365 ...
python
def resolve_role_to_path(role): """ Given a role definition from a service's list of roles, returns the file path to the role """ loader = DataLoader() try: variable_manager = VariableManager(loader=loader) except TypeError: # If Ansible prior to ansible/ansible@8f97aef1a365 ...
[ "def", "resolve_role_to_path", "(", "role", ")", ":", "loader", "=", "DataLoader", "(", ")", "try", ":", "variable_manager", "=", "VariableManager", "(", "loader", "=", "loader", ")", "except", "TypeError", ":", "# If Ansible prior to ansible/ansible@8f97aef1a365", ...
Given a role definition from a service's list of roles, returns the file path to the role
[ "Given", "a", "role", "definition", "from", "a", "service", "s", "list", "of", "roles", "returns", "the", "file", "path", "to", "the", "role" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/__init__.py#L225-L238
230,798
ansible/ansible-container
container/utils/__init__.py
get_role_fingerprint
def get_role_fingerprint(role, service_name, config_vars): """ Given a role definition from a service's list of roles, returns a hexdigest based on the role definition, the role contents, and the hexdigest of each dependency """ def hash_file(hash_obj, file_path): blocksize = 64 * 1024 ...
python
def get_role_fingerprint(role, service_name, config_vars): """ Given a role definition from a service's list of roles, returns a hexdigest based on the role definition, the role contents, and the hexdigest of each dependency """ def hash_file(hash_obj, file_path): blocksize = 64 * 1024 ...
[ "def", "get_role_fingerprint", "(", "role", ",", "service_name", ",", "config_vars", ")", ":", "def", "hash_file", "(", "hash_obj", ",", "file_path", ")", ":", "blocksize", "=", "64", "*", "1024", "with", "open", "(", "file_path", ",", "'rb'", ")", "as", ...
Given a role definition from a service's list of roles, returns a hexdigest based on the role definition, the role contents, and the hexdigest of each dependency
[ "Given", "a", "role", "definition", "from", "a", "service", "s", "list", "of", "roles", "returns", "a", "hexdigest", "based", "on", "the", "role", "definition", "the", "role", "contents", "and", "the", "hexdigest", "of", "each", "dependency" ]
d031c1a6133d5482a5d054fcbdbecafb923f8b4b
https://github.com/ansible/ansible-container/blob/d031c1a6133d5482a5d054fcbdbecafb923f8b4b/container/utils/__init__.py#L256-L323
230,799
litl/backoff
backoff/_decorator.py
on_predicate
def on_predicate(wait_gen, predicate=operator.not_, max_tries=None, max_time=None, jitter=full_jitter, on_success=None, on_backoff=None, on_giveup=None, logger='backoff', ...
python
def on_predicate(wait_gen, predicate=operator.not_, max_tries=None, max_time=None, jitter=full_jitter, on_success=None, on_backoff=None, on_giveup=None, logger='backoff', ...
[ "def", "on_predicate", "(", "wait_gen", ",", "predicate", "=", "operator", ".", "not_", ",", "max_tries", "=", "None", ",", "max_time", "=", "None", ",", "jitter", "=", "full_jitter", ",", "on_success", "=", "None", ",", "on_backoff", "=", "None", ",", "...
Returns decorator for backoff and retry triggered by predicate. Args: wait_gen: A generator yielding successive wait times in seconds. predicate: A function which when called on the return value of the target function will trigger backoff when considered truthily...
[ "Returns", "decorator", "for", "backoff", "and", "retry", "triggered", "by", "predicate", "." ]
229d30adce4128f093550a1761c49594c78df4b4
https://github.com/litl/backoff/blob/229d30adce4128f093550a1761c49594c78df4b4/backoff/_decorator.py#L20-L106