Documentation ¶
Index ¶
- Variables
- func MockNTP(n ntp.NTPInterface) func(*BlockHeader)
- type Block
- func (b *Block) ApplyStateChanges(addressesState map[string]*addressstate.AddressState) bool
- func (b *Block) BlockHeader() BlockHeader
- func (b *Block) BlockNumber() uint64
- func (b *Block) BlockReward() uint64
- func (b *Block) Epoch() uint64
- func (b *Block) FromJSON(jsonData string) *Block
- func (b *Block) GenerateHeaderHash() []byte
- func (b *Block) GenesisBalance() []*generated.GenesisBalance
- func (b *Block) HeaderHash() []byte
- func (b *Block) IsEqual(b2 *Block) bool
- func (b *Block) JSON() (string, error)
- func (b *Block) MiningBlob() []byte
- func (b *Block) MiningNonce() uint32
- func (b *Block) PBData() *generated.Block
- func (b *Block) PrepareAddressesList() map[string]*addressstate.AddressState
- func (b *Block) PrevHeaderHash() []byte
- func (b *Block) Serialize() ([]byte, error)
- func (b *Block) SetDifficultyTracker(dt pow.DifficultyTrackerInterface)
- func (b *Block) SetNTP(n ntp.NTPInterface)
- func (b *Block) SetNonces(miningNonce uint32, extraNonce uint64)
- func (b *Block) Size() int
- func (b *Block) Timestamp() uint64
- func (b *Block) Transactions() []*generated.Transaction
- func (b *Block) UpdateMiningAddress(miningAddress []byte)
- func (b *Block) Validate(blockFromState *Block, parentBlock *Block, ...) bool
- func (b *Block) ValidateMiningNonce(bh *BlockHeader, parentBlock *Block, parentMetadata *metadata.BlockMetaData, ...) bool
- func (b *Block) VerifyBlob(blob []byte) bool
- type BlockBareInterface
- type BlockHeader
- func (bh *BlockHeader) BlockNumber() uint64
- func (bh *BlockHeader) BlockReward() uint64
- func (bh *BlockHeader) Epoch() uint64
- func (bh *BlockHeader) ExtraNonce() uint64
- func (bh *BlockHeader) ExtraNonceOffset() uint16
- func (bh *BlockHeader) FeeReward() uint64
- func (bh *BlockHeader) FromJSON(jsonData string) *BlockHeader
- func (bh *BlockHeader) GenerateHeaderHash() []byte
- func (bh *BlockHeader) HeaderHash() []byte
- func (bh *BlockHeader) JSON() (string, error)
- func (bh *BlockHeader) MiningBlob() []byte
- func (bh *BlockHeader) MiningNonce() uint32
- func (bh *BlockHeader) NonceOffset() int64
- func (bh *BlockHeader) Option(options ...func(*BlockHeader))
- func (bh *BlockHeader) PrevHeaderHash() []byte
- func (bh *BlockHeader) SetMiningNonceFromBlob(blob []byte)
- func (bh *BlockHeader) SetNonces(miningNonce uint32, extraNonce uint64)
- func (bh *BlockHeader) SetPBData(blockHeader *generated.BlockHeader)
- func (bh *BlockHeader) Timestamp() uint64
- func (bh *BlockHeader) TxMerkleRoot() []byte
- func (bh *BlockHeader) UpdateMerkleRoot(hashedtransactions []byte)
- func (bh *BlockHeader) Validate(feeReward uint64, coinbaseAmount uint64, txMerkleRoot []byte) bool
- func (bh *BlockHeader) ValidateParentChildRelation(parentBlock BlockBareInterface) bool
- func (bh *BlockHeader) VerifyBlob(blob []byte) bool
- type BlockHeaderInterface
- type BlockInterface
- type PlainBlock
- type PlainBlockHeader
Constants ¶
This section is empty.
Variables ¶
View Source
var BlockRewardCalc = func(blockNumber uint64, config *c.Config) uint64 { if blockNumber == 0 { return config.Dev.Genesis.SuppliedCoins } return formulas.BlockReward(config.Dev.Genesis.MaxCoinSupply-config.Dev.Genesis.SuppliedCoins, blockNumber) }
Functions ¶
func MockNTP ¶
func MockNTP(n ntp.NTPInterface) func(*BlockHeader)
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
func BlockFromPBData ¶
func CreateBlock ¶
func CreateBlock(minerAddress []byte, blockNumber uint64, prevBlockHeaderhash []byte, prevBlockTimestamp uint64, txs []transactions.TransactionInterface, timestamp uint64) *Block
func DeSerializeBlock ¶
func (*Block) ApplyStateChanges ¶
func (b *Block) ApplyStateChanges(addressesState map[string]*addressstate.AddressState) bool
func (*Block) BlockHeader ¶
func (b *Block) BlockHeader() BlockHeader
func (*Block) BlockNumber ¶
func (*Block) BlockReward ¶
func (*Block) GenerateHeaderHash ¶
func (*Block) GenesisBalance ¶
func (b *Block) GenesisBalance() []*generated.GenesisBalance
func (*Block) HeaderHash ¶
func (*Block) MiningBlob ¶
func (*Block) MiningNonce ¶
func (*Block) PrepareAddressesList ¶
func (b *Block) PrepareAddressesList() map[string]*addressstate.AddressState
func (*Block) PrevHeaderHash ¶
func (*Block) SetDifficultyTracker ¶
func (b *Block) SetDifficultyTracker(dt pow.DifficultyTrackerInterface)
func (*Block) SetNTP ¶
func (b *Block) SetNTP(n ntp.NTPInterface)
func (*Block) Transactions ¶
func (b *Block) Transactions() []*generated.Transaction
func (*Block) UpdateMiningAddress ¶
func (*Block) ValidateMiningNonce ¶
func (b *Block) ValidateMiningNonce(bh *BlockHeader, parentBlock *Block, parentMetadata *metadata.BlockMetaData, measurement uint64, enableLogging bool) bool
func (*Block) VerifyBlob ¶
type BlockBareInterface ¶
BlockBareInterface only includes the basics which other components working with Block might need to use. Use it when you're too lazy to make a real Block.
type BlockHeader ¶
type BlockHeader struct {
// contains filtered or unexported fields
}
func BlockHeaderFromPBData ¶
func BlockHeaderFromPBData(header *generated.BlockHeader) *BlockHeader
func CreateBlockHeader ¶
func CreateBlockHeader(blockNumber uint64, prevBlockHeaderHash []byte, prevBlockTimestamp uint64, merkleRoot []byte, feeReward uint64, timestamp uint64, options ...func(*BlockHeader)) *BlockHeader
func (*BlockHeader) BlockNumber ¶
func (bh *BlockHeader) BlockNumber() uint64
func (*BlockHeader) BlockReward ¶
func (bh *BlockHeader) BlockReward() uint64
func (*BlockHeader) Epoch ¶
func (bh *BlockHeader) Epoch() uint64
func (*BlockHeader) ExtraNonce ¶
func (bh *BlockHeader) ExtraNonce() uint64
func (*BlockHeader) ExtraNonceOffset ¶
func (bh *BlockHeader) ExtraNonceOffset() uint16
func (*BlockHeader) FeeReward ¶
func (bh *BlockHeader) FeeReward() uint64
func (*BlockHeader) FromJSON ¶
func (bh *BlockHeader) FromJSON(jsonData string) *BlockHeader
func (*BlockHeader) GenerateHeaderHash ¶
func (bh *BlockHeader) GenerateHeaderHash() []byte
func (*BlockHeader) HeaderHash ¶
func (bh *BlockHeader) HeaderHash() []byte
func (*BlockHeader) JSON ¶
func (bh *BlockHeader) JSON() (string, error)
func (*BlockHeader) MiningBlob ¶
func (bh *BlockHeader) MiningBlob() []byte
func (*BlockHeader) MiningNonce ¶
func (bh *BlockHeader) MiningNonce() uint32
func (*BlockHeader) NonceOffset ¶
func (bh *BlockHeader) NonceOffset() int64
func (*BlockHeader) Option ¶
func (bh *BlockHeader) Option(options ...func(*BlockHeader))
func (*BlockHeader) PrevHeaderHash ¶
func (bh *BlockHeader) PrevHeaderHash() []byte
func (*BlockHeader) SetMiningNonceFromBlob ¶
func (bh *BlockHeader) SetMiningNonceFromBlob(blob []byte)
func (*BlockHeader) SetNonces ¶
func (bh *BlockHeader) SetNonces(miningNonce uint32, extraNonce uint64)
func (*BlockHeader) SetPBData ¶
func (bh *BlockHeader) SetPBData(blockHeader *generated.BlockHeader)
func (*BlockHeader) Timestamp ¶
func (bh *BlockHeader) Timestamp() uint64
func (*BlockHeader) TxMerkleRoot ¶
func (bh *BlockHeader) TxMerkleRoot() []byte
func (*BlockHeader) UpdateMerkleRoot ¶
func (bh *BlockHeader) UpdateMerkleRoot(hashedtransactions []byte)
func (*BlockHeader) Validate ¶
func (bh *BlockHeader) Validate(feeReward uint64, coinbaseAmount uint64, txMerkleRoot []byte) bool
func (*BlockHeader) ValidateParentChildRelation ¶
func (bh *BlockHeader) ValidateParentChildRelation(parentBlock BlockBareInterface) bool
func (*BlockHeader) VerifyBlob ¶
func (bh *BlockHeader) VerifyBlob(blob []byte) bool
type BlockHeaderInterface ¶
type BlockHeaderInterface interface { BlockNumber() uint64 Epoch() uint64 Timestamp() uint64 HeaderHash() []byte PrevHeaderHash() []byte BlockReward() uint64 FeeReward() uint64 TxMerkleRoot() []byte ExtraNonce() uint64 MiningNonce() uint32 NonceOffset() uint16 ExtraNonceOffset() uint16 MiningBlob() []byte GenerateHeaderHash() []byte UpdateMerkleRoot([]byte) SetNonces(uint32, uint64) SetMiningNonceFromBlob([]byte) Validate(uint64, uint64, []byte) bool ValidateParentChildRelation(BlockBareInterface) bool VerifyBlob([]byte) bool SetPBData(*generated.BlockHeader) FromJSON(string) *BlockHeader JSON() (string, error) }
TODO: this Interface is outdated and does not correspond to BlockHeader method signatures
type BlockInterface ¶
type BlockInterface interface { PBData() *generated.Block Size() int GenesisBalance() []*generated.GenesisBalance BlockNumber() uint64 Epoch() uint64 HeaderHash() []byte PrevHeaderHash() []byte Transactions() []*generated.Transaction MiningNonce() uint32 BlockReward() []uint64 FeeReward() []uint64 Timestamp() []uint64 MiningBlob() []byte MiningNonceOffset() []byte VerifyBlob([]byte) bool SetNonces(uint32, uint64) FromJSON(string) Block JSON() (string, error) Serialize() ([]byte, error) Create(blockNumber uint64, prevHeaderHash []byte, prevBlockTimestamp uint64, transactions generated.Transaction, minerAddress []byte) UpdateMiningAddress(miningAddress []byte) Validate(futureBlocks map[string]*generated.Block) ValidateMiningNonce(bh *BlockHeader, parentBlock *Block, parentMetadata metadata.BlockMetaData, measurement uint64, enableLogging bool) bool IsFutureBlock() bool ValidateParentChildRelation(block generated.Block) bool ApplyStateChanges(addressesState map[string]*addressstate.AddressState) }
type PlainBlock ¶
type PlainBlock struct { Header *PlainBlockHeader `json:"header" bson:"header"` Transactions []transactions.PlainTransactionInterface `json:"transactions" bson:"transactions"` }
func (*PlainBlock) BlockFromPBData ¶
func (b *PlainBlock) BlockFromPBData(b2 *generated.Block)
type PlainBlockHeader ¶
type PlainBlockHeader struct { HeaderHash string `json:"headerHash" bson:"headerHash"` BlockNumber uint64 `json:"blockNumber" bson:"blockNumber"` Timestamp uint64 `json:"timestamp" bson:"timestamp"` PrevHeaderHash string `json:"prevHeaderHash" bson:"prevHeaderHash"` BlockReward uint64 `json:"blockReward" bson:"blockReward"` FeeReward uint64 `json:"feeReward" bson:"feeReward"` MerkleRoot string `json:"merkleRoot" bson:"merkleRoot"` MiningNonce uint32 `json:"miningNonce" bson:"miningNonce"` ExtraNonce uint64 `json:"extraNonce" bson:"extraNonce"` }
func (*PlainBlockHeader) BlockHeaderFromPBData ¶
func (bh *PlainBlockHeader) BlockHeaderFromPBData(bh2 *generated.BlockHeader)
Click to show internal directories.
Click to hide internal directories.