indexer

package
v0.0.0-...-1f897c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

README

Blockstack Indexer

The resolver runs through all the names in the Blockstack network, pulls their Zonefiles and resolves their profiles by fetching the data there. It persists this data in a Mongodb instance to survive restarts and re-syncs the data if the process dies.

The blockstack api runs an instance of the indexer to help manage responses. The resolver also has the database connection.

Implement Retries for the following methods:

Sample Subdomain record:

created_equal.self_evident_truth.id.	3600	IN	TXT	"owner=1AYddAnfHbw6bPNvnsQFFrEuUdhMhf2XG9" "seqn=0" "parts=1" "zf0=JE9SSUdJTiBjcmVhdGVkX2VxdWFsCiRUVEwgMzYwMApfaHR0cHMuX3RjcCBVUkkgMTAgMSAiaHR0cHM6Ly93d3cuY3MucHJpbmNldG9uLmVkdS9+YWJsYW5rc3QvY3JlYXRlZF9lcXVhbC5qc29uIgpfZmlsZSBVUkkgMTAgMSAiZmlsZTovLy90bXAvY3JlYXRlZF9lcXVhbC5qc29uIgo="

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Type       string `json:"@type"`
	Service    string `json:"service"`
	ProofType  string `json:"proofType"`
	Identifier string `json:"identifier"`
	ProofURL   string `json:"proofUrl"`
}

Account models a social media proof TODO: Write method on Account to check proof

type Claim

type Claim struct {
	Type    string    `json:"@type"`
	Image   []Image   `json:"image"`
	Account []Account `json:"account"`
}

Claim contains social proofs and images

type Config

type Config struct {
	URLs                 []string
	IndexMethod          string
	NamePageWorkers      int
	ResolveWorkers       int
	ConcurrentPageFetch  int
	ClientUpdateInterval int
	DBBatchSize          int
	DBWorkers            int
	MongoConnection      string

	sync.Mutex
	// contains filtered or unexported fields
}

Config is a config object for the Indexer

func (*Config) SetClients

func (c *Config) SetClients()

SetClients takes the configured URLs and returns only the blockstack-core nodes that are in consensus

func (*Config) String

func (c *Config) String() string

type DecodedProfileToken

type DecodedProfileToken struct {
	Payload   string `json:"payload"`
	Protected string `json:"protected"`
	Signature string `json:"signature"`
}

func NewDecodedProfileToken

func NewDecodedProfileToken(pt string) *DecodedProfileToken

func (*DecodedProfileToken) DecodedPayload

func (dpt *DecodedProfileToken) DecodedPayload() *DecodedProfileTokenPayload

type DecodedProfileTokenPayload

type DecodedProfileTokenPayload struct {
	IssuedAt  string `json:"issuedAt,omitempty"`
	Claim     Claim
	ExpiresAt string `json:"expiresAt,omitempty"`
	Issuer    PublicKey
	Subject   PublicKey
	Jti       string    `json:"jti,omitempty"`
	Iat       time.Time `json:"iat,omitempty"`
	Exp       time.Time `json:"exp,omitempty"`
}

type DecodedToken

type DecodedToken struct {
	Payload   Payload `json:"payload"`
	Signature string  `json:"signature"`
	Header    Header  `json:"header"`
}

DecodedToken contains most of the profile information

type Domain

type Domain struct {
	Name             string                                   `json:"name"`
	Zonefile         *Zonefile                                `json:"zonefile"`
	Profile          Profile                                  `json:"profile"`
	BlockchainRecord blockstack.GetNameBlockchainRecordResult `json:"blockchainRecord"`
	// contains filtered or unexported fields
}

Domain models a Blockstack domain name

func NewDomain

func NewDomain(name string) *Domain

NewDomain returns an initialized Domain

func (*Domain) AddZonefile

func (d *Domain) AddZonefile(zonefile string)

AddZonefile takes a string representation of a Zonefile and parses out some info

func (*Domain) GetURI

func (d *Domain) GetURI() *dns.URI

GetURI returns the first URI with a Target starting with http

func (*Domain) JSON

func (d *Domain) JSON() string

JSON returns the JSON representation of Domain

func (*Domain) ResolveProfile

func (d *Domain) ResolveProfile()

ResolveProfile takes an initialized domain and fetches the resulting profile for that domain TODO: Make this fail early and often to prevent bottleneck also this basically doesn't work

type Domains

type Domains []*Domain

Domains is a collection of *Domain

type Header struct {
	Typ string `json:"typ"`
	Alg string `json:"alg"`
}

Header describes the encryption types

type Image

type Image struct {
	Type       string `json:"@type"`
	ContentURL string `json:"contentUrl"`
	Name       string `json:"name"`
}

Image models a Profile Image

type Indexer

type Indexer struct {
	CurrentBlock  int
	ExpectedNames int
	Config        *Config
	// contains filtered or unexported fields
}

The Indexer talks to blockstack-core and resolves all the domains and subdomains - hopefully

func NewIndexer

func NewIndexer(conf *Config) *Indexer

NewIndexer returns a new *Indexer

func (*Indexer) GetAllNamespaces

func (i *Indexer) GetAllNamespaces()

GetAllNamespaces implements retries for the RPC method

func (*Indexer) GetCB

func (i *Indexer) GetCB() int

GetCB reads the current block in a goroutine safe manner

func (*Indexer) GetNameAt

func (i *Indexer) GetNameAt()

GetNameAt implements retries for the RPC method

func (*Indexer) GetNamesInNamespace

func (i *Indexer) GetNamesInNamespace()

GetNamesInNamespace implements retries for the RPC method

func (*Indexer) GetNumNamesInNamespace

func (i *Indexer) GetNumNamesInNamespace()

GetNumNamesInNamespace implements retries for the RPC method

func (*Indexer) GetZonefiles

func (i *Indexer) GetZonefiles()

GetZonefiles implements retries for the RPC method

func (*Indexer) Start

func (i *Indexer) Start()

Start runs the Indexer

type LProof

type LProof struct {
	Proof    map[string]string `json:"proof"`
	Username string            `json:"username"`
}

LProof is a legacy proof

type LegacyProfile

type LegacyProfile struct {
	Account  []map[string]string `json:"account"`
	Avatar   map[string]string   `json:"avatar"`
	Bio      string              `json:"bio"`
	Bitcoin  map[string]string   `json:"bitcoin"`
	Cover    map[string]string   `json:"cover"`
	Facebook LProof              `json:"facebook"`
	Github   LProof              `json:"github"`
	Linkedin map[string]string   `json:"linkedin"`
	Location map[string]string   `json:"location"`
	Name     map[string]string   `json:"name"`
	Pgp      map[string]string   `json:"pgp"`
	Twitter  LProof              `json:"twitter"`
	V        string              `json:"v"`
	Website  string              `json:"website"`
}

LegacyProfile models a zonefile that holds the full profile format

func (LegacyProfile) JSON

func (p LegacyProfile) JSON() string

JSON statisfiles the Profile interface

func (LegacyProfile) Validate

func (lp LegacyProfile) Validate() bool

type Payload

type Payload struct {
	Claim     Claim     `json:"claim"`
	IssuedAt  string    `json:"issuedAt"`
	Subject   PublicKey `json:"subject"`
	Issuer    PublicKey `json:"issuer"`
	ExpiresAt string    `json:"expiresAt"`
}

Payload contains social media claim info and other

type Profile

type Profile interface {
	JSON() string
	Validate() bool
}

Profile is an interface to wrap Schema.org profiles and LegacyProfiles

type PublicKey

type PublicKey struct {
	PublicKey string `json:"publicKey"`
}

PublicKey models {publicKey: "030ec5101181a8e528b70141b0cde18fda231ab1be5f166e49f813c63914f4ebc8"}

type SOProfile

type SOProfile struct {
	Token           string       `json:"token"`
	ParentPublicKey string       `json:"parentPublicKey"`
	Encrypted       bool         `json:"encrypted"`
	DecodedToken    DecodedToken `json:"decodedToken"`
}

SOProfile models a Schema.org profile

func (SOProfile) JSON

func (p SOProfile) JSON() string

JSON statisfiles the Profile interface

func (SOProfile) Validate

func (so SOProfile) Validate() bool

type Zonefile

type Zonefile struct {
	Raw string   `json:"raw"`
	RRs []dns.RR `json:"RRs"`

	Compliant bool
}

Zonefile models a Zonefile

func (*Zonefile) GetURI

func (zf *Zonefile) GetURI() *dns.URI

GetURI returns the first URI with a Target starting with http

func (*Zonefile) JSON

func (zf *Zonefile) JSON() []byte

JSON representation of a Zonefile

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL