Documentation ¶
Index ¶
- Variables
- type AddrInfo
- type PeerDB
- func (p *PeerDB) Close() error
- func (p *PeerDB) Delete(_ context.Context, key datastore.Key) error
- func (p *PeerDB) Get(_ context.Context, key datastore.Key) (value []byte, err error)
- func (pdb *PeerDB) GetPeerCount() int
- func (p *PeerDB) GetSize(_ context.Context, key datastore.Key) (size int, err error)
- func (p *PeerDB) Has(_ context.Context, key datastore.Key) (exists bool, err error)
- func (p *PeerDB) Put(_ context.Context, key datastore.Key, value []byte) error
- func (p *PeerDB) Query(ctx context.Context, q query.Query) (query.Results, error)
- func (p *PeerDB) Sync(ctx context.Context, prefix datastore.Key) error
- type PeerInfo
- type ProtoAddrInfo
- func (*ProtoAddrInfo) Descriptor() ([]byte, []int)deprecated
- func (x *ProtoAddrInfo) GetAddrs() []string
- func (x *ProtoAddrInfo) GetID() string
- func (*ProtoAddrInfo) ProtoMessage()
- func (x *ProtoAddrInfo) ProtoReflect() protoreflect.Message
- func (x *ProtoAddrInfo) Reset()
- func (x *ProtoAddrInfo) String() string
- type ProtoPeerInfo
- func (*ProtoPeerInfo) Descriptor() ([]byte, []int)deprecated
- func (x *ProtoPeerInfo) GetAddrInfo() *ProtoAddrInfo
- func (x *ProtoPeerInfo) GetEntropy() uint64
- func (x *ProtoPeerInfo) GetProtected() bool
- func (x *ProtoPeerInfo) GetPubKey() []byte
- func (*ProtoPeerInfo) ProtoMessage()
- func (x *ProtoPeerInfo) ProtoReflect() protoreflect.Message
- func (x *ProtoPeerInfo) Reset()
- func (x *ProtoPeerInfo) String() string
Constants ¶
This section is empty.
Variables ¶
var (
ErrPeerNotFound = leveldb.ErrNotFound
)
var File_p2p_node_peerManager_peerdb_peer_info_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type AddrInfo ¶
func (*AddrInfo) ProtoDecode ¶
func (addr *AddrInfo) ProtoDecode(protoAddr *ProtoAddrInfo) error
func (*AddrInfo) ProtoEncode ¶
func (addr *AddrInfo) ProtoEncode() *ProtoAddrInfo
type PeerDB ¶
type PeerDB struct {
// contains filtered or unexported fields
}
PeerDB implements the ipfs Datastore interface and exposes an API for storing and retrieving peers using levelDB as the underlying database
func (*PeerDB) Close ¶
Close closes the datastore. If the datastore is already closed, this returns ErrClosed.
func (*PeerDB) Delete ¶
Delete removes the value for given `key`. If the key is not in the datastore, this method returns no error.
func (*PeerDB) Get ¶
Get retrieves the object `value` named by `key`. Get will return ErrNotFound if the key is not mapped to a value.
func (*PeerDB) GetPeerCount ¶
Returns the number of peers stored in the database
func (*PeerDB) GetSize ¶
GetSize returns the size of the `value` named by `key`. In some contexts, it may be much cheaper to only get the size of the value rather than retrieving the value itself.
func (*PeerDB) Has ¶
Has returns whether the `key` is mapped to a `value`. In some contexts, it may be much cheaper only to check for existence of a value, rather than retrieving the value itself. (e.g. HTTP HEAD). The default implementation is found in `GetBackedHas`.
func (*PeerDB) Put ¶
Put stores the object `value` named by `key`.
The generalized Datastore interface does not impose a value type, allowing various datastore middleware implementations (which do not handle the values directly) to be composed together.
Ultimately, the lowest-level datastore will need to do some value checking or risk getting incorrect values. It may also be useful to expose a more type-safe interface to your application, and do the checking up-front.
func (*PeerDB) Query ¶
Query searches the datastore and returns a query result. This function may return before the query actually runs. To wait for the query:
result, _ := ds.Query(q) use the channel interface; result may come in at different times: for entry := range result.Next() { ... } or wait for the query to be completely done: entries, _ := result.Rest() for entry := range entries { ... }
func (*PeerDB) Sync ¶
Sync Method Sync guarantees that any Put or Delete calls under prefix that returned before Sync(prefix) was called will be observed after Sync(prefix) returns, even if the program crashes. If Put/Delete operations already satisfy these requirements then Sync may be a no-op.
If the prefix fails to Sync this method returns an error.
type PeerInfo ¶
contains the information of a peer that is stored in the peerDB as Value
func (*PeerInfo) ProtoDecode ¶
func (pi *PeerInfo) ProtoDecode(ppi *ProtoPeerInfo) error
func (*PeerInfo) ProtoEncode ¶
func (pi *PeerInfo) ProtoEncode() *ProtoPeerInfo
ProtoEncode converts the hash into the ProtoHash type
type ProtoAddrInfo ¶
type ProtoAddrInfo struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` Addrs []string `protobuf:"bytes,2,rep,name=Addrs,proto3" json:"Addrs,omitempty"` // contains filtered or unexported fields }
func (*ProtoAddrInfo) Descriptor
deprecated
func (*ProtoAddrInfo) Descriptor() ([]byte, []int)
Deprecated: Use ProtoAddrInfo.ProtoReflect.Descriptor instead.
func (*ProtoAddrInfo) GetAddrs ¶
func (x *ProtoAddrInfo) GetAddrs() []string
func (*ProtoAddrInfo) GetID ¶
func (x *ProtoAddrInfo) GetID() string
func (*ProtoAddrInfo) ProtoMessage ¶
func (*ProtoAddrInfo) ProtoMessage()
func (*ProtoAddrInfo) ProtoReflect ¶
func (x *ProtoAddrInfo) ProtoReflect() protoreflect.Message
func (*ProtoAddrInfo) Reset ¶
func (x *ProtoAddrInfo) Reset()
func (*ProtoAddrInfo) String ¶
func (x *ProtoAddrInfo) String() string
type ProtoPeerInfo ¶
type ProtoPeerInfo struct { AddrInfo *ProtoAddrInfo `protobuf:"bytes,1,opt,name=addrInfo,proto3" json:"addrInfo,omitempty"` PubKey []byte `protobuf:"bytes,2,opt,name=pubKey,proto3" json:"pubKey,omitempty"` Entropy uint64 `protobuf:"varint,3,opt,name=entropy,proto3" json:"entropy,omitempty"` Protected bool `protobuf:"varint,4,opt,name=protected,proto3" json:"protected,omitempty"` // contains filtered or unexported fields }
func (*ProtoPeerInfo) Descriptor
deprecated
func (*ProtoPeerInfo) Descriptor() ([]byte, []int)
Deprecated: Use ProtoPeerInfo.ProtoReflect.Descriptor instead.
func (*ProtoPeerInfo) GetAddrInfo ¶
func (x *ProtoPeerInfo) GetAddrInfo() *ProtoAddrInfo
func (*ProtoPeerInfo) GetEntropy ¶
func (x *ProtoPeerInfo) GetEntropy() uint64
func (*ProtoPeerInfo) GetProtected ¶
func (x *ProtoPeerInfo) GetProtected() bool
func (*ProtoPeerInfo) GetPubKey ¶
func (x *ProtoPeerInfo) GetPubKey() []byte
func (*ProtoPeerInfo) ProtoMessage ¶
func (*ProtoPeerInfo) ProtoMessage()
func (*ProtoPeerInfo) ProtoReflect ¶
func (x *ProtoPeerInfo) ProtoReflect() protoreflect.Message
func (*ProtoPeerInfo) Reset ¶
func (x *ProtoPeerInfo) Reset()
func (*ProtoPeerInfo) String ¶
func (x *ProtoPeerInfo) String() string