indexer

package
v0.0.0-...-14266a6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2017 License: GPL-3.0 Imports: 11 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 resyncs the data if the process dies.

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

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

func StartIndexer

func StartIndexer(confs []blockstack.ServerConfig)

StartIndexer returns a Indexer

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

type Claim

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

Claim contains social proofs and images

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"`
	Address       string         `json:"address"`
	Zonefile      *Zonefile      `json:"zonefile"`
	Profile       *Profile       `json:"profile"`
	LegacyProfile *LegacyProfile `json:"legacy_profile"`
	// contains filtered or unexported fields
}

Domain models a Blockstack domain name

func NewDomain

func NewDomain(name string, zonefile 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(sem chan struct{})

ResolveProfile takes an initialized domain and fetches the resulting profile for that 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 {
	StartBlock       int
	CurrentBlock     int
	Names            []*Domain
	ExpectedNames    int
	NameZonefileHash map[string]string

	sync.Mutex
	// contains filtered or unexported fields
}

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

func (*Indexer) Client

func (i *Indexer) Client() *blockstack.Client

Client provides a convinent interface to loop through provided multiple clients

func (*Indexer) GetZonefilesByBlock

func (i *Indexer) GetZonefilesByBlock(startBlock, endBlock int)

GetZonefilesByBlock returns a map[name]zonefile TODO: Parallelize - difficult, need to keep blocks in order. Maybe hold off on this

type LegacyProfile

type LegacyProfile struct {
	Account []struct {
		Type       string `json:"@type"`
		Identifier string `json:"identifier"`
		Service    string `json:"service"`
	} `json:"account"`
	Avatar struct {
		URL string `json:"url"`
	} `json:"avatar"`
	Bio     string `json:"bio"`
	Bitcoin struct {
		Address string `json:"address"`
	} `json:"bitcoin"`
	Cover struct {
		URL string `json:"url"`
	} `json:"cover"`
	Facebook struct {
		Proof struct {
			URL string `json:"url"`
		} `json:"proof"`
		Username string `json:"username"`
	} `json:"facebook"`
	Github struct {
		Proof struct {
			URL string `json:"url"`
		} `json:"proof"`
		Username string `json:"username"`
	} `json:"github"`
	Linkedin struct {
		URL string `json:"url"`
	} `json:"linkedin"`
	Location struct {
		Formatted string `json:"formatted"`
	} `json:"location"`
	Name struct {
		Formatted string `json:"formatted"`
	} `json:"name"`
	Pgp struct {
		Fingerprint string `json:"fingerprint"`
		URL         string `json:"url"`
	} `json:"pgp"`
	Twitter struct {
		Proof struct {
			URL string `json:"url"`
		} `json:"proof"`
		Username string `json:"username"`
	} `json:"twitter"`
	V       string `json:"v"`
	Website string `json:"website"`
}

LegacyProfile models a zonefile that holds the full profile format

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 struct {
	Token           string       `json:"token"`
	ParentPublicKey string       `json:"parentPublicKey"`
	Encrypted       bool         `json:"encrypted"`
	DecodedToken    DecodedToken `json:"decodedToken"`
}

Profile models a blockstack profile

type PublicKey

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

PublicKey models {publicKey: "030ec5101181a8e528b70141b0cde18fda231ab1be5f166e49f813c63914f4ebc8"}

type Zonefile

type Zonefile struct {
	Raw string   `json:"raw"`
	RRs []dns.RR `json:"RRs"`
	// contains filtered or unexported fields
}

Zonefile models a Zonefile

Jump to

Keyboard shortcuts

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