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