-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
splitting the code into multiple packages (wip)
- Loading branch information
Showing
39 changed files
with
255 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"crypto/sha256" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
json "encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
json "encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"encoding/json" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"crypto/rand" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
type ProfilePointer struct { | ||
PublicKey string `json:"pubkey"` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package core | ||
|
||
import "time" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package nostr | ||
|
||
import ( | ||
"github.com/nbd-wtf/go-nostr/core" | ||
"github.com/nbd-wtf/go-nostr/relays" | ||
"github.com/nbd-wtf/go-nostr/utils" | ||
) | ||
|
||
type ( | ||
Event core.Event | ||
Filter core.Filter | ||
Filters core.Filters | ||
Timestamp core.Timestamp | ||
Tag core.Tag | ||
TagMap core.TagMap | ||
|
||
ProfilePointer core.ProfilePointer | ||
EventPointer core.EventPointer | ||
EntityPointer core.EntityPointer | ||
|
||
AuthEnvelope core.AuthEnvelope | ||
OKEnvelope core.OKEnvelope | ||
NoticeEnvelope core.NoticeEnvelope | ||
EventEnvelope core.EventEnvelope | ||
CloseEnvelope core.CloseEnvelope | ||
ClosedEnvelope core.ClosedEnvelope | ||
CountEnvelope core.CountEnvelope | ||
EOSEEnvelope core.EOSEEnvelope | ||
ReqEnvelope core.ReqEnvelope | ||
Envelope core.Envelope | ||
|
||
Relay relays.Relay | ||
RelayOption relays.RelayOption | ||
SimplePool relays.SimplePool | ||
PoolOption relays.PoolOption | ||
Subscription relays.Subscription | ||
SubscriptionOption relays.SubscriptionOption | ||
IncomingEvent relays.IncomingEvent | ||
WithAuthHandler relays.WithAuthHandler | ||
WithLabel relays.WithLabel | ||
WithNoticeHandler relays.WithNoticeHandler | ||
|
||
RelayStore relays.RelayStore | ||
MultiStore relays.MultiStore | ||
) | ||
|
||
var ( | ||
Now = core.Now | ||
FilterEqual = core.FilterEqual | ||
GeneratePrivateKey = core.GeneratePrivateKey | ||
GetPublicKey = core.GetPublicKey | ||
IsValidPublicKey = core.IsValidPublicKey | ||
|
||
NewSimplePool = relays.NewSimplePool | ||
NewRelay = relays.NewRelay | ||
|
||
IsValid32ByteHex = utils.IsValid32ByteHex | ||
IsValidRelayURL = utils.IsValidRelayURL | ||
NormalizeOKMessage = utils.NormalizeOKMessage | ||
NormalizeURL = utils.NormalizeURL | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package relays | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package relays | ||
|
||
import ( | ||
"sync" | ||
"unsafe" | ||
) | ||
|
||
const MAX_LOCKS = 50 | ||
|
||
var namedMutexPool = make([]sync.Mutex, MAX_LOCKS) | ||
|
||
//go:noescape | ||
//go:linkname memhash runtime.memhash | ||
func memhash(p unsafe.Pointer, h, s uintptr) uintptr | ||
|
||
func namedLock(name string) (unlock func()) { | ||
sptr := unsafe.StringData(name) | ||
idx := uint64(memhash(unsafe.Pointer(sptr), 0, uintptr(len(name)))) % MAX_LOCKS | ||
l := &namedMutexPool[idx] | ||
l.Lock() | ||
return l.Unlock | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package relays | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package nostr | ||
package relays | ||
|
||
import ( | ||
"log" | ||
|
Oops, something went wrong.