/
GetChannelSize.d
65 lines (42 loc) · 2.09 KB
/
GetChannelSize.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
Turtle implementation of DHT `GetChannelSize` request
Copyright:
Copyright (c) 2015-2017 dunnhumby Germany GmbH. All rights reserved.
License:
Boost Software License Version 1.0. See LICENSE.txt for details.
*******************************************************************************/
module fakedht.request.GetChannelSize;
/*******************************************************************************
Imports
*******************************************************************************/
import ocean.transition;
import Protocol = dhtproto.node.request.GetChannelSize;
/*******************************************************************************
GetChannelSize request implementation
*******************************************************************************/
public scope class GetChannelSize : Protocol.GetChannelSize
{
import fakedht.mixins.RequestConstruction;
import fakedht.Storage;
/***************************************************************************
Adds this.resources and constructor to initialize it and forward
arguments to base
***************************************************************************/
mixin RequestConstruction!();
/***************************************************************************
Gets the size metadata for specified channel. Overriden in
actual implementors of dhtnode protocol.
Params:
channel_name = name of channel to be queried
value_getter_dg = The delegate that is called with the channel data.
***************************************************************************/
override protected void getChannelData ( cstring channel_name,
scope void delegate ( ChannelSizeData ) value_getter_dg )
{
ChannelSizeData result;
auto channel = global_storage.get(channel_name);
if (channel !is null)
channel.countSize(result.records, result.bytes);
value_getter_dg(result);
}
}