P2P: allow ti limit the length of list in requests
This commit is contained in:
parent
970305a455
commit
85a25e200d
@ -31,6 +31,7 @@ module Make_raw
|
||||
Distributed_db_functors.MEMORY_TABLE with type key := Hash.t)
|
||||
(Request_message : sig
|
||||
type param
|
||||
val max_length : int
|
||||
val forge : param -> Hash.t list -> Message.t
|
||||
end)
|
||||
(Precheck : Distributed_db_functors.PRECHECK
|
||||
@ -40,8 +41,10 @@ module Make_raw
|
||||
module Request = struct
|
||||
type param = Request_message.param request_param
|
||||
let active { active } = active ()
|
||||
let send { data ; send } gid keys =
|
||||
send gid (Request_message.forge data keys)
|
||||
let rec send state gid keys =
|
||||
let first_keys, keys = List.split_n Request_message.max_length keys in
|
||||
state.send gid (Request_message.forge state.data first_keys) ;
|
||||
if keys <> [] then send state gid keys
|
||||
end
|
||||
|
||||
module Scheduler =
|
||||
@ -82,6 +85,7 @@ module Raw_operation =
|
||||
(Operation_hash.Table)
|
||||
(struct
|
||||
type param = unit
|
||||
let max_length = 10
|
||||
let forge () keys = Message.Get_operations keys
|
||||
end)
|
||||
(struct
|
||||
@ -112,6 +116,7 @@ module Raw_block_header =
|
||||
(Block_hash.Table)
|
||||
(struct
|
||||
type param = unit
|
||||
let max_length = 10
|
||||
let forge () keys = Message.Get_block_headers keys
|
||||
end)
|
||||
(struct
|
||||
@ -164,6 +169,7 @@ module Raw_operation_hashes = struct
|
||||
(Operations_table)
|
||||
(struct
|
||||
type param = unit
|
||||
let max_length = 10
|
||||
let forge () keys =
|
||||
Message.Get_operation_hashes_for_blocks keys
|
||||
end)
|
||||
@ -232,6 +238,7 @@ module Raw_operations = struct
|
||||
(Operations_table)
|
||||
(struct
|
||||
type param = unit
|
||||
let max_length = 10
|
||||
let forge () keys =
|
||||
Message.Get_operations_for_blocks keys
|
||||
end)
|
||||
@ -281,6 +288,7 @@ module Raw_protocol =
|
||||
(Protocol_hash.Table)
|
||||
(struct
|
||||
type param = unit
|
||||
let max_length = 10
|
||||
let forge () keys = Message.Get_protocols keys
|
||||
end)
|
||||
(struct
|
||||
|
@ -90,7 +90,7 @@ let encoding =
|
||||
|
||||
case ~tag:0x20
|
||||
~title:"Get_block_headers"
|
||||
(obj1 (req "get_block_headers" (list Block_hash.encoding)))
|
||||
(obj1 (req "get_block_headers" (list ~max_length:10 Block_hash.encoding)))
|
||||
(function
|
||||
| Get_block_headers bhs -> Some bhs
|
||||
| _ -> None)
|
||||
@ -106,7 +106,7 @@ let encoding =
|
||||
|
||||
case ~tag:0x30
|
||||
~title:"Get_operations"
|
||||
(obj1 (req "get_operations" (list Operation_hash.encoding)))
|
||||
(obj1 (req "get_operations" (list ~max_length:10 Operation_hash.encoding)))
|
||||
(function
|
||||
| Get_operations bhs -> Some bhs
|
||||
| _ -> None)
|
||||
@ -121,7 +121,7 @@ let encoding =
|
||||
case ~tag:0x40
|
||||
~title:"Get_protocols"
|
||||
(obj1
|
||||
(req "get_protocols" (list Protocol_hash.encoding)))
|
||||
(req "get_protocols" (list ~max_length:10 Protocol_hash.encoding)))
|
||||
(function
|
||||
| Get_protocols protos -> Some protos
|
||||
| _ -> None)
|
||||
@ -136,7 +136,7 @@ let encoding =
|
||||
case ~tag:0x50
|
||||
~title:"Get_operation_hashes_for_blocks"
|
||||
(obj1 (req "get_operation_hashes_for_blocks"
|
||||
(list (tup2 Block_hash.encoding int8))))
|
||||
(list ~max_length:10 (tup2 Block_hash.encoding int8))))
|
||||
(function
|
||||
| Get_operation_hashes_for_blocks keys -> Some keys
|
||||
| _ -> None)
|
||||
@ -159,9 +159,10 @@ let encoding =
|
||||
case ~tag:0x60
|
||||
~title:"Get_operations_for_blocks"
|
||||
(obj1 (req "get_operations_for_blocks"
|
||||
(list (obj2
|
||||
(req "hash" Block_hash.encoding)
|
||||
(req "validation_pass" int8)))))
|
||||
(list ~max_length:10
|
||||
(obj2
|
||||
(req "hash" Block_hash.encoding)
|
||||
(req "validation_pass" int8)))))
|
||||
(function
|
||||
| Get_operations_for_blocks keys -> Some keys
|
||||
| _ -> None)
|
||||
|
Loading…
Reference in New Issue
Block a user