Versions in this module Expand all Collapse all v0 v0.0.3 Feb 7, 2021 Changes in this version + const MaxBlockOrder + const MaxId + const MaxMainLocatorNum + const MaxTipLayerGap + const MaxTips + const RET_KEY + const StableConfirmations + const VMK_KEY + var BlockRate = anticone.DefaultBlockRate + func DBGetDAGBlock(dbTx database.Tx, block IBlock) error + func DBHasMainChainBlock(dbTx database.Tx, id uint) bool + func DBPutDAGBlock(dbTx database.Tx, block IBlock) error + func DBPutDAGInfo(dbTx database.Tx, bd *BlockDAG) error + func DBPutMainChainBlock(dbTx database.Tx, id uint) error + func DBRemoveMainChainBlock(dbTx database.Tx, id uint) error + func GetDAGTypeByIndex(dagType byte) string + func GetDAGTypeIndex(dagType string) byte + func GetMaxLenHashSet(bsm map[hash.Hash]*HashSet) *hash.Hash + func GetOrderLogStr(order uint) string + func GetRisk(N int, alpha float64, lambda float64, delay float64, waitingTime uint, ...) float64 + func UseLogger(logger l.Logger) + type Block struct + func (b *Block) AddChild(child IBlock) + func (b *Block) Decode(r io.Reader) error + func (b *Block) Encode(w io.Writer) error + func (b *Block) GetBackParent() *Block + func (b *Block) GetChildren() *IdSet + func (b *Block) GetForwardParent() *Block + func (b *Block) GetHash() *hash.Hash + func (b *Block) GetHeight() uint + func (b *Block) GetID() uint + func (b *Block) GetLayer() uint + func (b *Block) GetMainParent() uint + func (b *Block) GetOrder() uint + func (b *Block) GetParents() *IdSet + func (b *Block) GetStatus() BlockStatus + func (b *Block) GetWeight() uint64 + func (b *Block) HasChildren() bool + func (b *Block) HasParents() bool + func (b *Block) IsOrdered() bool + func (b *Block) SetHeight(h uint) + func (b *Block) SetLayer(layer uint) + func (b *Block) SetOrder(o uint) + func (b *Block) SetStatus(status BlockStatus) + func (b *Block) SetStatusFlags(flags BlockStatus) + func (b *Block) SetWeight(weight uint64) + func (b *Block) UnsetStatusFlags(flags BlockStatus) + type BlockDAG struct + func (bd *BlockDAG) AddBlock(b IBlockData) (*list.List, IBlock) + func (bd *BlockDAG) BuildMerkleTreeStoreFromTips() []*hash.Hash + func (bd *BlockDAG) CheckBlueAndMature(targets []uint, views []uint, max uint) error + func (bd *BlockDAG) CheckBlueAndMatureMT(targets []uint, views []uint, max uint) error + func (bd *BlockDAG) CheckSubMainChainTip(parents []uint) (uint, bool) + func (bd *BlockDAG) Decode(r io.Reader) error + func (bd *BlockDAG) Encode(w io.Writer) error + func (bd *BlockDAG) GetBlock(h *hash.Hash) IBlock + func (bd *BlockDAG) GetBlockById(id uint) IBlock + func (bd *BlockDAG) GetBlockByOrder(order uint) *hash.Hash + func (bd *BlockDAG) GetBlockConcurrency(h *hash.Hash) (uint, error) + func (bd *BlockDAG) GetBlockHash(id uint) *hash.Hash + func (bd *BlockDAG) GetBlockTotal() uint + func (bd *BlockDAG) GetBlues(parents *IdSet) uint + func (bd *BlockDAG) GetConfirmations(id uint) uint + func (bd *BlockDAG) GetGenesisHash() *hash.Hash + func (bd *BlockDAG) GetGraphState() *GraphState + func (bd *BlockDAG) GetIdSet(hs []*hash.Hash) *IdSet + func (bd *BlockDAG) GetInstance() IBlockDAG + func (bd *BlockDAG) GetLastBlock() IBlock + func (bd *BlockDAG) GetLastTime() *time.Time + func (bd *BlockDAG) GetLayer(id uint) uint + func (bd *BlockDAG) GetMainChainTip() IBlock + func (bd *BlockDAG) GetMainParent(parents *IdSet) IBlock + func (bd *BlockDAG) GetMainParentConcurrency(b IBlock) int + func (bd *BlockDAG) GetMaturity(target uint, views []uint) uint + func (bd *BlockDAG) GetName() string + func (bd *BlockDAG) GetOrder() map[uint]uint + func (bd *BlockDAG) GetParentsMaxLayer(parents *IdSet) (uint, bool) + func (bd *BlockDAG) GetPrevious(id uint) (uint, error) + func (bd *BlockDAG) GetTips() *HashSet + func (bd *BlockDAG) GetTipsList() []IBlock + func (bd *BlockDAG) GetValidTips() []*hash.Hash + func (bd *BlockDAG) HasBlock(h *hash.Hash) bool + func (bd *BlockDAG) HasBlockById(id uint) bool + func (bd *BlockDAG) Init(dagType string, calcWeight CalcWeight, blockRate float64, ...) IBlockDAG + func (bd *BlockDAG) IsBlue(id uint) bool + func (bd *BlockDAG) IsHourglass(id uint) bool + func (bd *BlockDAG) IsOnMainChain(id uint) bool + func (bd *BlockDAG) Load(dbTx database.Tx, blockTotal uint, genesis *hash.Hash) error + func (bd *BlockDAG) SortBlock(src []*hash.Hash) []*hash.Hash + func (bd *BlockDAG) UpdateWeight(ib IBlock) + func (bd *BlockDAG) UpgradeDB(dbTx database.Tx) error + type BlockHashSlice []IBlock + func (bn BlockHashSlice) Len() int + func (bn BlockHashSlice) Less(i, j int) bool + func (bn BlockHashSlice) Swap(i, j int) + type BlockSlice []IBlock + func (bn BlockSlice) Len() int + func (bn BlockSlice) Less(i, j int) bool + func (bn BlockSlice) Swap(i, j int) + type BlockStatus byte + const StatusBadSide + const StatusNone + func (status BlockStatus) IsBadSide() bool + type CalcWeight func(int64, *hash.Hash, byte) int64 + type Conflux struct + func (con *Conflux) AddBlock(b IBlock) *list.List + func (con *Conflux) CreateBlock(b *Block) IBlock + func (con *Conflux) Decode(r io.Reader) error + func (con *Conflux) Encode(w io.Writer) error + func (con *Conflux) GetBlockByOrder(order uint) *hash.Hash + func (con *Conflux) GetBlues(parents *IdSet) uint + func (con *Conflux) GetMainChain() []uint + func (con *Conflux) GetMainChainTip() IBlock + func (con *Conflux) GetMainParent(parents *IdSet) IBlock + func (con *Conflux) GetMainParentConcurrency(b IBlock) int + func (con *Conflux) GetName() string + func (con *Conflux) GetTipsList() []IBlock + func (con *Conflux) Init(bd *BlockDAG) bool + func (con *Conflux) IsBlue(id uint) bool + func (con *Conflux) IsDAG(parents []IBlock) bool + func (con *Conflux) IsOnMainChain(b IBlock) bool + func (con *Conflux) Load(dbTx database.Tx) error + type DAGSync struct + GS *GraphState + GSMtx sync.Mutex + func NewDAGSync(bd *BlockDAG) *DAGSync + func (ds *DAGSync) CalcSyncBlocks(gs *GraphState, locator []*hash.Hash, mode SyncMode, maxHashes uint) ([]*hash.Hash, *hash.Hash) + func (ds *DAGSync) GetMainLocator(point *hash.Hash) []*hash.Hash + type Empty struct + type Epoch struct + func (e *Epoch) GetSequence() []IBlock + func (e *Epoch) HasBlock(h *hash.Hash) bool + func (e *Epoch) HasDepends() bool + type GetBlockId func(*hash.Hash) uint + type GraphState struct + func NewGraphState() *GraphState + func (gs *GraphState) Clone() *GraphState + func (gs *GraphState) Decode(r io.Reader, pver uint32) error + func (gs *GraphState) Encode(w io.Writer, pver uint32) error + func (gs *GraphState) Equal(other *GraphState) + func (gs *GraphState) GetLayer() uint + func (gs *GraphState) GetMainChainTip() *hash.Hash + func (gs *GraphState) GetMainHeight() uint + func (gs *GraphState) GetMainOrder() uint + func (gs *GraphState) GetTips() *HashSet + func (gs *GraphState) GetTotal() uint + func (gs *GraphState) IsEqual(other *GraphState) bool + func (gs *GraphState) IsExcellent(other *GraphState) bool + func (gs *GraphState) IsGenesis() bool + func (gs *GraphState) MaxPayloadLength() uint32 + func (gs *GraphState) SetLayer(layer uint) + func (gs *GraphState) SetMainHeight(mainHeight uint) + func (gs *GraphState) SetMainOrder(order uint) + func (gs *GraphState) SetTips(tips *HashSet) + func (gs *GraphState) SetTotal(total uint) + func (gs *GraphState) String() string + type HashSet struct + func NewHashSet() *HashSet + func (s *HashSet) Add(elem *hash.Hash) + func (s *HashSet) AddList(list []*hash.Hash) + func (s *HashSet) AddPair(elem *hash.Hash, data interface{}) + func (s *HashSet) AddSet(other *HashSet) + func (s *HashSet) Clean() + func (s *HashSet) Clone() *HashSet + func (s *HashSet) Contain(other *HashSet) bool + func (s *HashSet) Exclude(other *HashSet) + func (s *HashSet) Get(elem *hash.Hash) interface{} + func (s *HashSet) GetMap() map[hash.Hash]interface{} + func (s *HashSet) Has(elem *hash.Hash) bool + func (s *HashSet) HasOnly(elem *hash.Hash) bool + func (s *HashSet) Intersection(other *HashSet) *HashSet + func (s *HashSet) IsEmpty() bool + func (s *HashSet) IsEqual(other *HashSet) bool + func (s *HashSet) List() []*hash.Hash + func (s *HashSet) Remove(elem *hash.Hash) + func (s *HashSet) RemoveSet(other *HashSet) + func (s *HashSet) Size() int + func (s *HashSet) SortList(reverse bool) []*hash.Hash + func (s *HashSet) Union(other *HashSet) *HashSet + type HashSlice []*hash.Hash + func (sh HashSlice) Has(h *hash.Hash) bool + func (sh HashSlice) Len() int + func (sh HashSlice) Less(i, j int) bool + func (sh HashSlice) Swap(i, j int) + type IBlock interface + AddChild func(child IBlock) + Decode func(r io.Reader) error + Encode func(w io.Writer) error + GetChildren func() *IdSet + GetHash func() *hash.Hash + GetHeight func() uint + GetID func() uint + GetLayer func() uint + GetMainParent func() uint + GetOrder func() uint + GetParents func() *IdSet + GetStatus func() BlockStatus + GetWeight func() uint64 + HasChildren func() bool + HasParents func() bool + IsOrdered func() bool + SetOrder func(o uint) + SetStatus func(status BlockStatus) + SetWeight func(weight uint64) + type IBlockDAG interface + AddBlock func(ib IBlock) *list.List + CreateBlock func(b *Block) IBlock + Decode func(r io.Reader) error + Encode func(w io.Writer) error + GetBlockByOrder func(order uint) *hash.Hash + GetBlues func(parents *IdSet) uint + GetMainChainTip func() IBlock + GetMainParent func(parents *IdSet) IBlock + GetMainParentConcurrency func(b IBlock) int + GetName func() string + GetTipsList func() []IBlock + Init func(bd *BlockDAG) bool + IsBlue func(id uint) bool + IsDAG func(parents []IBlock) bool + IsOnMainChain func(ib IBlock) bool + Load func(dbTx database.Tx) error + func NewBlockDAG(dagType string) IBlockDAG + type IBlockData interface + GetHash func() *hash.Hash + GetParents func() []uint + GetTimestamp func() int64 + GetWeight func() uint64 + type ISpectre interface + Vote func(x IBlock, y IBlock) int + type IdSet struct + func NewIdSet() *IdSet + func (s *IdSet) Add(elem uint) + func (s *IdSet) AddList(list []uint) + func (s *IdSet) AddPair(elem uint, data interface{}) + func (s *IdSet) AddSet(other *IdSet) + func (s *IdSet) Clean() + func (s *IdSet) Clone() *IdSet + func (s *IdSet) Contain(other *IdSet) bool + func (s *IdSet) Exclude(other *IdSet) + func (s *IdSet) Get(elem uint) interface{} + func (s *IdSet) GetMap() map[uint]interface{} + func (s *IdSet) Has(elem uint) bool + func (s *IdSet) HasOnly(elem uint) bool + func (s *IdSet) Intersection(other *IdSet) *IdSet + func (s *IdSet) IsEmpty() bool + func (s *IdSet) IsEqual(other *IdSet) bool + func (s *IdSet) List() []uint + func (s *IdSet) Remove(elem uint) + func (s *IdSet) RemoveSet(other *IdSet) + func (s *IdSet) Size() int + func (s *IdSet) SortHashList(reverse bool) []uint + func (s *IdSet) SortList(reverse bool) []uint + func (s *IdSet) Union(other *IdSet) *IdSet + type IdSlice []uint + func (sh IdSlice) Has(id uint) bool + func (sh IdSlice) Len() int + func (sh IdSlice) Less(i, j int) bool + func (sh IdSlice) Swap(i, j int) + type KChain struct + type LazySet struct + func NewLazySet() *LazySet + func (ls *LazySet) Add(elem *hash.Hash) + func (ls *LazySet) Clear() + func (ls *LazySet) Clone() *LazySet + func (ls *LazySet) Intersection(other *HashSet) *LazySet + func (ls *LazySet) Remove(elem *hash.Hash) + func (ls *LazySet) Union(other *HashSet) *LazySet + type MainChain struct + func (mc *MainChain) Add(id uint) error + func (mc *MainChain) Has(id uint) bool + func (mc *MainChain) Remove(id uint) error + type Phantom struct + func (ph *Phantom) AddBlock(ib IBlock) *list.List + func (ph *Phantom) CreateBlock(b *Block) IBlock + func (ph *Phantom) Decode(r io.Reader) error + func (ph *Phantom) Encode(w io.Writer) error + func (ph *Phantom) GetBlockByOrder(order uint) *hash.Hash + func (ph *Phantom) GetBlues(parents *IdSet) uint + func (ph *Phantom) GetDiffAnticone() *IdSet + func (ph *Phantom) GetDiffBlueSet() *IdSet + func (ph *Phantom) GetMainChainTip() IBlock + func (ph *Phantom) GetMainParent(parents *IdSet) IBlock + func (ph *Phantom) GetMainParentConcurrency(b IBlock) int + func (ph *Phantom) GetName() string + func (ph *Phantom) GetTipsList() []IBlock + func (ph *Phantom) Init(bd *BlockDAG) bool + func (ph *Phantom) IsBlue(id uint) bool + func (ph *Phantom) IsDAG(parents []IBlock) bool + func (ph *Phantom) IsOnMainChain(b IBlock) bool + func (ph *Phantom) Load(dbTx database.Tx) error + func (ph *Phantom) UpdateVirtualBlockOrder() *PhantomBlock + func (ph *Phantom) UpdateWeight(ib IBlock, store bool) + type PhantomBlock struct + func (pb *PhantomBlock) Decode(r io.Reader) error + func (pb *PhantomBlock) Encode(w io.Writer) error + func (pb *PhantomBlock) GetBlueDiffAnticone() *IdSet + func (pb *PhantomBlock) GetBlueNum() uint + func (pb *PhantomBlock) GetRedDiffAnticone() *IdSet + func (pb *PhantomBlock) IsBluer(other *PhantomBlock) bool + type Phantom_v2 struct + func (ph *Phantom_v2) AddBlock(b IBlock) *list.List + func (ph *Phantom_v2) CreateBlock(b *Block) IBlock + func (ph *Phantom_v2) Decode(r io.Reader) error + func (ph *Phantom_v2) Encode(w io.Writer) error + func (ph *Phantom_v2) GetBlockByOrder(order uint) *hash.Hash + func (ph *Phantom_v2) GetBlues(parents *IdSet) uint + func (ph *Phantom_v2) GetMainChainTip() IBlock + func (ph *Phantom_v2) GetMainParent(parents *IdSet) IBlock + func (ph *Phantom_v2) GetMainParentConcurrency(b IBlock) int + func (ph *Phantom_v2) GetName() string + func (ph *Phantom_v2) GetTipsList() []IBlock + func (ph *Phantom_v2) Init(bd *BlockDAG) bool + func (ph *Phantom_v2) IsBlue(id uint) bool + func (ph *Phantom_v2) IsDAG(parents []IBlock) bool + func (ph *Phantom_v2) IsOnMainChain(b IBlock) bool + func (ph *Phantom_v2) Load(dbTx database.Tx) error + type Spectre struct + func (sp *Spectre) AddBlock(b IBlock) *list.List + func (sp *Spectre) CreateBlock(b *Block) IBlock + func (sp *Spectre) Decode(r io.Reader) error + func (sp *Spectre) Encode(w io.Writer) error + func (sp *Spectre) GetBlockByOrder(order uint) *hash.Hash + func (sp *Spectre) GetBlues(parents *IdSet) uint + func (sp *Spectre) GetMainChainTip() IBlock + func (sp *Spectre) GetMainParent(parents *IdSet) IBlock + func (sp *Spectre) GetMainParentConcurrency(b IBlock) int + func (sp *Spectre) GetName() string + func (sp *Spectre) GetTipsList() []IBlock + func (sp *Spectre) Init(bd *BlockDAG) bool + func (sp *Spectre) InitVote(b1 IBlock, b2 IBlock) (bool, error) + func (sp *Spectre) IsBlue(id uint) bool + func (sp *Spectre) IsDAG(parents []IBlock) bool + func (sp *Spectre) IsInPastOf(b1 IBlock, b2 IBlock) bool + func (sp *Spectre) IsOnMainChain(b IBlock) bool + func (sp *Spectre) Load(dbTx database.Tx) error + func (sp *Spectre) Vote(b1 IBlock, b2 IBlock) (bool, error) + func (sp *Spectre) VoteByBlock(virtualBlock IBlock) (bool, error) + func (sp *Spectre) Votes() map[hash.Hash]bool + type SpectreBlock struct + Votes1 int + Votes2 int + func (sb *SpectreBlock) GetHash() *hash.Hash + type SpectreBlockData struct + func (sd *SpectreBlockData) GetHash() *hash.Hash + func (sd *SpectreBlockData) GetParents() []uint + func (sd *SpectreBlockData) GetTimestamp() int64 + func (sd *SpectreBlockData) GetWeight() uint64 + type SyncMode byte + const DirectMode + const SubDAGMode