Documentation
¶
Overview ¶
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>
ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.
Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:
- You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
- Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.
ZooBC is architected by Roberto Capodieci & Barton Johnston
contact us at roberto.capodieci[at]blockchainzoo.com and barton.johnston[at]blockchainzoo.com
Core developers that contributed to the current implementation of the software are:
Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com Allan Bintoro allan.bintoro[at]blockchainzoo.com Andy Herman Gede Sukra Ketut Ariasa Nawi Kartini nawi.kartini[at]blockchainzoo.com Stefano Galassi stefano.galassi[at]blockchainzoo.com
IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Index ¶
- func GetActiveNodesInSpineBlocks(QueryExecutor query.ExecutorInterface, ...) (activeNodeRegistry []storage.NodeRegistry, err error)
- func GetActiveSpinePublicKeysByBlockHeight(QueryExecutor query.ExecutorInterface, ...) (spinePublicKeys []*model.SpinePublicKey, err error)
- type BlocksmithStrategyInterface
- type BlocksmithStrategyMain
- func (bss *BlocksmithStrategyMain) AddCandidate(prevBlock *model.Block) error
- func (bss *BlocksmithStrategyMain) CalculateCumulativeDifficulty(prevBlock, block *model.Block) (string, error)
- func (bss *BlocksmithStrategyMain) CanPersistBlock(previousBlock, block *model.Block, timestamp int64) error
- func (bss *BlocksmithStrategyMain) GetBlocksBlocksmiths(previousBlock, block *model.Block) ([]*model.Blocksmith, error)
- func (bss *BlocksmithStrategyMain) GetSmithingIndex(previousBlock, block *model.Block, activeRegistries []storage.NodeRegistry) (int, error)
- func (bss *BlocksmithStrategyMain) GetSmithingRound(previousBlock, block *model.Block) (int, error)
- func (bss *BlocksmithStrategyMain) IsBlockValid(prevBlock, block *model.Block) error
- func (bss *BlocksmithStrategyMain) WillSmith(prevBlock *model.Block) (int64, error)
- type BlocksmithStrategySpine
- func (bss *BlocksmithStrategySpine) AddCandidate(prevBlock *model.Block) error
- func (bss *BlocksmithStrategySpine) CalculateCumulativeDifficulty(prevBlock, block *model.Block) (string, error)
- func (bss *BlocksmithStrategySpine) CanPersistBlock(previousBlock, block *model.Block, timestamp int64) error
- func (bss *BlocksmithStrategySpine) GetBlocksBlocksmiths(previousBlock, block *model.Block) ([]*model.Blocksmith, error)
- func (bss *BlocksmithStrategySpine) GetSmithingIndex(previousBlock, block *model.Block, activeRegistries []storage.NodeRegistry) (int, error)
- func (bss *BlocksmithStrategySpine) GetSmithingRound(previousBlock, block *model.Block) (int, error)
- func (bss *BlocksmithStrategySpine) IsBlockValid(prevBlock, block *model.Block) error
- func (bss *BlocksmithStrategySpine) WillSmith(prevBlock *model.Block) (int64, error)
- type Candidate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetActiveNodesInSpineBlocks ¶
func GetActiveNodesInSpineBlocks(QueryExecutor query.ExecutorInterface, SpinePublicKeyQuery query.SpinePublicKeyQueryInterface, block *model.Block) (activeNodeRegistry []storage.NodeRegistry, err error)
GetActiveNodesInSpineBlocks get the active nodes either from cache ( main blocks), or from from spine_pub_keys if spine blocks
func GetActiveSpinePublicKeysByBlockHeight ¶
func GetActiveSpinePublicKeysByBlockHeight(QueryExecutor query.ExecutorInterface, SpinePublicKeyQuery query.SpinePublicKeyQueryInterface, height uint32) (spinePublicKeys []*model.SpinePublicKey, err error)
Types ¶
type BlocksmithStrategyInterface ¶
type BlocksmithStrategyInterface interface { // WillSmith is used by node to check if it is its own time to create block yet WillSmith(prevBlock *model.Block) (int64, error) // IsBlockValid validate if provided `block` is valid given the previousBlock IsBlockValid(prevBlock, block *model.Block) error // CalculateCumulativeDifficulty calculate quality of block by giving the previous block as // base calculation CalculateCumulativeDifficulty(prevBlock, block *model.Block) (string, error) // GetBlocksBlocksmiths return the candidates of blocksmith of provided block, by calculating the time-gap // between previousBlock and block GetBlocksBlocksmiths(previousBlock, block *model.Block) ([]*model.Blocksmith, error) // GetSmithingRound get the number of time we should be running a random number generate given previousBlock // and block GetSmithingRound(previousBlock, block *model.Block) (int, error) // CanPersistBlock check if block can be persisted or not (from block-pool to database) CanPersistBlock(previousBlock, block *model.Block, timestamp int64) error }
BlocksmithStrategyInterface interface for finding the valid blocksmith (block creator)
type BlocksmithStrategyMain ¶
type BlocksmithStrategyMain struct { Chaintype chaintype.ChainType ActiveNodeRegistryCacheStorage storage.CacheStorageInterface SkippedBlocksmithQuery query.SkippedBlocksmithQueryInterface BlockQuery query.BlockQueryInterface QueryExecutor query.ExecutorInterface BlocksCacheStorage storage.CacheStackStorageInterface SpinePublicKeyQuery query.SpinePublicKeyQueryInterface Logger *log.Logger CurrentNodePublicKey []byte // contains filtered or unexported fields }
func NewBlocksmithStrategyMain ¶
func NewBlocksmithStrategyMain( logger *log.Logger, currentNodePublicKey []byte, activeNodeRegistryCacheStorage storage.CacheStorageInterface, skippedBlocksmithQuery query.SkippedBlocksmithQueryInterface, blockQuery query.BlockQueryInterface, blocksCacheStorage storage.CacheStackStorageInterface, spinePublicKeyQuery query.SpinePublicKeyQueryInterface, queryExecutor query.ExecutorInterface, rng *crypto.RandomNumberGenerator, chaintype chaintype.ChainType, ) *BlocksmithStrategyMain
func (*BlocksmithStrategyMain) AddCandidate ¶
func (bss *BlocksmithStrategyMain) AddCandidate(prevBlock *model.Block) error
func (*BlocksmithStrategyMain) CalculateCumulativeDifficulty ¶
func (bss *BlocksmithStrategyMain) CalculateCumulativeDifficulty(prevBlock, block *model.Block) (string, error)
func (*BlocksmithStrategyMain) CanPersistBlock ¶
func (bss *BlocksmithStrategyMain) CanPersistBlock(previousBlock, block *model.Block, timestamp int64) error
func (*BlocksmithStrategyMain) GetBlocksBlocksmiths ¶
func (bss *BlocksmithStrategyMain) GetBlocksBlocksmiths(previousBlock, block *model.Block) ([]*model.Blocksmith, error)
GetBlocksBlocksmiths fetch the blocksmiths candidate list up to block.BlocksmithPublicKey, if the block.BlocksmithPublicKey is first blocksmith then it returns only a single model.Blocksmith, otherwise it returns n-1 number of skipped blocksmith including (possibly) the block.BlocksmithPublicKey with the valid blocksmith at n-th index.
func (*BlocksmithStrategyMain) GetSmithingIndex ¶
func (bss *BlocksmithStrategyMain) GetSmithingIndex( previousBlock, block *model.Block, activeRegistries []storage.NodeRegistry, ) (int, error)
func (*BlocksmithStrategyMain) GetSmithingRound ¶
func (bss *BlocksmithStrategyMain) GetSmithingRound(previousBlock, block *model.Block) (int, error)
func (*BlocksmithStrategyMain) IsBlockValid ¶
func (bss *BlocksmithStrategyMain) IsBlockValid(prevBlock, block *model.Block) error
type BlocksmithStrategySpine ¶
type BlocksmithStrategySpine struct { Chaintype chaintype.ChainType ActiveNodeRegistryCacheStorage storage.CacheStorageInterface SkippedBlocksmithQuery query.SkippedBlocksmithQueryInterface BlockQuery query.BlockQueryInterface QueryExecutor query.ExecutorInterface BlocksCacheStorage storage.CacheStackStorageInterface Logger *log.Logger CurrentNodePublicKey []byte SpinePublicKeyQuery query.SpinePublicKeyQueryInterface // contains filtered or unexported fields }
func NewBlocksmithStrategySpine ¶
func NewBlocksmithStrategySpine( logger *log.Logger, currentNodePublicKey []byte, activeNodeRegistryCacheStorage storage.CacheStorageInterface, skippedBlocksmithQuery query.SkippedBlocksmithQueryInterface, blockQuery query.BlockQueryInterface, blocksCacheStorage storage.CacheStackStorageInterface, queryExecutor query.ExecutorInterface, rng *crypto.RandomNumberGenerator, chaintype chaintype.ChainType, spinePublicKeyQuery query.SpinePublicKeyQueryInterface, ) *BlocksmithStrategySpine
func (*BlocksmithStrategySpine) AddCandidate ¶
func (bss *BlocksmithStrategySpine) AddCandidate(prevBlock *model.Block) error
func (*BlocksmithStrategySpine) CalculateCumulativeDifficulty ¶
func (bss *BlocksmithStrategySpine) CalculateCumulativeDifficulty(prevBlock, block *model.Block) (string, error)
func (*BlocksmithStrategySpine) CanPersistBlock ¶
func (bss *BlocksmithStrategySpine) CanPersistBlock(previousBlock, block *model.Block, timestamp int64) error
func (*BlocksmithStrategySpine) GetBlocksBlocksmiths ¶
func (bss *BlocksmithStrategySpine) GetBlocksBlocksmiths(previousBlock, block *model.Block) ([]*model.Blocksmith, error)
GetBlocksBlocksmiths fetch the blocksmiths candidate list up to block.BlocksmithPublicKey, if the block.BlocksmithPublicKey is first blocksmith then it returns only a single model.Blocksmith, otherwise it returns n-1 number of skipped blocksmith including (possibly) the block.BlocksmithPublicKey with the valid blocksmith at n-th index.
func (*BlocksmithStrategySpine) GetSmithingIndex ¶
func (bss *BlocksmithStrategySpine) GetSmithingIndex( previousBlock, block *model.Block, activeRegistries []storage.NodeRegistry, ) (int, error)
func (*BlocksmithStrategySpine) GetSmithingRound ¶
func (bss *BlocksmithStrategySpine) GetSmithingRound(previousBlock, block *model.Block) (int, error)
func (*BlocksmithStrategySpine) IsBlockValid ¶
func (bss *BlocksmithStrategySpine) IsBlockValid(prevBlock, block *model.Block) error