RPC: minor changes and add genesis+N
This commit is contained in:
parent
60a6b76229
commit
9d34bd6f16
@ -77,11 +77,12 @@ let parse_block s =
|
|||||||
end in
|
end in
|
||||||
try
|
try
|
||||||
match split_on_delim (count_delims s) with
|
match split_on_delim (count_delims s) with
|
||||||
| (["genesis"],_) -> Ok `Genesis
|
| (["genesis"], _) -> Ok `Genesis
|
||||||
| (["head"],_) -> Ok (`Head 0)
|
| (["genesis"; n], '+') -> Ok (`Level (Int32.of_string n))
|
||||||
| (["head"; n],'~') -> Ok (`Head (int_of_string n))
|
| (["head"], _) -> Ok (`Head 0)
|
||||||
| (["head"; n],'-') -> Ok (`Head (int_of_string n))
|
| (["head"; n], '~') | (["head"; n], '-') ->
|
||||||
| ([hol],_) ->
|
Ok (`Head (int_of_string n))
|
||||||
|
| ([hol], _) ->
|
||||||
begin
|
begin
|
||||||
match Block_hash.of_b58check_opt hol with
|
match Block_hash.of_b58check_opt hol with
|
||||||
Some h -> Ok (`Hash (h , 0))
|
Some h -> Ok (`Hash (h , 0))
|
||||||
@ -90,9 +91,9 @@ let parse_block s =
|
|||||||
if Int32.(compare l (of_int 0)) < 0 then raise Exit
|
if Int32.(compare l (of_int 0)) < 0 then raise Exit
|
||||||
else Ok (`Level (Int32.of_string s))
|
else Ok (`Level (Int32.of_string s))
|
||||||
end
|
end
|
||||||
| ([h ; n],'~') -> Ok (`Hash (Block_hash.of_b58check_exn h, int_of_string n))
|
| ([h ; n], '~') | ([h ; n], '-') ->
|
||||||
| ([h ; n],'-') -> Ok (`Hash (Block_hash.of_b58check_exn h, int_of_string n))
|
Ok (`Hash (Block_hash.of_b58check_exn h, int_of_string n))
|
||||||
| ([h ; n],'+') -> Ok (`Hash (Block_hash.of_b58check_exn h, - int_of_string n))
|
| ([h ; n], '+') -> Ok (`Hash (Block_hash.of_b58check_exn h, - int_of_string n))
|
||||||
| _ -> raise Exit
|
| _ -> raise Exit
|
||||||
with _ -> Error "Cannot parse block identifier."
|
with _ -> Error "Cannot parse block identifier."
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ let blocks_arg =
|
|||||||
one the predefined aliases: 'genesis', 'head' \
|
one the predefined aliases: 'genesis', 'head' \
|
||||||
or a block level (index in the chain). \
|
or a block level (index in the chain). \
|
||||||
One might also use 'head~N' or '<hash>~N' where N is an integer to \
|
One might also use 'head~N' or '<hash>~N' where N is an integer to \
|
||||||
denotes the Nth predecessor of the designated block.\
|
denote the Nth predecessor of the designated block.\
|
||||||
Also, '<hash>+N' denotes the Nth successor of a block." in
|
Also, '<hash>+N' denotes the Nth successor of a block." in
|
||||||
let construct = to_string in
|
let construct = to_string in
|
||||||
let destruct = parse_block in
|
let destruct = parse_block in
|
||||||
|
Loading…
Reference in New Issue
Block a user