Support namecoin standard 'map' for subdomain name (#1856)
* Support namecoin standard 'map' for subdomain name * Proper naming for variables * naming fix and added one case for namecoin standard
This commit is contained in:
parent
8ee8acf655
commit
1f1e6006ec
1 changed files with 26 additions and 2 deletions
|
@ -22,9 +22,33 @@ def processNameOp(domain, value, test=False):
|
|||
except Exception, err:
|
||||
print "Json load error: %s" % err
|
||||
return False
|
||||
if "zeronet" not in data:
|
||||
print "No zeronet in ", data.keys()
|
||||
if "zeronet" not in data and "map" not in data:
|
||||
# Namecoin standard use {"map": { "blog": {"zeronet": "1D..."} }}
|
||||
print "No zeronet and no map in ", data.keys()
|
||||
return False
|
||||
if "map" in data:
|
||||
# If subdomains using the Namecoin standard is present, just re-write in the Zeronet way
|
||||
# and call the function again
|
||||
data_map = data["map"]
|
||||
new_value = {}
|
||||
for subdomain in data_map:
|
||||
if "zeronet" in data_map[subdomain]:
|
||||
new_value[subdomain] = data_map[subdomain]["zeronet"]
|
||||
if "zeronet" in data and isinstance(data["zeronet"], basestring):
|
||||
# {
|
||||
# "zeronet":"19rXKeKptSdQ9qt7omwN82smehzTuuq6S9",
|
||||
# ....
|
||||
# }
|
||||
new_value[""] = data["zeronet"]
|
||||
if len(new_value) > 0:
|
||||
return processNameOp(domain, json.dumps({"zeronet": new_value}), test)
|
||||
else:
|
||||
return False
|
||||
if "zeronet" in data and isinstance(data["zeronet"], basestring):
|
||||
# {
|
||||
# "zeronet":"19rXKeKptSdQ9qt7omwN82smehzTuuq6S9"
|
||||
# } is valid
|
||||
return processNameOp(domain, json.dumps({"zeronet": { "": data["zeronet"]}}), test)
|
||||
if not isinstance(data["zeronet"], dict):
|
||||
print "Not dict: ", data["zeronet"]
|
||||
return False
|
||||
|
|
Loading…
Reference in a new issue