Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
cdec9b0d
Commit
cdec9b0d
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
value: add documentation
parent
46ab981e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/default_types.h
+1
-1
1 addition, 1 deletion
include/opendht/default_types.h
include/opendht/value.h
+28
-3
28 additions, 3 deletions
include/opendht/value.h
with
29 additions
and
4 deletions
include/opendht/default_types.h
+
1
−
1
View file @
cdec9b0d
...
@@ -37,7 +37,7 @@ struct DhtMessage : public Value::Serializable<DhtMessage>
...
@@ -37,7 +37,7 @@ struct DhtMessage : public Value::Serializable<DhtMessage>
}
}
static
Value
::
Filter
getFilter
()
{
return
{};
}
static
Value
::
Filter
getFilter
()
{
return
{};
}
static
bool
storePolicy
(
InfoHash
,
std
::
shared_ptr
<
Value
>&
,
InfoHash
,
const
sockaddr
*
,
socklen_t
);
static
bool
storePolicy
(
InfoHash
key
,
std
::
shared_ptr
<
Value
>&
value
,
InfoHash
from
,
const
sockaddr
*
from_addr
,
socklen_t
from_len
);
static
Value
::
Filter
ServiceFilter
(
std
::
string
s
);
static
Value
::
Filter
ServiceFilter
(
std
::
string
s
);
...
...
This diff is collapsed.
Click to expand it.
include/opendht/value.h
+
28
−
3
View file @
cdec9b0d
...
@@ -51,10 +51,35 @@ namespace dht {
...
@@ -51,10 +51,35 @@ namespace dht {
struct
Value
;
struct
Value
;
typedef
std
::
function
<
bool
(
InfoHash
,
std
::
shared_ptr
<
Value
>&
,
InfoHash
,
const
sockaddr
*
,
socklen_t
)
>
StorePolicy
;
/**
typedef
std
::
function
<
bool
(
InfoHash
,
const
std
::
shared_ptr
<
Value
>&
,
std
::
shared_ptr
<
Value
>&
,
InfoHash
,
const
sockaddr
*
,
socklen_t
)
>
EditPolicy
;
* A storage policy is applied once to every incoming value storage requests.
* If the policy returns false, the value is dropped.
*
* @param key: the key where the storage is requested.
* @param value: the value to be stored. The value can be edited by the storage policy.
* @param from: id of the requesting node.
* @param form_addr: network address of the incoming request.
* @param from_len: network address lendth of the incoming request.
*/
using
StorePolicy
=
std
::
function
<
bool
(
InfoHash
key
,
std
::
shared_ptr
<
Value
>&
value
,
InfoHash
from
,
const
sockaddr
*
from_addr
,
socklen_t
from_len
)
>
;
/**
* An edition policy is applied once to every incoming value storage requests,
* if a value already exists for this key and value id.
* If the policy returns false, the edition request is ignored.
* The default behavior is to deny edition (see {ValueType::DEFAULT_EDIT_POLICY}).
* Some {ValueType}s may override this behavior (e.g. SignedValue).
*
* @param key: the key where the value is stored.
* @param old_val: the previously stored value.
* @param new_val: the new value to be stored. The value can be edited by the edit policy.
* @param from: id of the requesting node.
* @param form_addr: network address of the incoming request.
* @param from_len: network address lendth of the incoming request.
*/
using
EditPolicy
=
std
::
function
<
bool
(
InfoHash
key
,
const
std
::
shared_ptr
<
Value
>&
old_val
,
std
::
shared_ptr
<
Value
>&
new_val
,
InfoHash
from
,
const
sockaddr
*
from_addr
,
socklen_t
from_len
)
>
;
static
constexpr
size_t
MAX_VALUE_SIZE
{
1024
*
128
};
static
constexpr
const
size_t
MAX_VALUE_SIZE
{
1024
*
128
};
struct
ValueType
{
struct
ValueType
{
typedef
uint16_t
Id
;
typedef
uint16_t
Id
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment