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 ¶
- func NewAddressFromBitcoinAddress(hex string, addrType int32) (*common.Address, error)
- type BtcClient
- type BtcPowerCollector
- func (bpc *BtcPowerCollector) GetBitcoinMiner(height, count int32) ([]*MinerInfo, error)
- func (bpc *BtcPowerCollector) GetMinerName(miner string) string
- func (bpc *BtcPowerCollector) Halt() error
- func (bpc *BtcPowerCollector) Init(height, count int32) ([]*MinerInfo, error)
- func (bpc *BtcPowerCollector) Start() error
- func (bpc *BtcPowerCollector) UpdateMinerInfo(count int32) ([]*MinerInfo, int32, error)
- type BtcValidatorTx
- type GetBitcoinBlockMinerInfoResult
- type GetBlockChainInfoResult
- type MinerInfo
- func (mi *MinerInfo) Address() string
- func (mi *MinerInfo) Deserialize(r io.Reader) (err error)
- func (mi *MinerInfo) Name() string
- func (mi *MinerInfo) Serialize(w io.Writer) error
- func (mi *MinerInfo) SerializeSize() int
- func (mi *MinerInfo) Time() uint32
- func (mi *MinerInfo) ValidatorTxs() []*ValidatorTx
- type ValidatorTx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
NewBtcClient returns a new BtcClient using the active net params.
func NewBtcClientWithParams ¶
NewBtcClientWithParams returns a new BtcClient using the net params.
func (*BtcClient) Call ¶
Call call an rpc request to bitcoin service, and switch target bitcoin server when it failed.
func (*BtcClient) GetBitcoinBlockChainInfo ¶
GetBitcoinBlockChainInfo call getblockchaininfo to bitcoin service.
func (*BtcClient) GetBitcoinMinerInfo ¶
GetBitcoinMinerInfo call listblockminerinfo to bitcoin service.
func (*BtcClient) SwitchClient ¶
SwitchClient switch target bitcoin server.
type BtcPowerCollector ¶
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) Deserialize ¶
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) Serialize ¶
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 ¶
SerializeSize returns the number of bytes it would take to serialize the miner info.
func (*MinerInfo) ValidatorTxs ¶
func (mi *MinerInfo) ValidatorTxs() []*ValidatorTx
ValidatorTxs returns the candidates for mapped transactions.