mirror of
https://github.com/status-im/status-go.git
synced 2025-01-20 03:30:24 +00:00
eeca435064
Update vendor Integrate rendezvous into status node Add a test with failover using rendezvous Use multiple servers in client Use discovery V5 by default and test that node can be started with rendezvous discovet Fix linter Update rendezvous client to one with instrumented stream Address feedback Fix test with updated topic limits Apply several suggestions Change log to debug for request errors because we continue execution Remove web3js after rebase Update rendezvous package
37 lines
734 B
Go
37 lines
734 B
Go
package host
|
|
|
|
import (
|
|
"strings"
|
|
|
|
semver "github.com/coreos/go-semver/semver"
|
|
"github.com/libp2p/go-libp2p-protocol"
|
|
)
|
|
|
|
func MultistreamSemverMatcher(base protocol.ID) (func(string) bool, error) {
|
|
parts := strings.Split(string(base), "/")
|
|
vers, err := semver.NewVersion(parts[len(parts)-1])
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return func(check string) bool {
|
|
chparts := strings.Split(check, "/")
|
|
if len(chparts) != len(parts) {
|
|
return false
|
|
}
|
|
|
|
for i, v := range chparts[:len(chparts)-1] {
|
|
if parts[i] != v {
|
|
return false
|
|
}
|
|
}
|
|
|
|
chvers, err := semver.NewVersion(chparts[len(chparts)-1])
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
return vers.Major == chvers.Major && vers.Minor >= chvers.Minor
|
|
}, nil
|
|
}
|