mirror of
https://github.com/matrix-construct/construct
synced 2025-03-13 21:10:32 +01:00
ircd:Ⓜ️:media::block: Add zero-copy block::get() closure.
This commit is contained in:
parent
e357974d6f
commit
dc1364c735
2 changed files with 10 additions and 0 deletions
|
@ -49,6 +49,7 @@ namespace ircd::m::media::block
|
|||
using closure = std::function<void (const const_buffer &)>;
|
||||
|
||||
bool prefetch(const string_view &hash);
|
||||
bool get(const string_view &hash, const closure &);
|
||||
const_buffer get(const mutable_buffer &out, const string_view &hash);
|
||||
|
||||
void set(const string_view &hash, const const_buffer &block);
|
||||
|
|
|
@ -679,6 +679,15 @@ ircd::m::media::block::get(const mutable_buffer &out,
|
|||
return db::read(blocks, b58hash, out);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::media::block::get(const string_view &b58hash,
|
||||
const closure &closure)
|
||||
{
|
||||
const db::gopts opts;
|
||||
return blocks(b58hash, std::nothrow, closure, opts);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::media::block::prefetch(const string_view &b58hash)
|
||||
|
|
Loading…
Add table
Reference in a new issue