repository

package
v0.0.0-...-3332e24 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BLOCK_COLLECT         = "block"
	TX_COLLECT            = "transaction"
	CONTRACT_META_COLLECT = "contract_meta"
	MONGO_URL             string
	DB_NAME               string
	ChainID               string
)
View Source
var MutexCollect = "mutex"

Functions

func CollectionItemNum

func CollectionItemNum(collect string) (count int, err error)

func Contract

func Contract(hash string) (contract Transaction, txs []Transaction, err error)

func ContractsCount

func ContractsCount() (int, error)

func CreateSqlite

func CreateSqlite() (err error)

func GetHTTPResp

func GetHTTPResp(url string) (bytez []byte, err error)

func Height

func Height() (maxHeight int, err error)

func Init

func Init()

func OneBlock

func OneBlock(hash string) (block Block, txs []Transaction, err error)

func OneBlockBySqlite

func OneBlockBySqlite(hash string) (block Block, txs []Transaction, err error)

func OneContract

func OneContract(hash string) (contract Transaction, txs []Transaction, err error)

func Save

func Save(br *BlockRepo) (err error)

func SaveBlockBySqlite

func SaveBlockBySqlite(blocks []Block) (err error)

func SaveContractMeta

func SaveContractMeta(meta ContractMeta) error

func SaveTxBySqlite

func SaveTxBySqlite(txs []Transaction) (err error)

func TryLock

func TryLock(owner string, long int) (bool, error)

func TxsCount

func TxsCount() (int, error)

Types

type Block

type Block struct {
	Hash            string
	ParentHash      string
	ChainID         string
	Height          int `bson:"_id"`
	Time            time.Time
	NumTxs          int
	LastCommitHash  string
	DataHash        string
	ValidatorsHash  string
	AppHash         string
	ProposerAddress string
}

func BlockByHeight

func BlockByHeight(height int) (block Block, err error)

func BlockByHeightBySqlite

func BlockByHeightBySqlite(height int) (block Block, err error)

func BlocksFromTo

func BlocksFromTo(from, to int) (blocks []Block, err error)

func BlocksFromToBySqlite

func BlocksFromToBySqlite(from, to int) (blocks []Block, err error)

func LatestBlocksBySqlite

func LatestBlocksBySqlite(limit int) (blocks []Block, err error)

type BlockRepo

type BlockRepo struct {
	Blocks []Block
	Txs    []Transaction
}

type ContractMeta

type ContractMeta struct {
	Hash string `json:"hash" bson:"_id"`
	ABI  string `json:"abi" bson:"abi"`
}

func OneContractMeta

func OneContractMeta(hash string) (meta *ContractMeta, err error)

type DBMutex

type DBMutex struct {
	Id           string `bson:"_id"`
	Owner        string `bson:"owner"`
	LastLockedAt int64  `bson:"last_locked_at"`
}

type DisplayItem

type DisplayItem struct {
	Block
	Tps      int
	Interval float64
}

func BlocksToDisplayItems

func BlocksToDisplayItems(blocks []Block, limit int) (items []DisplayItem)

func LatestBlocks

func LatestBlocks(limit int) (displayData []DisplayItem, err error)

type HTTPResponse

type HTTPResponse struct {
	JSONRPC string           `json:"jsonrpc"`
	ID      string           `json:"id"`
	Result  *json.RawMessage `json:"result"`
	Error   string           `json:"error"`
}

type NodeInfo

type NodeInfo struct {
	NetWork string `json:"network"`
}

type Repo

type Repo interface {
	Init()
	Save(br *BlockRepo) (err error)
	SaveContractMeta(meta ContractMeta) (err error)
	LatestBlocks(limit int) (displayData []DisplayItem, err error)
	BlocksFromTo(from, to int) (blocks []Block, err error)
	CollectionItemNum(collect string) (count int, err error)
	Contract(hash string) (tx Transaction, txs []Transaction, err error)
	Height() (maxHeight int, err error)
	Contracts(limit int) (txs []Transaction, err error)
	ContractsCount() (int, error)
	LatestContracts(limit int, skip int) (txs []Transaction, err error)
	TxsQuery(fromTo string) (txs []Transaction, err error)
	Txs(limit int) (txs []Transaction, err error)
	TxsCount() (int, error)
	LatestTxs(limit int, skip int) (txs []Transaction, err error)
	OneContract(hash string) (contract Transaction, txs []Transaction, err error)
	OneContractMeta(hash string) (*ContractMeta, error)
	OneTransaction(hash string) (tx Transaction, err error)
	TransactionsByBlkhash(hash string) (txs []Transaction, err error)
	TxsByBlkHeight(height int) (txs []Transaction, err error)
	TransactionFromTo(from, to int) (txs []Transaction, err error)
	BlockByHeight(height int) (block Block, err error)
	OneBlock(hash string) (block Block, txs []Transaction, err error)
}

type Status

type Status struct {
	NodeInfo          *NodeInfo `json:"node_info"`
	LatestBlockHeight int       `json:"latest_block_height"`
}

func GetStatus

func GetStatus(chainID string) (status Status)

type Transaction

type Transaction struct {
	Payload      []byte `json:"-"`
	PayloadHex   string
	ContractMeta ContractMeta `bson:"-"`
	Hash         string       `bson:"_id"`
	From         string
	To           string
	Receipt      string
	Amount       string
	Nonce        uint64
	Gas          string
	Size         int64
	Block        string
	Contract     string
	Time         time.Time
	Height       int
}

func LatestContracts

func LatestContracts(limit int, skip int) (txs []Transaction, err error)

func LatestTxs

func LatestTxs(limit int, skip int) (txs []Transaction, err error)

func OneTransaction

func OneTransaction(hash string) (tx Transaction, err error)

func OneTransactionBySqlite

func OneTransactionBySqlite(hash string) (tx Transaction, err error)

func TransactionFromTo

func TransactionFromTo(from, to int) (txs []Transaction, err error)

func TransactionFromToBySqlite

func TransactionFromToBySqlite(from, to int) (txs []Transaction, err error)

func TransactionsByBlkhash

func TransactionsByBlkhash(hash string) (txs []Transaction, err error)

func TransactionsByBlkhashBySqlite

func TransactionsByBlkhashBySqlite(hash string) (txs []Transaction, err error)

func Txs

func Txs(limit int) (txs []Transaction, err error)

func TxsByBlkHeight

func TxsByBlkHeight(height int) (txs []Transaction, err error)

func TxsQuery

func TxsQuery(fromTo string) (txs []Transaction, err error)

Jump to

Keyboard shortcuts

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