mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-01 05:02:09 +08:00
port fix from master re: storing queued profiles
This commit is contained in:
@@ -1856,6 +1856,8 @@ class BlockstackStoragePusher( threading.Thread ):
|
||||
blockchain_id = str(entry['fqu'])
|
||||
fq_data_id = None
|
||||
data_txt = None
|
||||
profile = False
|
||||
|
||||
try:
|
||||
# mutable data?
|
||||
payload = json.loads(entry['profile'])
|
||||
@@ -1874,6 +1876,7 @@ class BlockstackStoragePusher( threading.Thread ):
|
||||
# profile
|
||||
fq_data_id = blockchain_id
|
||||
data_txt = str(entry['profile'])
|
||||
profile = True
|
||||
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
@@ -1882,7 +1885,7 @@ class BlockstackStoragePusher( threading.Thread ):
|
||||
queue_removeall( entries, path=self.queue_path )
|
||||
return False
|
||||
|
||||
success = store_mutable_data_to_storage( blockchain_id, fq_data_id, data_txt, required=storage_drivers, skip=['blockstack_server'])
|
||||
success = store_mutable_data_to_storage( blockchain_id, fq_data_id, data_txt, profile=profile, required=storage_drivers, skip=['blockstack_server'])
|
||||
if not success:
|
||||
log.error("Failed to store data for {} ({} bytes)".format(blockchain_id, len(data_txt)))
|
||||
queue_removeall( entries, path=self.queue_path )
|
||||
|
||||
@@ -268,16 +268,21 @@ def store_zonefile_to_storage( zonefile_dict, required=None, skip=None, cache=Fa
|
||||
return store_zonefile_data_to_storage( zonefile_data, required=required, skip=skip, cache=cache, zonefile_dir=zonefile_dir, name=name )
|
||||
|
||||
|
||||
def store_mutable_data_to_storage( blockchain_id, data_id, data_txt, required=None, skip=None ):
|
||||
def store_mutable_data_to_storage( blockchain_id, data_id, data_txt, profile=False, required=None, skip=None ):
|
||||
"""
|
||||
Store the given mutable datum to storage providers.
|
||||
Used by the storage gateway logic.
|
||||
Return True on successful replication to all required drivers
|
||||
Return False on error
|
||||
"""
|
||||
nocollide_data_id = None
|
||||
if profile:
|
||||
nocollide_data_id = blockchain_id
|
||||
|
||||
else:
|
||||
nocollide_data_id = '{}-{}'.format(blockchain_id, data_id)
|
||||
res = blockstack_client.storage.put_mutable_data(nocollide_data_id, None, None, data_text=data_txt, required=required, skip=skip, blockchain_id=blockchain_id)
|
||||
|
||||
res = blockstack_client.storage.put_mutable_data(nocollide_data_id, data_txt, None, sign=False, required=required, skip=skip, blockchain_id=blockchain_id)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
@@ -905,7 +905,7 @@ def put_immutable_data(data_text, txid, data_hash=None, required=None, skip=None
|
||||
return None if successes == 0 and required_successes == len(required) else data_hash
|
||||
|
||||
|
||||
def put_mutable_data(fq_data_id, data_text_or_json, data_privkey=None, data_pubkey=None, data_signature=None, profile=False, blockchain_id=None, required=None, skip=None, required_exclusive=False):
|
||||
def put_mutable_data(fq_data_id, data_text_or_json, sign=True, data_privkey=None, data_pubkey=None, data_signature=None, profile=False, blockchain_id=None, required=None, skip=None, required_exclusive=False):
|
||||
"""
|
||||
Given the unserialized data, store it into our mutable data stores.
|
||||
Do so in a best-effort way. This method fails if all storage providers fail,
|
||||
@@ -933,11 +933,15 @@ def put_mutable_data(fq_data_id, data_text_or_json, data_privkey=None, data_pubk
|
||||
|
||||
data_pubkey = get_pubkey_hex( data_privkey )
|
||||
|
||||
else:
|
||||
elif sign:
|
||||
assert data_pubkey is not None
|
||||
assert data_signature is not None
|
||||
|
||||
serialized_data = None
|
||||
if sign:
|
||||
serialized_data = serialize_mutable_data(data_text_or_json, data_privkey=data_privkey, data_pubkey=data_pubkey, data_signature=data_signature, profile=profile)
|
||||
else:
|
||||
serialized_data = data_text_or_json
|
||||
|
||||
successes = 0
|
||||
required_successes = 0
|
||||
|
||||
Reference in New Issue
Block a user