diff --git a/blockstack/blockstackd.py b/blockstack/blockstackd.py index 403e939ae..f762fc245 100644 --- a/blockstack/blockstackd.py +++ b/blockstack/blockstackd.py @@ -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 ) diff --git a/blockstack/lib/storage/crawl.py b/blockstack/lib/storage/crawl.py index 1d9f02e2f..77622a830 100644 --- a/blockstack/lib/storage/crawl.py +++ b/blockstack/lib/storage/crawl.py @@ -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 = '{}-{}'.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) + 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, data_txt, None, sign=False, required=required, skip=skip, blockchain_id=blockchain_id) return res diff --git a/blockstack_client/storage.py b/blockstack_client/storage.py index 5ab9f4bc5..a3e15f636 100644 --- a/blockstack_client/storage.py +++ b/blockstack_client/storage.py @@ -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 = serialize_mutable_data(data_text_or_json, data_privkey=data_privkey, data_pubkey=data_pubkey, data_signature=data_signature, profile=profile) + 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