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
8fd71c7f
Commit
8fd71c7f
authored
9 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
dhtrunner: add missing shared_ptr<Value> versions of putSigned, putEncrypted.
parent
af6f33e9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/opendht/dhtrunner.h
+21
-7
21 additions, 7 deletions
include/opendht/dhtrunner.h
src/dhtrunner.cpp
+18
-8
18 additions, 8 deletions
src/dhtrunner.cpp
with
39 additions
and
15 deletions
include/opendht/dhtrunner.h
+
21
−
7
View file @
8fd71c7f
...
@@ -149,26 +149,40 @@ public:
...
@@ -149,26 +149,40 @@ public:
void
cancelListen
(
InfoHash
h
,
size_t
token
);
void
cancelListen
(
InfoHash
h
,
size_t
token
);
void
cancelListen
(
InfoHash
h
,
std
::
shared_future
<
size_t
>
token
);
void
cancelListen
(
InfoHash
h
,
std
::
shared_future
<
size_t
>
token
);
void
put
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
put
(
InfoHash
hash
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallback
cb
=
{});
void
put
(
InfoHash
hash
,
const
std
::
shared_ptr
<
Value
>&
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
put
(
InfoHash
hash
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallbackSimple
cb
)
{
put
(
hash
,
value
,
Dht
::
bindDoneCb
(
cb
));
}
void
put
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
{});
void
put
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
void
put
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
put
(
hash
,
std
::
forward
<
Value
>
(
value
),
Dht
::
bindDoneCb
(
cb
));
put
(
hash
,
std
::
forward
<
Value
>
(
value
),
Dht
::
bindDoneCb
(
cb
));
}
}
void
put
(
const
std
::
string
&
key
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
=
nullptr
);
void
put
(
const
std
::
string
&
key
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
=
{}
);
void
cancelPut
(
const
InfoHash
&
h
,
const
Value
::
Id
&
id
);
void
cancelPut
(
const
InfoHash
&
h
,
const
Value
::
Id
&
id
);
void
putSigned
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
putSigned
(
InfoHash
hash
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallback
cb
=
{});
void
putSigned
(
const
std
::
string
&
key
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
=
nullptr
);
void
putSigned
(
InfoHash
hash
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallbackSimple
cb
)
{
putSigned
(
hash
,
value
,
Dht
::
bindDoneCb
(
cb
));
}
void
putSigned
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
{});
void
putSigned
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
void
putSigned
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
putSigned
(
hash
,
std
::
forward
<
Value
>
(
value
),
Dht
::
bindDoneCb
(
cb
));
putSigned
(
hash
,
std
::
forward
<
Value
>
(
value
),
Dht
::
bindDoneCb
(
cb
));
}
}
void
putSigned
(
const
std
::
string
&
key
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
=
{});
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallback
cb
=
{});
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallbackSimple
cb
)
{
putEncrypted
(
hash
,
to
,
value
,
Dht
::
bindDoneCb
(
cb
));
}
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
{}
);
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
void
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
putEncrypted
(
hash
,
to
,
std
::
forward
<
Value
>
(
value
),
Dht
::
bindDoneCb
(
cb
));
putEncrypted
(
hash
,
to
,
std
::
forward
<
Value
>
(
value
),
Dht
::
bindDoneCb
(
cb
));
}
}
void
putEncrypted
(
const
std
::
string
&
key
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
nullptr
);
void
putEncrypted
(
const
std
::
string
&
key
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
=
{}
);
void
bootstrap
(
const
char
*
host
,
const
char
*
service
);
void
bootstrap
(
const
char
*
host
,
const
char
*
service
);
void
bootstrap
(
const
std
::
vector
<
std
::
pair
<
sockaddr_storage
,
socklen_t
>>&
nodes
);
void
bootstrap
(
const
std
::
vector
<
std
::
pair
<
sockaddr_storage
,
socklen_t
>>&
nodes
);
...
...
This diff is collapsed.
Click to expand it.
src/dhtrunner.cpp
+
18
−
8
View file @
8fd71c7f
...
@@ -359,7 +359,7 @@ DhtRunner::put(InfoHash hash, Value&& value, Dht::DoneCallback cb)
...
@@ -359,7 +359,7 @@ DhtRunner::put(InfoHash hash, Value&& value, Dht::DoneCallback cb)
}
}
void
void
DhtRunner
::
put
(
InfoHash
hash
,
const
std
::
shared_ptr
<
Value
>
&
value
,
Dht
::
DoneCallback
cb
)
DhtRunner
::
put
(
InfoHash
hash
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallback
cb
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
...
@@ -385,16 +385,21 @@ DhtRunner::cancelPut(const InfoHash& h , const Value::Id& id)
...
@@ -385,16 +385,21 @@ DhtRunner::cancelPut(const InfoHash& h , const Value::Id& id)
}
}
void
void
DhtRunner
::
putSigned
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallback
cb
)
DhtRunner
::
putSigned
(
InfoHash
hash
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallback
cb
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
auto
sv
=
std
::
make_shared
<
Value
>
(
std
::
move
(
value
));
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
dht
.
putSigned
(
hash
,
s
v
,
cb
);
dht
.
putSigned
(
hash
,
v
alue
,
cb
);
});
});
cv
.
notify_all
();
cv
.
notify_all
();
}
}
void
DhtRunner
::
putSigned
(
InfoHash
hash
,
Value
&&
value
,
Dht
::
DoneCallback
cb
)
{
putSigned
(
hash
,
std
::
make_shared
<
Value
>
(
std
::
move
(
value
)),
cb
);
}
void
void
DhtRunner
::
putSigned
(
const
std
::
string
&
key
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
DhtRunner
::
putSigned
(
const
std
::
string
&
key
,
Value
&&
value
,
Dht
::
DoneCallbackSimple
cb
)
{
{
...
@@ -402,16 +407,21 @@ DhtRunner::putSigned(const std::string& key, Value&& value, Dht::DoneCallbackSim
...
@@ -402,16 +407,21 @@ DhtRunner::putSigned(const std::string& key, Value&& value, Dht::DoneCallbackSim
}
}
void
void
DhtRunner
::
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
)
DhtRunner
::
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
std
::
shared_ptr
<
Value
>
value
,
Dht
::
DoneCallback
cb
)
{
{
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
std
::
lock_guard
<
std
::
mutex
>
lck
(
storage_mtx
);
auto
sv
=
std
::
make_shared
<
Value
>
(
std
::
move
(
value
));
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
pending_ops
.
emplace
([
=
](
SecureDht
&
dht
)
{
dht
.
putEncrypted
(
hash
,
to
,
s
v
,
cb
);
dht
.
putEncrypted
(
hash
,
to
,
v
alue
,
cb
);
});
});
cv
.
notify_all
();
cv
.
notify_all
();
}
}
void
DhtRunner
::
putEncrypted
(
InfoHash
hash
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
)
{
putEncrypted
(
hash
,
to
,
std
::
make_shared
<
Value
>
(
std
::
move
(
value
)),
cb
);
}
void
void
DhtRunner
::
putEncrypted
(
const
std
::
string
&
key
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
)
DhtRunner
::
putEncrypted
(
const
std
::
string
&
key
,
InfoHash
to
,
Value
&&
value
,
Dht
::
DoneCallback
cb
)
{
{
...
...
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