2023-03-27 13:51:55 +00:00
|
|
|
package dbi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RegistrationRecord struct {
|
2023-06-07 20:46:50 +00:00
|
|
|
Id peer.ID
|
|
|
|
SignedPeerRecord []byte
|
|
|
|
Ns string
|
|
|
|
Ttl int
|
2023-03-27 13:51:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DB interface {
|
|
|
|
Close() error
|
2023-06-07 20:46:50 +00:00
|
|
|
Register(p peer.ID, ns string, signedPeerRecord []byte, ttl int) (uint64, error)
|
2023-03-27 13:51:55 +00:00
|
|
|
Unregister(p peer.ID, ns string) error
|
|
|
|
CountRegistrations(p peer.ID) (int, error)
|
|
|
|
Discover(ns string, cookie []byte, limit int) ([]RegistrationRecord, []byte, error)
|
|
|
|
ValidCookie(ns string, cookie []byte) bool
|
|
|
|
}
|