Documentation ¶
Index ¶
- type Block
- type Blockchain
- func (chain *Blockchain) CalcTimeTargetV1(parent *Block) *calculus.TimeTarget
- func (chain *Blockchain) CalcTimeTargetV2(parent *Block) *calculus.TimeTarget
- func (chain *Blockchain) GetBlock(height uint64) *Block
- func (chain *Blockchain) LastBlock() *Block
- func (chain *Blockchain) NewBlock(block *Block)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Difficulty uint64 `json:"difficultyStart"` Height uint64 `json:"height"` Coinbase string `json:"coinbase"` Time uint64 `json:"time"` Nonce uint64 `json:"nonce"` }
Block represents each block in the blockchain
type Blockchain ¶
Blockchain represents current state of the chain
func CreateBlockchain ¶
func CreateBlockchain() *Blockchain
CreateBlockchain creates initial blockchain state
func (*Blockchain) CalcTimeTargetV1 ¶
func (chain *Blockchain) CalcTimeTargetV1(parent *Block) *calculus.TimeTarget
*
- Implements block time consensus *
- POS-11: Block time restrictions
- POS-12: Block interval enforcement
func (*Blockchain) CalcTimeTargetV2 ¶
func (chain *Blockchain) CalcTimeTargetV2(parent *Block) *calculus.TimeTarget
CalcTimeTargetV2 calculates asgard time target
func (*Blockchain) GetBlock ¶
func (chain *Blockchain) GetBlock(height uint64) *Block
GetBlock return height corresponding mined block
func (*Blockchain) LastBlock ¶
func (chain *Blockchain) LastBlock() *Block
LastBlock returns last mined block in chain (the blockchain has genesis block)
func (*Blockchain) NewBlock ¶
func (chain *Blockchain) NewBlock(block *Block)
NewBlock appends new mined block into the chain
Click to show internal directories.
Click to hide internal directories.