shared

package
v0.7.1-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxBatchSize   uint64 = 100
	DefaultMaxBatchNumber int64  = 50
)
View Source
const (
	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"
	ETH_CHAIN_ID      = "ETH_CHAIN_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 and cid string

func FetchIPLDByMhKey

func FetchIPLDByMhKey(tx *sqlx.Tx, mhKey string) ([]byte, error)

FetchIPLDByMhKey is used to retrieve an ipld from Postgres blockstore with the provided tx and mhkey string

func GetEthNodeAndClient

func GetEthNodeAndClient(path string) (node.Info, *rpc.Client, error)

GetEthNodeAndClient returns eth node info and client from path url

func HandleZeroAddr

func HandleZeroAddr(to common.Address) string

HandleZeroAddr will return an empty string for a 0 value address

func HandleZeroAddrPointer

func HandleZeroAddrPointer(to *common.Address) string

HandleZeroAddrPointer will return an emtpy string for a nil address pointer

func ListContainsString

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

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

func MultihashKeyFromCID

func MultihashKeyFromCID(c cid.Cid) string

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

func MultihashKeyFromCIDString

func MultihashKeyFromCIDString(c string) (string, error)

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

func MultihashKeyFromKeccak256

func MultihashKeyFromKeccak256(hash common.Hash) (string, error)

MultihashKeyFromKeccak256 converts keccak256 hash bytes into a blockstore-prefixed multihash db key string

func PublishDirect

func PublishDirect(tx *sqlx.Tx, key string, value []byte) error

PublishDirect diretly writes a previously derived mhkey => value pair to the ipld database

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 PublishMockIPLD

func PublishMockIPLD(db *postgres.DB, mhKey string, mockData []byte) error

PublishMockIPLD writes a mhkey-data pair to the public.blocks table so that test data can FK reference the mhkey

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 watcher tests

func SetupDBWithNode

func SetupDBWithNode(node node.Info) (*postgres.DB, error)

func SupportedDataType

func SupportedDataType(d DataType) (bool, error)

func TestCID

func TestCID(b []byte) cid.Cid

TestCID creates a basic CID for testing purposes

Types

type ChainType

type ChainType int

ChainType enum for specifying blockchain

const (
	UnknownChain ChainType = iota
	Ethereum
	Bitcoin
	Omni
	EthereumClassic
)

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 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

Jump to

Keyboard shortcuts

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