My Project 1.7.4
C++ Distributed Hash Table
Public Types | Public Member Functions | Protected Attributes | List of all members
dht::DhtInterface Class Referenceabstract
Inheritance diagram for dht::DhtInterface:
Inheritance graph
[legend]
Collaboration diagram for dht::DhtInterface:
Collaboration graph
[legend]

Public Types

using Status = NodeStatus
 
using NodeExport = dht::NodeExport
 

Public Member Functions

virtual NodeStatus getStatus (sa_family_t af) const =0
 
virtual NodeStatus getStatus () const =0
 
virtual const InfoHashgetNodeId () const =0
 
virtual void shutdown (ShutdownCallback cb)=0
 
virtual bool isRunning (sa_family_t af=0) const =0
 
virtual void registerType (const ValueType &type)=0
 
virtual const ValueTypegetType (ValueType::Id type_id) const =0
 
virtual void insertNode (const InfoHash &id, const SockAddr &)=0
 
virtual void insertNode (const InfoHash &id, const sockaddr *sa, socklen_t salen)=0
 
virtual void insertNode (const NodeExport &n)=0
 
virtual void pingNode (const sockaddr *, socklen_t, DoneCallbackSimple &&cb={})=0
 
virtual time_point periodic (const uint8_t *buf, size_t buflen, const SockAddr &)=0
 
virtual time_point periodic (const uint8_t *buf, size_t buflen, const sockaddr *from, socklen_t fromlen)=0
 
virtual void get (const InfoHash &key, GetCallback cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={})=0
 
virtual void get (const InfoHash &key, GetCallback cb, DoneCallbackSimple donecb={}, Value::Filter &&f={}, Where &&w={})=0
 
virtual void get (const InfoHash &key, GetCallbackSimple cb, DoneCallback donecb={}, Value::Filter &&f={}, Where &&w={})=0
 
virtual void get (const InfoHash &key, GetCallbackSimple cb, DoneCallbackSimple donecb, Value::Filter &&f={}, Where &&w={})=0
 
virtual void query (const InfoHash &key, QueryCallback cb, DoneCallback done_cb={}, Query &&q={})=0
 
virtual void query (const InfoHash &key, QueryCallback cb, DoneCallbackSimple done_cb={}, Query &&q={})=0
 
virtual std::vector< Sp< Value > > getLocal (const InfoHash &key, Value::Filter f=Value::AllFilter()) const =0
 
virtual Sp< ValuegetLocalById (const InfoHash &key, Value::Id vid) const =0
 
virtual void put (const InfoHash &key, Sp< Value >, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false)=0
 
virtual void put (const InfoHash &key, const Sp< Value > &v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false)=0
 
virtual void put (const InfoHash &key, Value &&v, DoneCallback cb=nullptr, time_point created=time_point::max(), bool permanent=false)=0
 
virtual void put (const InfoHash &key, Value &&v, DoneCallbackSimple cb, time_point created=time_point::max(), bool permanent=false)=0
 
virtual std::vector< Sp< Value > > getPut (const InfoHash &)=0
 
virtual Sp< ValuegetPut (const InfoHash &, const Value::Id &)=0
 
virtual bool cancelPut (const InfoHash &, const Value::Id &)=0
 
virtual size_t listen (const InfoHash &, GetCallback, Value::Filter={}, Where w={})=0
 
virtual size_t listen (const InfoHash &key, GetCallbackSimple cb, Value::Filter f={}, Where w={})=0
 
virtual size_t listen (const InfoHash &, ValueCallback, Value::Filter={}, Where w={})=0
 
virtual bool cancelListen (const InfoHash &, size_t token)=0
 
virtual void connectivityChanged (sa_family_t)=0
 
virtual void connectivityChanged ()=0
 
virtual std::vector< NodeExportexportNodes ()=0
 
virtual std::vector< ValuesExport > exportValues () const =0
 
virtual void importValues (const std::vector< ValuesExport > &)=0
 
virtual NodeStats getNodesStats (sa_family_t af) const =0
 
virtual std::string getStorageLog () const =0
 
virtual std::string getStorageLog (const InfoHash &) const =0
 
virtual std::string getRoutingTablesLog (sa_family_t) const =0
 
virtual std::string getSearchesLog (sa_family_t) const =0
 
virtual std::string getSearchLog (const InfoHash &, sa_family_t af=AF_UNSPEC) const =0
 
virtual void dumpTables () const =0
 
virtual std::vector< unsigned > getNodeMessageStats (bool in=false)=0
 
virtual void setStorageLimit (size_t limit=DEFAULT_STORAGE_LIMIT)=0
 
virtual std::pair< size_t, size_t > getStoreSize () const =0
 
virtual std::vector< SockAddrgetPublicAddress (sa_family_t family=0)=0
 
virtual void setLoggers (LogMethod error=NOLOG, LogMethod warn=NOLOG, LogMethod debug=NOLOG)
 
virtual void setLogFilter (const InfoHash &f)
 
virtual void setPushNotificationToken (const std::string &)
 
virtual void pushNotificationReceived (const std::map< std::string, std::string > &data)=0
 

Protected Attributes

bool logFilerEnable_ {}
 
InfoHash logFiler_ {}
 
Logger DHT_LOG
 

Detailed Description

Definition at line 26 of file dht_interface.h.

Member Typedef Documentation

◆ NodeExport

Definition at line 34 of file dht_interface.h.

◆ Status

Definition at line 32 of file dht_interface.h.

Member Function Documentation

◆ cancelPut()

virtual bool dht::DhtInterface::cancelPut ( const InfoHash ,
const Value::Id &   
)
pure virtual

Stop any put/announce operation at the given location, for the value with the given id.

Implemented in dht::Dht, and dht::SecureDht.

◆ connectivityChanged()

virtual void dht::DhtInterface::connectivityChanged ( sa_family_t  )
pure virtual

Inform the DHT of lower-layer connectivity changes. This will cause the DHT to assume a public IP address change. The DHT will recontact neighbor nodes, re-register for listen ops etc.

Implemented in dht::SecureDht, and dht::Dht.

◆ exportNodes()

virtual std::vector< NodeExport > dht::DhtInterface::exportNodes ( )
pure virtual

Get the list of good nodes for local storage saving purposes The list is ordered to minimize the back-to-work delay.

Implemented in dht::Dht, and dht::SecureDht.

◆ get()

virtual void dht::DhtInterface::get ( const InfoHash key,
GetCallback  cb,
DoneCallback  donecb = {},
Value::Filter &&  f = {},
Where &&  w = {} 
)
pure virtual

Get a value by searching on all available protocols (IPv4, IPv6), and call the provided get callback when values are found at key. The operation will start as soon as the node is connected to the network.

Parameters
cba function called when new values are found on the network. It should return false to stop the operation.
donecba function called when the operation is complete. cb and donecb won't be called again afterward.
fa filter function used to prefilter values.

Implemented in dht::SecureDht, and dht::Dht.

◆ getLocal()

virtual std::vector< Sp< Value > > dht::DhtInterface::getLocal ( const InfoHash key,
Value::Filter  f = Value::AllFilter() 
) const
pure virtual

Get locally stored data for the given hash.

Implemented in dht::Dht, and dht::SecureDht.

◆ getLocalById()

virtual Sp< Value > dht::DhtInterface::getLocalById ( const InfoHash key,
Value::Id  vid 
) const
pure virtual

Get locally stored data for the given key and value id.

Implemented in dht::Dht, and dht::SecureDht.

◆ getNodeId()

virtual const InfoHash & dht::DhtInterface::getNodeId ( ) const
pure virtual

Get the ID of the node.

Implemented in dht::Dht, and dht::SecureDht.

◆ getPut() [1/2]

virtual std::vector< Sp< Value > > dht::DhtInterface::getPut ( const InfoHash )
pure virtual

Get data currently being put at the given hash.

Implemented in dht::Dht, and dht::SecureDht.

◆ getPut() [2/2]

virtual Sp< Value > dht::DhtInterface::getPut ( const InfoHash ,
const Value::Id &   
)
pure virtual

Get data currently being put at the given hash with the given id.

Implemented in dht::Dht, and dht::SecureDht.

◆ getStatus()

virtual NodeStatus dht::DhtInterface::getStatus ( sa_family_t  af) const
pure virtual

Get the current status of the node for the given family.

Implemented in dht::Dht, and dht::SecureDht.

◆ getStoreSize()

virtual std::pair< size_t, size_t > dht::DhtInterface::getStoreSize ( ) const
pure virtual

Returns the total memory usage of stored values and the number of stored values.

Implemented in dht::Dht, and dht::SecureDht.

◆ insertNode()

virtual void dht::DhtInterface::insertNode ( const InfoHash id,
const SockAddr  
)
pure virtual

Insert a node in the main routing table. The node is not pinged, so this should be used to bootstrap efficiently from previously known nodes.

Implemented in dht::Dht, and dht::SecureDht.

◆ isRunning()

virtual bool dht::DhtInterface::isRunning ( sa_family_t  af = 0) const
pure virtual

Returns true if the node is running (have access to an open socket).

af: address family. If non-zero, will return true if the node is running for the provided family.

Implemented in dht::Dht, and dht::SecureDht.

◆ listen() [1/2]

virtual size_t dht::DhtInterface::listen ( const InfoHash ,
GetCallback  ,
Value::Filter  = {},
Where  w = {} 
)
pure virtual

Listen on the network for any changes involving a specified hash. The node will register to receive updates from relevent nodes when new values are added or removed.

Returns
a token to cancel the listener later.

Implemented in dht::Dht, and dht::SecureDht.

◆ listen() [2/2]

virtual size_t dht::DhtInterface::listen ( const InfoHash ,
ValueCallback  ,
Value::Filter  = {},
Where  w = {} 
)
pure virtual

Implemented in dht::Dht.

◆ pushNotificationReceived()

virtual void dht::DhtInterface::pushNotificationReceived ( const std::map< std::string, std::string > &  data)
pure virtual

Call linked callback with a push notification

Parameters
notificationto process

Implemented in dht::Dht, and dht::SecureDht.

◆ put()

virtual void dht::DhtInterface::put ( const InfoHash key,
Sp< Value ,
DoneCallback  cb = nullptr,
time_point  created = time_point::max(),
bool  permanent = false 
)
pure virtual

Announce a value on all available protocols (IPv4, IPv6).

The operation will start as soon as the node is connected to the network. The done callback will be called once, when the first announce succeeds, or fails.

Implemented in dht::SecureDht, and dht::Dht.

◆ query()

virtual void dht::DhtInterface::query ( const InfoHash key,
QueryCallback  cb,
DoneCallback  done_cb = {},
Query &&  q = {} 
)
pure virtual

Similar to Dht::get, but sends a Query to filter data remotely.

Parameters
keythe key for which to query data for.
cba function called when new values are found on the network. It should return false to stop the operation.
done_cba function called when the operation is complete. cb and done_cb won't be called again afterward.
qa query used to filter values on the remotes before they send a response.

Implemented in dht::Dht, and dht::SecureDht.

◆ setLogFilter()

virtual void dht::DhtInterface::setLogFilter ( const InfoHash f)
inlinevirtual

Only print logs related to the given InfoHash (if given), or disable filter (if zeroes).

Reimplemented in dht::SecureDht.

Definition at line 227 of file dht_interface.h.

◆ setLoggers()

virtual void dht::DhtInterface::setLoggers ( LogMethod  error = NOLOG,
LogMethod  warn = NOLOG,
LogMethod  debug = NOLOG 
)
inlinevirtual

Enable or disable logging of DHT internal messages

Reimplemented in dht::SecureDht.

Definition at line 217 of file dht_interface.h.

◆ setPushNotificationToken()

virtual void dht::DhtInterface::setPushNotificationToken ( const std::string &  )
inlinevirtual

Definition at line 232 of file dht_interface.h.

◆ setStorageLimit()

virtual void dht::DhtInterface::setStorageLimit ( size_t  limit = DEFAULT_STORAGE_LIMIT)
pure virtual

Set the in-memory storage limit in bytes

Implemented in dht::Dht, and dht::SecureDht.

◆ shutdown()

virtual void dht::DhtInterface::shutdown ( ShutdownCallback  cb)
pure virtual

Performs final operations before quitting.

Implemented in dht::Dht, and dht::SecureDht.

Member Data Documentation

◆ DHT_LOG

Logger dht::DhtInterface::DHT_LOG
protected

Definition at line 243 of file dht_interface.h.

◆ logFiler_

InfoHash dht::DhtInterface::logFiler_ {}
protected

Definition at line 242 of file dht_interface.h.

◆ logFilerEnable_

bool dht::DhtInterface::logFilerEnable_ {}
protected

Definition at line 241 of file dht_interface.h.


The documentation for this class was generated from the following file: