protocol-design
protocol-design copied to clipboard
Bug removal in resolve
As parseDomain pushes the domain from left to right onto the list, we would end up with this list for the domain subdomain.dfinity.com (if it would have been implemented correctly, the way it's implemented now the com is missing):
HEAD
+
|
|
+---------+ +---------+ +--------+ +----v---+
| null +--->subdomain+-->dfinity +--->com |
| | | | | | | |
+---------+ +---------+ +--------+ +--------+
In the previous code with List.last<Text>(parsedDomain) we would assign ?subdomain to subdomain inside the first iteration of the while-loop. We would then ask Root-server for subdomain. Instead we should ask root for com which is the head of the list.
Additionally we would have then called List.drop<Text>(parsedDomain, counter) which would have dropped the first 2 elements in our list, leaving us with nothing but
HEAD
+
|
|
v
+---------+ +---+-----+
| null +--->subdomain|
| | | |
+---------+ +---------+
The proposed changes should fix this.