_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q226000 | get_subdomain_history | train | def get_subdomain_history(fqn, offset=None, count=None, reverse=False, db_path=None, zonefiles_dir=None, json=False):
"""
Static method for getting all historic operations on a subdomain
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
... | python | {
"resource": ""
} |
q226001 | get_all_subdomains | train | def get_all_subdomains(offset=None, count=None, min_sequence=None, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of all subdomains
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdo... | python | {
"resource": ""
} |
q226002 | get_subdomain_ops_at_txid | train | def get_subdomain_ops_at_txid(txid, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of subdomain operations accepted at a given txid.
Includes unaccepted subdomain operations
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if ... | python | {
"resource": ""
} |
q226003 | get_subdomains_owned_by_address | train | def get_subdomains_owned_by_address(address, db_path=None, zonefiles_dir=None):
"""
Static method for getting the list of subdomains for a given address
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdomaindb... | python | {
"resource": ""
} |
q226004 | get_subdomain_last_sequence | train | def get_subdomain_last_sequence(db_path=None, zonefiles_dir=None):
"""
Static method for getting the last sequence number in the database
"""
opts = get_blockstack_opts()
if not is_subdomains_enabled(opts):
return []
if db_path is None:
db_path = opts['subdomaindb_path']
if... | python | {
"resource": ""
} |
q226005 | sign | train | def sign(privkey_bundle, plaintext):
"""
Sign a subdomain plaintext with a private key bundle
Returns the base64-encoded scriptsig
"""
if virtualchain.is_singlesig(privkey_bundle):
return sign_singlesig(privkey_bundle, plaintext)
elif virtualchain.is_multisig(privkey_bundle):
ret... | python | {
"resource": ""
} |
q226006 | subdomains_init | train | def subdomains_init(blockstack_opts, working_dir, atlas_state):
"""
Set up subdomain state
Returns a SubdomainIndex object that has been successfully connected to Atlas
"""
if not is_subdomains_enabled(blockstack_opts):
return None
subdomain_state = SubdomainIndex(blockstack_opts['subdo... | python | {
"resource": ""
} |
q226007 | Subdomain.verify_signature | train | def verify_signature(self, addr):
"""
Given an address, verify whether or not it was signed by it
"""
return verify(virtualchain.address_reencode(addr), self.get_plaintext_to_sign(), self.sig) | python | {
"resource": ""
} |
q226008 | Subdomain.serialize_to_txt | train | def serialize_to_txt(self):
"""
Serialize this subdomain record to a TXT record. The trailing newline will be omitted
"""
txtrec = {
'name': self.fqn if self.independent else self.subdomain,
'txt': self.pack_subdomain()[1:]
}
return blockstack_zon... | python | {
"resource": ""
} |
q226009 | Subdomain.parse_subdomain_missing_zonefiles_record | train | def parse_subdomain_missing_zonefiles_record(cls, rec):
"""
Parse a missing-zonefiles vector given by the domain.
Returns the list of zone file indexes on success
Raises ParseError on unparseable records
"""
txt_entry = rec['txt']
if isinstance(txt_entry, list):
... | python | {
"resource": ""
} |
q226010 | Subdomain.get_public_key | train | def get_public_key(self):
"""
Parse the scriptSig and extract the public key.
Raises ValueError if this is a multisig-controlled subdomain.
"""
res = self.get_public_key_info()
if 'error' in res:
raise ValueError(res['error'])
if res['type'] != 'singl... | python | {
"resource": ""
} |
q226011 | SubdomainIndex.close | train | def close(self):
"""
Close the index
"""
with self.subdomain_db_lock:
self.subdomain_db.close()
self.subdomain_db = None
self.subdomain_db_path = None | python | {
"resource": ""
} |
q226012 | SubdomainIndex.make_new_subdomain_history | train | def make_new_subdomain_history(self, cursor, subdomain_rec):
"""
Recalculate the history for this subdomain from genesis up until this record.
Returns the list of subdomain records we need to save.
"""
# what's the subdomain's history up until this subdomain record?
hist ... | python | {
"resource": ""
} |
q226013 | SubdomainIndex.make_new_subdomain_future | train | def make_new_subdomain_future(self, cursor, subdomain_rec):
"""
Recalculate the future for this subdomain from the current record
until the latest known record.
Returns the list of subdomain records we need to save.
"""
assert subdomain_rec.accepted, 'BUG: given subdomain... | python | {
"resource": ""
} |
q226014 | SubdomainIndex.subdomain_try_insert | train | def subdomain_try_insert(self, cursor, subdomain_rec, history_neighbors):
"""
Try to insert a subdomain record into its history neighbors.
This is an optimization that handles the "usual" case.
We can do this without having to rewrite this subdomain's past and future
if (1) we c... | python | {
"resource": ""
} |
q226015 | SubdomainIndex.enqueue_zonefile | train | def enqueue_zonefile(self, zonefile_hash, block_height):
"""
Called when we discover a zone file. Queues up a request to reprocess this name's zone files' subdomains.
zonefile_hash is the hash of the zonefile.
block_height is the minimium block height at which this zone file occurs.
... | python | {
"resource": ""
} |
q226016 | SubdomainIndex.index_blockchain | train | def index_blockchain(self, block_start, block_end):
"""
Go through the sequence of zone files discovered in a block range, and reindex the names' subdomains.
"""
log.debug("Processing subdomain updates for zonefiles in blocks {}-{}".format(block_start, block_end))
res = ... | python | {
"resource": ""
} |
q226017 | SubdomainIndex.index_discovered_zonefiles | train | def index_discovered_zonefiles(self, lastblock):
"""
Go through the list of zone files we discovered via Atlas, grouped by name and ordered by block height.
Find all subsequent zone files for this name, and process all subdomain operations contained within them.
"""
all_queued_zf... | python | {
"resource": ""
} |
q226018 | SubdomainDB.subdomain_row_factory | train | def subdomain_row_factory(cls, cursor, row):
"""
Dict row factory for subdomains
"""
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d | python | {
"resource": ""
} |
q226019 | SubdomainDB._extract_subdomain | train | def _extract_subdomain(self, rowdata):
"""
Extract a single subdomain from a DB cursor
Raise SubdomainNotFound if there are no valid rows
"""
name = str(rowdata['fully_qualified_subdomain'])
domain = str(rowdata['domain'])
n = str(rowdata['sequence'])
enco... | python | {
"resource": ""
} |
q226020 | SubdomainDB.get_subdomains_count | train | def get_subdomains_count(self, accepted=True, cur=None):
"""
Fetch subdomain names
"""
if accepted:
accepted_filter = 'WHERE accepted=1'
else:
accepted_filter = ''
get_cmd = "SELECT COUNT(DISTINCT fully_qualified_subdomain) as count FROM {} {};".f... | python | {
"resource": ""
} |
q226021 | SubdomainDB.get_all_subdomains | train | def get_all_subdomains(self, offset=None, count=None, min_sequence=None, cur=None):
"""
Get and all subdomain names, optionally over a range
"""
get_cmd = 'SELECT DISTINCT fully_qualified_subdomain FROM {}'.format(self.subdomain_table)
args = ()
if min_sequence is not No... | python | {
"resource": ""
} |
q226022 | SubdomainDB.get_subdomain_ops_at_txid | train | def get_subdomain_ops_at_txid(self, txid, cur=None):
"""
Given a txid, get all subdomain operations at that txid.
Include unaccepted operations.
Order by zone file index
"""
get_cmd = 'SELECT * FROM {} WHERE txid = ? ORDER BY zonefile_offset'.format(self.subdomain_table)
... | python | {
"resource": ""
} |
q226023 | SubdomainDB.get_subdomains_owned_by_address | train | def get_subdomains_owned_by_address(self, owner, cur=None):
"""
Get the list of subdomain names that are owned by a given address.
"""
get_cmd = "SELECT fully_qualified_subdomain, MAX(sequence) FROM {} WHERE owner = ? AND accepted=1 GROUP BY fully_qualified_subdomain".format(self.subdoma... | python | {
"resource": ""
} |
q226024 | SubdomainDB.get_domain_resolver | train | def get_domain_resolver(self, domain_name, cur=None):
"""
Get the last-knwon resolver entry for a domain name
Returns None if not found.
"""
get_cmd = "SELECT resolver FROM {} WHERE domain=? AND resolver != '' AND accepted=1 ORDER BY sequence DESC, parent_zonefile_index DESC LIMI... | python | {
"resource": ""
} |
q226025 | SubdomainDB.get_subdomain_DID_info | train | def get_subdomain_DID_info(self, fqn, cur=None):
"""
Get the DID information for a subdomain.
Raise SubdomainNotFound if there is no such subdomain
Return {'name_type': ..., 'address': ..., 'index': ...}
"""
subrec = self.get_subdomain_entry_at_sequence(fqn, 0, cur=cur)
... | python | {
"resource": ""
} |
q226026 | SubdomainDB.get_DID_subdomain | train | def get_DID_subdomain(self, did, cur=None):
"""
Get a subdomain, given its DID
Raise ValueError if the DID is invalid
Raise SubdomainNotFound if the DID does not correspond to a subdomain
"""
did = str(did)
try:
did_info = parse_DID(did)
a... | python | {
"resource": ""
} |
q226027 | SubdomainDB.is_subdomain_zonefile_hash | train | def is_subdomain_zonefile_hash(self, fqn, zonefile_hash, cur=None):
"""
Does this zone file hash belong to this subdomain?
"""
sql = 'SELECT COUNT(zonefile_hash) FROM {} WHERE fully_qualified_subdomain = ? and zonefile_hash = ?;'.format(self.subdomain_table)
args = (fqn,zonefile_... | python | {
"resource": ""
} |
q226028 | SubdomainDB.update_subdomain_entry | train | def update_subdomain_entry(self, subdomain_obj, cur=None):
"""
Update the subdomain history table for this subdomain entry.
Creates it if it doesn't exist.
Return True on success
Raise exception on error
"""
# sanity checks
assert isinstance(subdomain_obj... | python | {
"resource": ""
} |
q226029 | SubdomainDB.get_last_block | train | def get_last_block(self, cur=None):
"""
Get the highest block last processed
"""
sql = 'SELECT MAX(block_height) FROM {};'.format(self.subdomain_table)
cursor = None
if cur is None:
cursor = self.conn.cursor()
else:
cursor = cur
ro... | python | {
"resource": ""
} |
q226030 | SubdomainDB.get_last_sequence | train | def get_last_sequence(self, cur=None):
"""
Get the highest sequence number in this db
"""
sql = 'SELECT sequence FROM {} ORDER BY sequence DESC LIMIT 1;'.format(self.subdomain_table)
cursor = None
if cur is None:
cursor = self.conn.cursor()
else:
... | python | {
"resource": ""
} |
q226031 | SubdomainDB._drop_tables | train | def _drop_tables(self):
"""
Clear the subdomain db's tables
"""
drop_cmd = "DROP TABLE IF EXISTS {};"
for table in [self.subdomain_table, self.blocked_table]:
cursor = self.conn.cursor()
db_query_execute(cursor, drop_cmd.format(table), ()) | python | {
"resource": ""
} |
q226032 | hash_name | train | def hash_name(name, script_pubkey, register_addr=None):
"""
Generate the hash over a name and hex-string script pubkey
"""
bin_name = b40_to_bin(name)
name_and_pubkey = bin_name + unhexlify(script_pubkey)
if register_addr is not None:
name_and_pubkey += str(register_addr)
return hex_has... | python | {
"resource": ""
} |
q226033 | fetch_profile_data_from_file | train | def fetch_profile_data_from_file():
""" takes profile data from file and saves in the profile_data DB
"""
with open(SEARCH_PROFILE_DATA_FILE, 'r') as fin:
profiles = json.load(fin)
counter = 0
log.debug("-" * 5)
log.debug("Fetching profile data from file")
for entry in profiles:
... | python | {
"resource": ""
} |
q226034 | create_search_index | train | def create_search_index():
""" takes people names from blockchain and writes deduped names in a 'cache'
"""
# create people name cache
counter = 0
people_names = []
twitter_handles = []
usernames = []
log.debug("-" * 5)
log.debug("Creating search index")
for user in namespace... | python | {
"resource": ""
} |
q226035 | op_extract | train | def op_extract(op_name, data, senders, inputs, outputs, block_id, vtxindex, txid):
"""
Extract an operation from transaction data.
Return the extracted fields as a dict.
"""
global EXTRACT_METHODS
if op_name not in EXTRACT_METHODS.keys():
raise Exception("No such operation '%s'" % op_na... | python | {
"resource": ""
} |
q226036 | op_canonicalize | train | def op_canonicalize(op_name, parsed_op):
"""
Get the canonical representation of a parsed operation's data.
Meant for backwards-compatibility
"""
global CANONICALIZE_METHODS
if op_name not in CANONICALIZE_METHODS:
# no canonicalization needed
return parsed_op
else:
r... | python | {
"resource": ""
} |
q226037 | op_decanonicalize | train | def op_decanonicalize(op_name, canonical_op):
"""
Get the current representation of a parsed operation's data, given the canonical representation
Meant for backwards-compatibility
"""
global DECANONICALIZE_METHODS
if op_name not in DECANONICALIZE_METHODS:
# no decanonicalization needed
... | python | {
"resource": ""
} |
q226038 | op_check | train | def op_check( state_engine, nameop, block_id, checked_ops ):
"""
Given the state engine, the current block, the list of pending
operations processed so far, and the current operation, determine
whether or not it should be accepted.
The operation is allowed to be "type-cast" to a new operation, but ... | python | {
"resource": ""
} |
q226039 | op_get_mutate_fields | train | def op_get_mutate_fields( op_name ):
"""
Get the names of the fields that will change
when this operation gets applied to a record.
"""
global MUTATE_FIELDS
if op_name not in MUTATE_FIELDS.keys():
raise Exception("No such operation '%s'" % op_name)
fields = MUTATE_FIELDS[op_name][:... | python | {
"resource": ""
} |
q226040 | op_get_consensus_fields | train | 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 | {
"resource": ""
} |
q226041 | check | train | 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 | {
"resource": ""
} |
q226042 | genesis_block_audit | train | 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 | {
"resource": ""
} |
q226043 | is_profile_in_legacy_format | train | 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 | {
"resource": ""
} |
q226044 | format_profile | train | 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 | {
"resource": ""
} |
q226045 | get_users | train | 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 | {
"resource": ""
} |
q226046 | is_earlier_than | train | 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 | {
"resource": ""
} |
q226047 | namespacereveal_sanity_check | train | 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 | {
"resource": ""
} |
q226048 | check | train | 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 | {
"resource": ""
} |
q226049 | namedb_create | train | 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 | {
"resource": ""
} |
q226050 | namedb_open | train | 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 | {
"resource": ""
} |
q226051 | namedb_insert_prepare | train | 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 | {
"resource": ""
} |
q226052 | namedb_update_must_equal | train | 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 | {
"resource": ""
} |
q226053 | namedb_delete_prepare | train | 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 | {
"resource": ""
} |
q226054 | namedb_query_execute | train | 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 | {
"resource": ""
} |
q226055 | namedb_preorder_insert | train | 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 | {
"resource": ""
} |
q226056 | namedb_preorder_remove | train | 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 | {
"resource": ""
} |
q226057 | namedb_name_insert | train | 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 | {
"resource": ""
} |
q226058 | namedb_name_update | train | 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 | {
"resource": ""
} |
q226059 | namedb_state_mutation_sanity_check | train | 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 | {
"resource": ""
} |
q226060 | namedb_get_last_name_import | train | 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 | {
"resource": ""
} |
q226061 | namedb_account_transaction_save | train | 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 | {
"resource": ""
} |
q226062 | namedb_account_debit | train | 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 | {
"resource": ""
} |
q226063 | namedb_accounts_vest | train | 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 | {
"resource": ""
} |
q226064 | namedb_is_history_snapshot | train | 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 | {
"resource": ""
} |
q226065 | namedb_get_account_tokens | train | 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 | {
"resource": ""
} |
q226066 | namedb_get_account | train | 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 | {
"resource": ""
} |
q226067 | namedb_get_account_diff | train | 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 | {
"resource": ""
} |
q226068 | namedb_get_account_history | train | 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 | {
"resource": ""
} |
q226069 | namedb_get_all_account_addresses | train | 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 | {
"resource": ""
} |
q226070 | namedb_get_name_at | train | 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 | {
"resource": ""
} |
q226071 | namedb_get_namespace_at | train | 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 | {
"resource": ""
} |
q226072 | namedb_get_account_balance | train | 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 | {
"resource": ""
} |
q226073 | namedb_get_preorder | train | 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 | {
"resource": ""
} |
q226074 | namedb_get_num_historic_names_by_address | train | 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 | {
"resource": ""
} |
q226075 | namedb_get_num_names | train | 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 | {
"resource": ""
} |
q226076 | namedb_get_all_names | train | 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 | {
"resource": ""
} |
q226077 | namedb_get_num_names_in_namespace | train | 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 | {
"resource": ""
} |
q226078 | namedb_get_names_in_namespace | train | 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 | {
"resource": ""
} |
q226079 | namedb_get_all_namespace_ids | train | 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 | {
"resource": ""
} |
q226080 | namedb_get_all_preordered_namespace_hashes | train | 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 | {
"resource": ""
} |
q226081 | namedb_get_all_revealed_namespace_ids | train | 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 | {
"resource": ""
} |
q226082 | namedb_get_all_importing_namespace_hashes | train | 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 | {
"resource": ""
} |
q226083 | namedb_get_names_by_sender | train | 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 | {
"resource": ""
} |
q226084 | namedb_get_namespace_preorder | train | 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 | {
"resource": ""
} |
q226085 | namedb_get_namespace_ready | train | 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 | {
"resource": ""
} |
q226086 | namedb_get_name_from_name_hash128 | train | 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 | {
"resource": ""
} |
q226087 | namedb_get_names_with_value_hash | train | 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 | {
"resource": ""
} |
q226088 | namedb_get_value_hash_txids | train | 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 | {
"resource": ""
} |
q226089 | namedb_get_num_block_vtxs | train | 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 | {
"resource": ""
} |
q226090 | namedb_is_name_zonefile_hash | train | 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 | {
"resource": ""
} |
q226091 | process_announcement | train | 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 | {
"resource": ""
} |
q226092 | check | train | 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 | {
"resource": ""
} |
q226093 | get_bitcoind_client | train | 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 | {
"resource": ""
} |
q226094 | txid_to_block_data | train | 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 | {
"resource": ""
} |
q226095 | get_consensus_hash_from_tx | train | 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 | {
"resource": ""
} |
q226096 | json_is_exception | train | 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 | {
"resource": ""
} |
q226097 | put_zonefiles | train | 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 | {
"resource": ""
} |
q226098 | get_zonefiles_by_block | train | 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 | {
"resource": ""
} |
q226099 | get_account_tokens | train | 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 | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.