shared

package
v0.0.11-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPFS_PATH    = "IPFS_PATH"
	IPFS_MODE    = "IPFS_MODE"
	HTTP_TIMEOUT = "HTTP_TIMEOUT"

	ETH_WS_PATH       = "ETH_WS_PATH"
	ETH_HTTP_PATH     = "ETH_HTTP_PATH"
	ETH_NODE_ID       = "ETH_NODE_ID"
	ETH_CLIENT_NAME   = "ETH_CLIENT_NAME"
	ETH_GENESIS_BLOCK = "ETH_GENESIS_BLOCK"
	ETH_NETWORK_ID    = "ETH_NETWORK_ID"

	BTC_WS_PATH       = "BTC_WS_PATH"
	BTC_HTTP_PATH     = "BTC_HTTP_PATH"
	BTC_NODE_PASSWORD = "BTC_NODE_PASSWORD"
	BTC_NODE_USER     = "BTC_NODE_USER"
	BTC_NODE_ID       = "BTC_NODE_ID"
	BTC_CLIENT_NAME   = "BTC_CLIENT_NAME"
	BTC_GENESIS_BLOCK = "BTC_GENESIS_BLOCK"
	BTC_NETWORK_ID    = "BTC_NETWORK_ID"
)

Env variables

Variables

This section is empty.

Functions

func FetchIPLD

func FetchIPLD(tx *sqlx.Tx, cid string) ([]byte, error)

FetchIPLD is used to retrieve an ipld from Postgres blockstore with the provided tx

func GetBtcNodeAndClient

func GetBtcNodeAndClient(path string) (core.Node, *rpcclient.ConnConfig)

GetBtcNodeAndClient returns btc node info from path url

func GetEthNodeAndClient

func GetEthNodeAndClient(path string) (core.Node, *rpc.Client, error)

GetEthNodeAndClient returns eth node info and client from path url

func GetIPFSPath

func GetIPFSPath() (string, error)

GetIPFSPath returns the ipfs path from the config or env variable

func HandleNullAddr

func HandleNullAddr(to common.Address) string

HandleNullAddr will return an empty string for a a null address

func HandleNullAddrPointer

func HandleNullAddrPointer(to *common.Address) string

HandleNullAddrPointer will return an emtpy string for a nil address pointer

func IPLDsContainBytes

func IPLDsContainBytes(iplds []ipfs.BlockModel, b []byte) bool

IPLDsContainBytes used to check if a list of strings contains a particular string

func ListContainsGap

func ListContainsGap(gapList []Gap, gap Gap) bool

ListContainsGap used to check if a list of Gaps contains a particular Gap

func ListContainsString

func ListContainsString(sss []string, s string) bool

ListContainsString used to check if a list of strings contains a particular string

func MultihashKeyFromCIDString

func MultihashKeyFromCIDString(c string) (string, error)

MultihashKeyFromCIDString converts a cid string into a blockstore-prefixed multihash db key string

func PublishIPLD

func PublishIPLD(tx *sqlx.Tx, i node.Node) error

PublishIPLD is used to insert an ipld into Postgres blockstore with the provided tx

func PublishRaw

func PublishRaw(tx *sqlx.Tx, codec, mh uint64, raw []byte) (string, error)

PublishRaw derives a cid from raw bytes and provided codec and multihash type, and writes it to the db tx

func Rollback

func Rollback(tx *sqlx.Tx)

Rollback sql transaction and log any error

func SetupDB

func SetupDB() (*postgres.DB, error)

SetupDB is use to setup a db for super node tests

func SupportedDataType

func SupportedDataType(d DataType, c ChainType) (bool, error)

Types

type CIDIndexer

type CIDIndexer interface {
	Index(cids CIDsForIndexing) error
}

CIDIndexer indexes a CID payload in Postgres

type CIDRetriever

type CIDRetriever interface {
	Retrieve(filter SubscriptionSettings, blockNumber int64) ([]CIDsForFetching, bool, error)
	RetrieveFirstBlockNumber() (int64, error)
	RetrieveLastBlockNumber() (int64, error)
	RetrieveGapsInData(validationLevel int) ([]Gap, error)
}

CIDRetriever retrieves cids according to a provided filter and returns a CID wrapper

type CIDsForFetching

type CIDsForFetching interface{}

type CIDsForIndexing

type CIDsForIndexing interface{}

type ChainType

type ChainType int

ChainType enum for specifying blockchain

const (
	UnknownChain ChainType = iota
	Ethereum
	Bitcoin
	Omni
)

func NewChainType

func NewChainType(name string) (ChainType, error)

func (ChainType) API

func (c ChainType) API() string

func (ChainType) String

func (c ChainType) String() string

type Cleaner

type Cleaner interface {
	Clean(rngs [][2]uint64, t DataType) error
	ResetValidation(rngs [][2]uint64) error
}

Cleaner is for cleaning out data from the cache within the given ranges

type ClientSubscription

type ClientSubscription interface {
	Err() <-chan error
	Unsubscribe()
}

ClientSubscription is a general interface for chain data subscriptions

type ConvertedData

type ConvertedData interface {
	Height() int64
}

The concrete type underneath StreamedIPLDs should not be a pointer

type DataType

type DataType int

DataType is an enum to loosely represent type of chain data

const (
	UnknownDataType DataType = iota - 1
	Full
	Headers
	Uncles
	Transactions
	Receipts
	State
	Storage
)

func GenerateDataTypeFromString

func GenerateDataTypeFromString(str string) (DataType, error)

GenerateDataTypeFromString

func (DataType) String

func (r DataType) String() string

String() method to resolve ReSyncType enum

type Gap

type Gap struct {
	Start uint64
	Stop  uint64
}

type IPFSMode

type IPFSMode int

IPFSMode enum for specifying how we want to interface and publish objects to IPFS

const (
	Unknown IPFSMode = iota
	LocalInterface
	RemoteClient
	DirectPostgres
)

func GetIPFSMode

func GetIPFSMode() (IPFSMode, error)

GetIPFSMode returns the ipfs mode of operation from the config or env variable

func NewIPFSMode

func NewIPFSMode(name string) (IPFSMode, error)

func (IPFSMode) String

func (c IPFSMode) String() string

type IPLDFetcher

type IPLDFetcher interface {
	Fetch(cids CIDsForFetching) (IPLDs, error)
}

IPLDFetcher uses a CID wrapper to fetch an IPLD wrapper

type IPLDPublisher

type IPLDPublisher interface {
	Publish(payload ConvertedData) (CIDsForIndexing, error)
}

IPLDPublisher publishes IPLD payloads and returns a CID payload for indexing

type IPLDs

type IPLDs interface {
	Height() int64
}

type PayloadConverter

type PayloadConverter interface {
	Convert(payload RawChainData) (ConvertedData, error)
}

PayloadConverter converts chain-specific payloads into IPLD payloads for publishing

type PayloadFetcher

type PayloadFetcher interface {
	FetchAt(blockHeights []uint64) ([]RawChainData, error)
}

PayloadFetcher fetches chain-specific payloads

type PayloadStreamer

type PayloadStreamer interface {
	Stream(payloadChan chan RawChainData) (ClientSubscription, error)
}

PayloadStreamer streams chain-specific payloads to the provided channel

type RawChainData

type RawChainData interface{}

These types serve as very loose wrappers around a generic underlying interface{}

type ResponseFilterer

type ResponseFilterer interface {
	Filter(filter SubscriptionSettings, payload ConvertedData) (response IPLDs, err error)
}

ResponseFilterer applies a filter to an IPLD payload to return a subscription response packet

type SubscriptionSettings

type SubscriptionSettings interface {
	StartingBlock() *big.Int
	EndingBlock() *big.Int
	ChainType() ChainType
	HistoricalData() bool
	HistoricalDataOnly() bool
}

SubscriptionSettings is the interface every subscription filter type needs to satisfy, no matter the chain Further specifics of the underlying filter type depend on the internal needs of the types which satisfy the ResponseFilterer and CIDRetriever interfaces for a specific chain The underlying type needs to be rlp serializable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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