A CellFrame.Consensus module is designed to work with a consensus. This module includes the following classes:
CellFrame.Consensus.DagPoa
A DAG PoA class.CellFrame.Consensus.Block
A chain block class.CellFrame.Consensus.ChainCSDag
A certificate class.CellFrame.Consensus.DAG
A directed acyclic graph class.CellFrame.Consensus.GDB
A global database class.class CellFrame.Consensus.DagPoa
This class representes a DAG chain with a PoA consensus.
staic method CellFrame.Consensus.DagPoa.setPresign(chain: CellFrame.Chain.Chain, callbackFunc: Callable, arg: object) -> str
Sets a presign callback function. The chain
is a chain with a PoA consensus, it must be a Chain
object. The callbackFunc
is a callback function, it must have the f(chain: CellFrame.Chain.Chain, event: CellFrame.Consensus.DagEvent, arg: object) -> int
signature. The arg
is an object, that is passed to the third arguments into the callback function.
class CellFrame.Consensus.Block
This class representes a chain block.
getter CellFrame.Consensus.Block.hash -> DAP.Crypto.HashFast
Gets a hash of the block.
getter CellFrame.Consensus.Block.version -> int
Gets a version of the block.
getter CellFrame.Consensus.Block.cellId -> CellFrame.Chain.ChainCellID
Gets a cell ID of the block.
getter CellFrame.Consensus.Block.chainId -> CellFrame.Chain.ChainID
Gets a chain ID of the block.
getter CellFrame.Consensus.Block.created -> dataetime.datetime
Gets the time and date when the block was created.
getter CellFrame.Consensus.Block.metaData -> Dict
Gets metadata. Returns a dictionary, which has the following structure {"blockPrevHash": HashFast, "blockAnchorHash": HashFast, "merkle": HashFast, "links": List[HashFast], "isGenesis": bool, "nonce": int, "nonce2": int}
getter CellFrame.Consensus.Block.datums -> List[CellFrame.Common.Datum]
Gets the list containing datums.
getter CellFrame.Consensus.Block.signs -> List[DAP.Crypto.Sign]
Gets the list containing signs.
static method CellFrame.Consensus.Block.fromAtom(atomPtr: ChainAtomPtr, atomSize: int) -> CellFrame.Consensus.Block
Gets a block by a pointer to the atom. The atomPtr
is a pointer to the atom. The atomSize
is a atom size. Returns an instanse of the Block
object.
class CellFrame.Consensus.ChainCSDag
This class representes a DAG chain with a consensus.
object method CellFrame.Consensus.ChainCSDag.findByHash(hash: DAP.Crypto.HashFast) -> CellFrame.Consensus.DagEvent
Finds a DAG event by a hash. The hash
must be a HashFast
object. Returns a instance of a DagEvent
object.
class CellFrame.Consensus.DAG
This class representes a directed acyclic graph chain.
static method CellFrame.Consensus.DAG.fromAtom(atomPtr: ChainAtomPtr, atomSize: int) -> CellFrame.Consensus.DAG
Gets a DAG by a pointer to the atom. The atomPtr
is a pointer to the atom. The atomSize
is a atom size. Returns an instanse of the DAG
object.
getter CellFrame.Consensus.DAG.hash -> DAP.Crypto.HashFast
Gets a hash of the DAG.
getter CellFrame.Consensus.DAG.version -> int
Gets a version of the DAG.
getter CellFrame.Consensus.DAG.roundId -> int
Gets a round ID of the DAG.
getter CellFrame.Consensus.DAG.created -> dataetime.datetime
Gets the time and date when the DAG was created.
getter CellFrame.Consensus.DAG.chainId -> CellFrame.Chain.ChainID
Gets a chain ID of the DAG.
getter CellFrame.Consensus.DAG.cellId -> CellFrame.Chain.ChainCellID
Gets a cell ID of the DAG.
getter CellFrame.Consensus.DAG.hashCount -> int
Gets a count of hashes of the DAG.
getter CellFrame.Consensus.DAG.signsCount -> int
Gets a count of signs of the DAG.
getter CellFrame.Consensus.DAG.links -> List[DAP.Crypto.HashFast]
Gets the list containing links.
getter CellFrame.Consensus.DAG.datum -> CellFrame.Common.Datum
Gets the datum.
getter CellFrame.Consensus.DAG.signs -> List[DAP.Crypto.Sign]
Gets the list containing signs.
class CellFrame.Consensus.DagPoa
This class representes a no-consensus chain.
object method CellFrame.Consensus.GDB.new(chain: CellFrame.Chain.Chain) -> int
Creates a new GDB in a chain. The chain
must be a Chain
object. Returns 0
if successful, otherwise an error code less than zero.
object method CellFrame.Consensus.GDB.delete(chain: CellFrame.Chain.Chain) -> int
Deletes a GDB in a chain. The chain
must be a Chain
object. Returns 0
if successful, otherwise an error code less than zero.
object method CellFrame.Consensus.GDB.getGroup(chain: CellFrame.Chain.Chain) -> int
Gets a group name. The chain
must be a Chain
object. Returns a string, that conteins the name.