minersync

package
v0.0.0-...-7ee7fde Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: Apache-2.0 Imports: 15 Imported by: 2

Documentation

Overview

Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Copyright (c) 2018-2020. The asimov developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddressFromBitcoinAddress

func NewAddressFromBitcoinAddress(hex string, addrType int32) (*common.Address, error)

NewAddressFromBitcoinAddress returns a new Address using the hex of btc address and type of btc address.

Types

type BtcClient

type BtcClient struct {
	// contains filtered or unexported fields
}

BtcClient implements the IBtcClient interface and represents a connection to an RPC server.

func NewBtcClient

func NewBtcClient() (*BtcClient, error)

NewBtcClient returns a new BtcClient using the active net params.

func NewBtcClientWithParams

func NewBtcClientWithParams(params *chaincfg.Params) (*BtcClient, error)

NewBtcClientWithParams returns a new BtcClient using the net params.

func (*BtcClient) Call

func (c *BtcClient) Call(result interface{}, method string, args ...interface{}) error

Call call an rpc request to bitcoin service, and switch target bitcoin server when it failed.

func (*BtcClient) GetBitcoinBlockChainInfo

func (c *BtcClient) GetBitcoinBlockChainInfo(result interface{}) error

GetBitcoinBlockChainInfo call getblockchaininfo to bitcoin service.

func (*BtcClient) GetBitcoinMinerInfo

func (c *BtcClient) GetBitcoinMinerInfo(result interface{}, height, count int32) error

GetBitcoinMinerInfo call listblockminerinfo to bitcoin service.

func (*BtcClient) SwitchClient

func (c *BtcClient) SwitchClient() error

SwitchClient switch target bitcoin server.

type BtcPowerCollector

type BtcPowerCollector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

BtcPowerCollector is a collector for collect bitcoin power. It fetch the miner information from bitcoin and saves it in the database.

func NewBtcPowerCollector

func NewBtcPowerCollector(c ainterface.IBtcClient, db database.Transactor) *BtcPowerCollector

NewBtcPowerCollector returns a new BtcPowerCollector using the bitcoin client and database.

func (*BtcPowerCollector) GetBitcoinMiner

func (bpc *BtcPowerCollector) GetBitcoinMiner(height, count int32) ([]*MinerInfo, error)

GetBitcoinMinerread fetch miner information from cache or database, the read range is height to height add count.

This function is safe for concurrent access.

func (*BtcPowerCollector) GetMinerName

func (bpc *BtcPowerCollector) GetMinerName(miner string) string

GetMinerName returns pool name of the miner. if not miner not find, return empty string.

func (*BtcPowerCollector) Halt

func (bpc *BtcPowerCollector) Halt() error

Halt ends fetch the miner information from bitcoin.

func (*BtcPowerCollector) Init

func (bpc *BtcPowerCollector) Init(height, count int32) ([]*MinerInfo, error)

Init read old miner information from database and fetch the miner information from bitcoin when the count not enough.

func (*BtcPowerCollector) Start

func (bpc *BtcPowerCollector) Start() error

Start begins fetch the miner information from bitcoin.

func (*BtcPowerCollector) UpdateMinerInfo

func (bpc *BtcPowerCollector) UpdateMinerInfo(count int32) ([]*MinerInfo, int32, error)

UpdateMinerInfo fetch the miner information about the number of count from bitcoin.

type BtcValidatorTx

type BtcValidatorTx struct {
	Txid        string   `json:"txid"`
	Vin         []string `json:"vin"`
	OutAddress  string   `json:"outAddress"`
	AddressType int32    `json:"addressType"`
}

BtcValidatorTx models the validatorTxs field of the listblockminerinfo command.

type GetBitcoinBlockMinerInfoResult

type GetBitcoinBlockMinerInfoResult struct {
	Height       int32            `json:"height"`
	Pool         string           `json:"pool"`
	Hash         string           `json:"hash"`
	Time         uint32           `json:"time"`
	Address      string           `json:"address"`
	ValidatorTxs []BtcValidatorTx `json:"ValidatorTxs"`
}

GetBitcoinBlockMinerInfoResult models the data returned from the listblockminerinfo command.

type GetBlockChainInfoResult

type GetBlockChainInfoResult struct {
	Chain         string `json:"chain"`
	Blocks        int32  `json:"blocks"`
	BestBlockHash string `json:"bestblockhash"`
}

GetBlockChainInfoResult models the data returned from the getblockchaininfo command.

type MinerInfo

type MinerInfo struct {
	// contains filtered or unexported fields
}

MinerInfo is the detail of collect bitcoin power.

func (*MinerInfo) Address

func (mi *MinerInfo) Address() string

Address returns mining address of this bitcoin block.

func (*MinerInfo) Deserialize

func (mi *MinerInfo) Deserialize(r io.Reader) (err error)

Deserialize decodes miner info from r into the receiver using a format that is suitable for long-term storage such as a database.

func (*MinerInfo) Name

func (mi *MinerInfo) Name() string

Name returns pool name of this bitcoin block.

func (*MinerInfo) Serialize

func (mi *MinerInfo) Serialize(w io.Writer) error

Serialize encodes miner info from w into the receiver using a format that is suitable for long-term storage such as a database.

func (*MinerInfo) SerializeSize

func (mi *MinerInfo) SerializeSize() int

SerializeSize returns the number of bytes it would take to serialize the miner info.

func (*MinerInfo) Time

func (mi *MinerInfo) Time() uint32

Time returns time of this bitcoin block.

func (*MinerInfo) ValidatorTxs

func (mi *MinerInfo) ValidatorTxs() []*ValidatorTx

ValidatorTxs returns the candidates for mapped transactions.

type ValidatorTx

type ValidatorTx struct {
	TxId       string
	Vin        []string
	OutAddress common.Address
}

ValidatorTx is a candidate for mapped transactions.

Jump to

Keyboard shortcuts

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