-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from eosnetworkfoundation/elmato/dev
Many fixes
- Loading branch information
Showing
29 changed files
with
9,093 additions
and
14 deletions.
There are no files selected for viewing
Submodule silkworm
updated
10 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
def convert_name_to_value(name): | ||
def value_of_char(c: str): | ||
assert len(c) == 1 | ||
if c >= 'a' and c <= 'z': | ||
return ord(c) - ord('a') + 6 | ||
if c >= '1' and c <= '5': | ||
return ord(c) - ord('1') + 1 | ||
if c == '.': | ||
return 0 | ||
raise ValueError("invalid Antelope name: character '{0}' is not allowed".format(c)) | ||
|
||
name_length = len(name) | ||
|
||
if name_length > 13: | ||
raise ValueError("invalid Antelope name: cannot exceed 13 characters") | ||
|
||
thirteen_char_value = 0 | ||
if name_length == 13: | ||
thirteen_char_value = value_of_char(name[12]) | ||
if thirteen_char_value > 15: | ||
raise ValueError("invalid Antelope name: 13th character cannot be letter past j") | ||
|
||
normalized_name = name[:12].ljust(12,'.') # truncate/extend to at exactly 12 characters since the 13th character is handled differently | ||
|
||
def convert_to_value(str): | ||
value = 0 | ||
for c in str: | ||
value <<= 5 | ||
value |= value_of_char(c) | ||
|
||
return value | ||
|
||
return (convert_to_value(normalized_name) << 4) | thirteen_char_value |
Oops, something went wrong.