Documentation
¶
Index ¶
- Constants
- func AddIndividualTermFields(q *elastic.BoolQuery, arr []string, name string, invert bool) *elastic.BoolQuery
- func AddInvertibleField(q *elastic.BoolQuery, field *pb.InvertibleField, name string) *elastic.BoolQuery
- func AddRangeField(q *elastic.BoolQuery, rqs []*pb.RangeField, name string) *elastic.BoolQuery
- func AddTermField(q *elastic.BoolQuery, value string, name string) *elastic.BoolQuery
- func AddTermsField(q *elastic.BoolQuery, arr []string, name string) *elastic.BoolQuery
- func AddTermsFieldInt32(q *elastic.BoolQuery, arr []int32, name string) *elastic.BoolQuery
- func EncodeAddress(addr string) []byte
- func GetEnvironment(data []string, getkeyval func(item string) (key, val string)) map[string]string
- func GetEnvironmentStandard() map[string]string
- func Int32ArrToInterface(arr []int32) []interface{}
- func RoundUpReleaseTime(q *elastic.BoolQuery, rqs []*pb.RangeField, name string) *elastic.BoolQuery
- func StrArrToInterface(arr []string) []interface{}
- func UDPServer(args *Args) error
- type Args
- type Peer
- type SPVPing
- type SPVPong
- type Server
- func (s *Server) AddPeer(ctx context.Context, args *pb.ServerMessage) (*pb.StringValue, error)
- func (s *Server) Hello(ctx context.Context, args *pb.HelloMessage) (*pb.HelloMessage, error)
- func (s *Server) PeerServersLoadOrStore(peer *Peer) (actual *Peer, loaded bool)
- func (s *Server) PeerSubsLoadOrStore(peer *Peer) (actual *Peer, loaded bool)
- func (s *Server) PeerSubscribe(ctx context.Context, in *pb.ServerMessage) (*pb.StringValue, error)
- func (s *Server) Ping(ctx context.Context, args *pb.EmptyMessage) (*pb.StringValue, error)
- func (s *Server) Run()
- func (s *Server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.Outputs, error)
- func (s *Server) Version(ctx context.Context, args *pb.EmptyMessage) (*pb.StringValue, error)
Constants ¶
const ( ServeCmd = iota SearchCmd = iota )
const ( DefaultHost = "0.0.0.0" DefaultPort = "50051" DefaultEsHost = "http://localhost" DefaultEsIndex = "claims" DefaultEsPort = "9200" DefaultPrometheusPort = "2112" DefaultRefreshDelta = 5 DefaultCacheTTL = 5 DefaultPeerFile = "peers.txt" DefaultCountry = "US" DefaultDisableLoadPeers = false DefaultDisableStartPrometheus = false DefaultDisableStartUDP = false DefaultDisableWritePeers = false DefaultDisableFederation = false )
const DefaultSearchSize = 1000
DefaultSearchSize is the default max number of items an es search will return.
Variables ¶
This section is empty.
Functions ¶
func AddIndividualTermFields ¶
func AddIndividualTermFields(q *elastic.BoolQuery, arr []string, name string, invert bool) *elastic.BoolQuery
AddIndividualTermFields takes a bool query, an array of string values a term name, and a bool to invert the query, and adds multiple individual TermQuerys for that name matching each of the values.
func AddInvertibleField ¶
func AddInvertibleField(q *elastic.BoolQuery, field *pb.InvertibleField, name string) *elastic.BoolQuery
AddInvertibleField takes a bool query, an invertible field and a term name and adds a term query for that name matching that invertible field.
func AddRangeField ¶
AddRangeField takes a bool query, a range field struct and a term name and adds a term query for that name matching that range field.
func AddTermField ¶
AddTermField takes an es bool query, a string value and a term name and adds a TermQuery for that name matching that value to the bool query.
func AddTermsField ¶
AddTermsField takes an es bool query, array of string values and a term name and adds a TermsQuery for that name matching those values to the bool query.
func AddTermsFieldInt32 ¶
AddTermsFieldInt32 takes an es bool query, array of int32 values and a term name and adds a TermsQuery for that name matching those values to the bool query.
func EncodeAddress ¶
EncodeAddress takes an ipv4 address and encodes it into bytes for the hub Ping/Pong protocol.
func GetEnvironment ¶
GetEnvironment takes the environment variables as an array of strings and a getkeyval function to turn it into a map.
func GetEnvironmentStandard ¶
GetEnvironmentStandard gets the environment variables as a map.
func Int32ArrToInterface ¶
func Int32ArrToInterface(arr []int32) []interface{}
Int32ArrToInterface takes an array of int32 and returns them as an array of interfaces.
func RoundUpReleaseTime ¶
RoundUpReleaseTime take a bool query, a range query and a term name and adds a term query for that name (this is for the release time field) with the value rounded up.
func StrArrToInterface ¶
func StrArrToInterface(arr []string) []interface{}
StrArrToInterface takes an array of strings and returns them as an array of interfaces.
Types ¶
type Args ¶
type Args struct {
CmdType int
Host string
Port string
EsHost string
EsPort string
PrometheusPort string
EsIndex string
RefreshDelta int
CacheTTL int
PeerFile string
Country string
DisableEs bool
Debug bool
DisableLoadPeers bool
DisableStartPrometheus bool
DisableStartUDP bool
DisableWritePeers bool
DisableFederation bool
}
Args struct contains the arguments to the hub server.
func ParseArgs ¶
func ParseArgs(searchRequest *pb.SearchRequest) *Args
ParseArgs parses the command line arguments when started the hub server.
type SPVPing ¶
type SPVPing struct {
// contains filtered or unexported fields
}
SPVPing is a struct for the format of how to ping another hub over udp. format b'!lB64s'
type SPVPong ¶
type SPVPong struct {
// contains filtered or unexported fields
}
SPVPong is a struct for the return pong from another hub server. format b'!BBL32s4sH'
func (*SPVPong) DecodeAddress ¶
DecodeAddress gets the string ipv4 address from an SPVPong struct.
func (*SPVPong) DecodeCountry ¶
func (*SPVPong) DecodeFlags ¶
func (*SPVPong) DecodeHeight ¶
func (*SPVPong) DecodeProtocolVersion ¶
type Server ¶
type Server struct {
GrpcServer *grpc.Server
Args *Args
MultiSpaceRe *regexp.Regexp
WeirdCharsRe *regexp.Regexp
EsClient *elastic.Client
QueryCache *ttlcache.Cache
S256 *hash.Hash
LastRefreshCheck time.Time
RefreshDelta time.Duration
NumESRefreshes int64
PeerServers map[string]*Peer
PeerServersMut sync.RWMutex
NumPeerServers *int64
PeerSubs map[string]*Peer
PeerSubsMut sync.RWMutex
NumPeerSubs *int64
ExternalIP net.IP
pb.UnimplementedHubServer
}
func MakeHubServer ¶
MakeHubServer takes the arguments given to a hub when it's started and initializes everything. It loads information about previously known peers, creates needed internal data structures, and initializes goroutines.
func (*Server) AddPeer ¶
func (s *Server) AddPeer(ctx context.Context, args *pb.ServerMessage) (*pb.StringValue, error)
AddPeer is a grpc endpoint to tell this hub about another hub in the network.
func (*Server) Hello ¶
func (s *Server) Hello(ctx context.Context, args *pb.HelloMessage) (*pb.HelloMessage, error)
Hello is a grpc endpoint to allow another hub to tell us about itself. The passed message includes information about the other hub, and all of its peers which are added to the knowledge of this hub.
func (*Server) PeerServersLoadOrStore ¶
func (*Server) PeerSubsLoadOrStore ¶
func (*Server) PeerSubscribe ¶
func (s *Server) PeerSubscribe(ctx context.Context, in *pb.ServerMessage) (*pb.StringValue, error)
PeerSubscribe adds a peer hub to the list of subscribers to update about new peers.
func (*Server) Ping ¶
func (s *Server) Ping(ctx context.Context, args *pb.EmptyMessage) (*pb.StringValue, error)
Ping is a grpc endpoint that returns a short message.
func (*Server) Search ¶
Search /* Search logic is as follows: 1) Setup query with params given 2) Do query with limit of 1000 3) remove blocked content (these are returned separately) 4) remove duplicates (these are not returned) 5) limit claims per channel logic 6) get claims referenced by reposts 7) get channels references by claims and repost claims 8) return streams referenced by repost and all channel referenced in extra_txos */
func (*Server) Version ¶
func (s *Server) Version(ctx context.Context, args *pb.EmptyMessage) (*pb.StringValue, error)
Version is a grpc endpoint to get this hub's version.