Documentation ¶
Index ¶
- Constants
- Variables
- func CheckSig(relay *ws.NIP11RelayInfo) error
- func CreateMutableTarget(pubKey []byte, salt []byte) krpc.ID
- func DefaultDHTServer() *dht.Server
- func DoGet(server *dht.Server, target bep44.Target, salt []byte) ([]byte, error)
- func DownloadDag(root string)
- func Equals(nr *ws.NIP11RelayInfo, other *ws.NIP11RelayInfo) bool
- func GetScionicRoot(event *nostr.Event) (string, bool)
- func InitSyncDB(dbPath string) (*gorm.DB, error)
- func InitiateEventSync(stream network.Stream, filter nostr.Filter, hostId string, store stores.Store) error
- func LoadEventVector(events []*nostr.Event) (*negentropy.Vector, error)
- func MarshalRelay(nr ws.NIP11RelayInfo) ([]byte, error)
- func ParseURLs(input []byte) []string
- func PerformNIP11Request(url string) *ws.NIP11RelayInfo
- func PutDHTUploadable(db *gorm.DB, payload []byte, pubkey []byte, salt []byte, signature []byte) error
- func PutSyncAuthor(db *gorm.DB, publicKey string) error
- func PutSyncRelay(db *gorm.DB, publicKey string, relayInfo interface{}) error
- func SearchForRelays(d *dht.Server, maxRelays int, minIndex int, maxIndex int) ([]ws.NIP11RelayInfo, []int)
- func SendNegentropyMessage(hostId string, stream network.Stream, msgType string, filter nostr.Filter, ...) error
- func SetupNegentropyEventHandler(h host.Host, hostId string, store stores.Store)
- func SignPut(put *bep44.Put, privKey ed25519.PrivateKey) error
- type DHTUploadable
- type KeyPair
- type RelayStore
- func (rs *RelayStore) AddAuthor(authorPubkey string)
- func (rs *RelayStore) AddRelay(relay *ws.NIP11RelayInfo)
- func (rs *RelayStore) AddUploadable(payload string, pubkey string, salt string, signature string, uploadNow bool) error
- func (rs *RelayStore) DoPut(uploadable DHTUploadable) (krpc.ID, error)
- func (rs *RelayStore) GetRelayListFromDHT(dhtKey *string) ([]*ws.NIP11RelayInfo, error)
- func (rs *RelayStore) SyncWithRelay(relay *ws.NIP11RelayInfo, filter nostr.Filter)
- type SyncAuthor
- type SyncRelay
Constants ¶
const FrameSizeLimit = 4096
const IdSize = 32
const NegentropyProtocol = "/negentropy/1.0.0"
Variables ¶
var HardcodedKey = KeyPair{ PrivKey: []byte{ 0x51, 0x8d, 0x31, 0x74, 0x5e, 0x17, 0x14, 0x28, 0xf4, 0xbc, 0x5e, 0x2c, 0x88, 0xae, 0x2f, 0x36, 0x37, 0x7a, 0xc2, 0xf4, 0xd3, 0xe1, 0x38, 0x68, 0xac, 0xc6, 0x9f, 0x3f, 0x88, 0x99, 0x2b, 0xdb, 0x6b, 0x9f, 0x74, 0x78, 0x36, 0x89, 0x4f, 0xc2, 0xc6, 0xcd, 0xbe, 0x8d, 0xce, 0x52, 0xc1, 0xaf, 0xc1, 0xc9, 0x48, 0xb5, 0x72, 0xf0, 0xc6, 0x62, 0x3a, 0x07, 0xcf, 0x77, 0xb5, 0xb8, 0xf8, 0x7f, }, PubKey: []byte{ 0x6b, 0x9f, 0x74, 0x78, 0x36, 0x89, 0x4f, 0xc2, 0xc6, 0xcd, 0xbe, 0x8d, 0xce, 0x52, 0xc1, 0xaf, 0xc1, 0xc9, 0x48, 0xb5, 0x72, 0xf0, 0xc6, 0x62, 0x3a, 0x07, 0xcf, 0x77, 0xb5, 0xb8, 0xf8, 0x7f, }, }
used to make targets predictable
Functions ¶
func CheckSig ¶
func CheckSig(relay *ws.NIP11RelayInfo) error
func CreateMutableTarget ¶
CreateMutableTarget derives the target (dht-input) for a given pubKey and salt
func DefaultDHTServer ¶
func DefaultDHTServer() *dht.Server
func DownloadDag ¶
func DownloadDag(root string)
func Equals ¶
func Equals(nr *ws.NIP11RelayInfo, other *ws.NIP11RelayInfo) bool
func GetScionicRoot ¶
func InitSyncDB ¶
Helper function to initialize database connection
func InitiateEventSync ¶
func LoadEventVector ¶
func LoadEventVector(events []*nostr.Event) (*negentropy.Vector, error)
func MarshalRelay ¶
func MarshalRelay(nr ws.NIP11RelayInfo) ([]byte, error)
func PerformNIP11Request ¶
func PerformNIP11Request(url string) *ws.NIP11RelayInfo
PerformNIP11Request attempts to get NIP11 info from a given url
func PutDHTUploadable ¶
func PutDHTUploadable(db *gorm.DB, payload []byte, pubkey []byte, salt []byte, signature []byte) error
PutDHTUploadable adds or updates a DHTUploadable
func PutSyncAuthor ¶
PutSyncAuthor adds or updates a SyncAuthor
func PutSyncRelay ¶
PutSyncRelay adds or updates a SyncRelay
func SearchForRelays ¶
func SearchForRelays(d *dht.Server, maxRelays int, minIndex int, maxIndex int) ([]ws.NIP11RelayInfo, []int)
SearchForRelays searches salt-space for relays to sync with The target is derived from a hardcoded key (because it needs to be predictable) and an enumeration of possible salts "nostr:relay:%d" NOTE: this is not currently used outside of tests
func SendNegentropyMessage ¶
Types ¶
type DHTUploadable ¶
func GetDHTUploadables ¶
func GetDHTUploadables(db *gorm.DB) ([]DHTUploadable, error)
type RelayStore ¶
type RelayStore struct {
// contains filtered or unexported fields
}
RelayStore struct encapsulates the connection to the dht and the db where we store relay info It also handles syncing with other relays
func GetRelayStore ¶
func GetRelayStore() *RelayStore
func NewRelayStore ¶
func (*RelayStore) AddAuthor ¶
func (rs *RelayStore) AddAuthor(authorPubkey string)
AddAuthor adds a pubkey to the relay db
func (*RelayStore) AddRelay ¶
func (rs *RelayStore) AddRelay(relay *ws.NIP11RelayInfo)
AddRelay adds a given relay to the relay db
func (*RelayStore) AddUploadable ¶
func (rs *RelayStore) AddUploadable(payload string, pubkey string, salt string, signature string, uploadNow bool) error
AddUploadable saves an DHTUploadable to the relay db
func (*RelayStore) DoPut ¶
func (rs *RelayStore) DoPut(uploadable DHTUploadable) (krpc.ID, error)
DoPut takes a DHTUploadable and puts it on the DHT
func (*RelayStore) GetRelayListFromDHT ¶
func (rs *RelayStore) GetRelayListFromDHT(dhtKey *string) ([]*ws.NIP11RelayInfo, error)
GetRelayListFromDHT takes a dhtKey and asks the DHT for any data at the corresponding target It expects this data to be in the form of relay URLs, which we can later sync to
func (*RelayStore) SyncWithRelay ¶
func (rs *RelayStore) SyncWithRelay(relay *ws.NIP11RelayInfo, filter nostr.Filter)
SyncWithRelay will attempt to do a negentropy event sync with a relay specified by NIP11RelayInfo if the specified relay is not a hornet relay, then we do not try to sync
type SyncAuthor ¶
GORM models for sync / dht related structs
func GetSyncAuthors ¶
func GetSyncAuthors(db *gorm.DB) ([]SyncAuthor, error)