Documentation
¶
Index ¶
- Variables
- func BuildBlockTryAppend(chain *Chain, tx_pool *TxPool, proposer func(Block))
- func StartMining(chain *Chain, tx_pool *TxPool, proposer func(Block))
- type Block
- type Chain
- func (chain *Chain) AvgBlockTime() time.Duration
- func (chain *Chain) Head() Block
- func (chain *Chain) ListOwners() (owners []struct{ ... })
- func (chain *Chain) ListTxsOwnedBy(owner uint32) (txs []struct{ ... })
- func (chain *Chain) Snapshot() []Block
- func (chain *Chain) TrySwitchHead(new_tail_uuid uint64) (switched bool)
- type Transaction
- type TxPool
Constants ¶
This section is empty.
Variables ¶
View Source
var BlockCache = func() *sync.Map { var cache sync.Map the_genesis_block := Block{ Timestamp: time.Duration(time.Now().UnixNano()).Seconds(), MinerAddress: chaindb_config.MinerAddress, UUID: 0, Height: 0, } cache.Store(the_genesis_block.UUID, the_genesis_block) return &cache }() // UUID:uint64 -> Block
Functions ¶
func BuildBlockTryAppend ¶
func StartMining ¶
Types ¶
type Block ¶
type Chain ¶
区块链最后一个区块的 UUID.
func (*Chain) AvgBlockTime ¶
对最近两个 由同一个矿工挖出的 block 进行采样, 算出平均区块时间.
func (*Chain) ListOwners ¶
按插入顺序返回.
func (*Chain) ListTxsOwnedBy ¶
func (chain *Chain) ListTxsOwnedBy(owner uint32) ( txs []struct { Tx Transaction ConfirmationScore uint32 }, )
func (*Chain) TrySwitchHead ¶
type Transaction ¶
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
} // 按照 (OwnerID, Nonce) 升序.
func (*TxPool) PopFunc ¶
func (pool *TxPool) PopFunc(txout chan<- Transaction, do_what func(tx Transaction) string)
Click to show internal directories.
Click to hide internal directories.