Address #2486.
This commit is contained in:
parent
3417871370
commit
b0a3008a1b
|
@ -231,71 +231,17 @@ proc validate(key: string, value: string): int =
|
||||||
## because it will be used for query routing.
|
## because it will be used for query routing.
|
||||||
case key
|
case key
|
||||||
of "{epoch}":
|
of "{epoch}":
|
||||||
# Can be any decimal 64bit value.
|
0
|
||||||
if len(value) > MaxDecimalSize: 1 else: match(value, DecimalSet)
|
|
||||||
of "{slot}":
|
of "{slot}":
|
||||||
# Can be any decimal 64bit value.
|
0
|
||||||
if len(value) > MaxDecimalSize: 1 else: match(value, DecimalSet)
|
|
||||||
of "{peer_id}":
|
of "{peer_id}":
|
||||||
# Can be base58 encoded value.
|
0
|
||||||
if len(value) > MaxPeerIdSize: 1 else: match(value, Base58Set)
|
|
||||||
of "{state_id}":
|
of "{state_id}":
|
||||||
# Can be one of: "head" (canonical head in node's view), "genesis",
|
0
|
||||||
# "finalized", "justified", <slot>, <hex encoded stateRoot with 0x prefix>.
|
|
||||||
if len(value) > 2:
|
|
||||||
if (value[0] == '0') and (value[1] == 'x'):
|
|
||||||
if len(value) != 2 + RootHashSize:
|
|
||||||
1
|
|
||||||
else:
|
|
||||||
match(value.toOpenArray(2, len(value) - 1), HexadecimalSet)
|
|
||||||
elif (value[0] in DecimalSet) and (value[1] in DecimalSet):
|
|
||||||
if len(value) > MaxDecimalSize:
|
|
||||||
1
|
|
||||||
else:
|
|
||||||
match(value.toOpenArray(2, len(value) - 1), DecimalSet)
|
|
||||||
else:
|
|
||||||
case value
|
|
||||||
of "head": 0
|
|
||||||
of "genesis": 0
|
|
||||||
of "finalized": 0
|
|
||||||
of "justified": 0
|
|
||||||
else: 1
|
|
||||||
else:
|
|
||||||
match(value, DecimalSet)
|
|
||||||
of "{block_id}":
|
of "{block_id}":
|
||||||
# Can be one of: "head" (canonical head in node's view), "genesis",
|
0
|
||||||
# "finalized", <slot>, <hex encoded blockRoot with 0x prefix>.
|
|
||||||
if len(value) > 2:
|
|
||||||
if (value[0] == '0') and (value[1] == 'x'):
|
|
||||||
if len(value) != 2 + RootHashSize:
|
|
||||||
1
|
|
||||||
else:
|
|
||||||
match(value.toOpenArray(2, len(value) - 1), HexadecimalSet)
|
|
||||||
elif (value[0] in DecimalSet) and (value[1] in DecimalSet):
|
|
||||||
if len(value) > MaxDecimalSize:
|
|
||||||
1
|
|
||||||
else:
|
|
||||||
match(value.toOpenArray(2, len(value) - 1), DecimalSet)
|
|
||||||
else:
|
|
||||||
case value
|
|
||||||
of "head": 0
|
|
||||||
of "genesis": 0
|
|
||||||
of "finalized": 0
|
|
||||||
else: 1
|
|
||||||
else:
|
|
||||||
match(value, DecimalSet)
|
|
||||||
of "{validator_id}":
|
of "{validator_id}":
|
||||||
# Either hex encoded public key (with 0x prefix) or validator index.
|
0
|
||||||
if len(value) > 2:
|
|
||||||
if (value[0] == '0') and (value[1] == 'x'):
|
|
||||||
if len(value) != 2 + ValidatorKeySize:
|
|
||||||
1
|
|
||||||
else:
|
|
||||||
match(value.toOpenArray(2, len(value) - 1), HexadecimalSet)
|
|
||||||
else:
|
|
||||||
match(value, DecimalSet)
|
|
||||||
else:
|
|
||||||
match(value, DecimalSet)
|
|
||||||
else:
|
else:
|
||||||
1
|
1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue