Documentation ¶
Index ¶
- Constants
- Variables
- func CheckIfGenesisFileExists(networkID byte) bool
- func NewBlockHash(nb *pb.Block) string
- func NewBlockchain(networkId byte) *pb.Blockchain
- func NewCustomGenesisBlock(b *pb.Blockchain)
- func NewGenesisAccount() *account.Account
- func NewTestNetGenesisBlock(b *pb.Blockchain)
- func VerifyHash(currentHash string, prevHash string, ts string, valaddr string) error
- func WriteGenesisBlock(networkID byte, genesis *GenesisBlock) error
- type BlockFactory
- type BlockHandler
- type BlockHandlerFunc
- type BlockProxy
- type BlockProxyQueries
- type BlockV1
- type BlockValidation
- type Blockchain
- func (b *Blockchain) CreateOrLoadGenesis()
- func (b *Blockchain) GenerateID()
- func (b *Blockchain) GenerateNewBlock(validator *pb.Validator) ([]*pb.Block, *pb.Block, error)
- func (b *Blockchain) InitializeStateMachines(machineNames []string, events map[string][]fsm.EventDesc, ...)
- func (b *Blockchain) SetVersion()
- func (b *Blockchain) TriggerStateEvent(stateType string, evt string, args ...any) error
- func (b *Blockchain) ValidateBlock(nb *pb.Block) bool
- func (b *Blockchain) ValidateBlockCandidate(newBlock *pb.Block) error
- func (b *Blockchain) ValidateBlockchain() error
- type ConsensusConfig
- type GKey
- type GenKeys
- type GenesisBlock
- func (g *GenesisBlock) Coinbase() string
- func (g *GenesisBlock) Config() *any
- func (g *GenesisBlock) DNAProof() string
- func (g *GenesisBlock) Hash() any
- func (g *GenesisBlock) Hex() string
- func (g *GenesisBlock) Metadata() map[string]any
- func (g *GenesisBlock) NewKyberKeys() (p2p.P2PPrivateKey, p2p.P2PPublicKey)
- func (g *GenesisBlock) Nonce() [8]byte
- func (g *GenesisBlock) Pb() *pb.Block
- func (g *GenesisBlock) Raw() []byte
- func (g *GenesisBlock) SaveContext() error
- func (g *GenesisBlock) Sign(msg string) []byte
- func (g *GenesisBlock) String() string
- func (g *GenesisBlock) Timestamp() timestamppb.Timestamp
- type GenesisContext
- type GuardFunc
- type Proxy
- type ProxyContextKey
- type QuantosConsensus
- func (c *QuantosConsensus) AddValidator(v *pb.Validator)
- func (c *QuantosConsensus) GetNumValidators() int
- func (c *QuantosConsensus) GetTotalStakes() *big.Int
- func (c *QuantosConsensus) NewRound() (*Round, error)
- func (c *QuantosConsensus) SetConfig()
- func (c *QuantosConsensus) Start(r *Round) (*pb.Validator, error)
- type Round
- type RunFunc
- type VBlock
Constants ¶
View Source
const CUSTOM_NET = byte(0x0f0)
View Source
const LIVE_NETWORK = byte(0x0af)
View Source
const STAKE_COST_PER_BLOCK = 10
View Source
const TEST_NETWORK = byte(0x0ba)
Variables ¶
View Source
var GenesisID = hex.EncodeToString(hash.NewBlake3Hash([]byte("genesis_kp")))
Functions ¶
func NewBlockHash ¶
func NewBlockchain ¶
func NewBlockchain(networkId byte) *pb.Blockchain
func NewCustomGenesisBlock ¶
func NewCustomGenesisBlock(b *pb.Blockchain)
func NewGenesisAccount ¶
func NewTestNetGenesisBlock ¶
func NewTestNetGenesisBlock(b *pb.Blockchain)
func VerifyHash ¶
func WriteGenesisBlock ¶
func WriteGenesisBlock(networkID byte, genesis *GenesisBlock) error
Types ¶
type BlockFactory ¶
type BlockFactory interface { CreateEmpty() interface{} CreateGenesis() *GenesisBlock Set(key string, value interface{}) Validate() bool Build() *pb.Block }
func GetBlockFactory ¶
func GetBlockFactory(bf BlockFactory) BlockFactory
type BlockHandler ¶
type BlockHandlerFunc ¶
func (BlockHandlerFunc) Apply ¶
func (b BlockHandlerFunc) Apply(original *BlockV1, blockEdits *BlockV1)
func (BlockHandlerFunc) Modify ¶
func (b BlockHandlerFunc) Modify(original *BlockV1, proxy *VBlock)
func (BlockHandlerFunc) Parse ¶
func (b BlockHandlerFunc) Parse(original *BlockV1, proxy *VBlock)
func (BlockHandlerFunc) Verify ¶
func (b BlockHandlerFunc) Verify(original *BlockV1, proxy *VBlock)
type BlockProxy ¶
type BlockProxy interface { Initialize(chainID string, callerAccount account.Account) error IsAllowed(aclType int, callerAccount account.Account) bool CreateBlankBLock() *pb.Block CopyBlock(b *pb.Block) *pb.Block FinalizeBlock(b *pb.Block) error GetRawBlock(height uint32) (*pb.Block, error) AddBlockToValidationQueue(b *pb.Block) ValidateAndSign(b *pb.Block) error }
BlockProxy protects the existing block by filtering requests and avoiding unwanted tempering
type BlockProxyQueries ¶
type BlockProxyQueries uint32
const ( BPQ BlockProxyQueries = iota INIT CREATEBLANK COPY FINALIZE GETRAW ADDTOVALQUEUE VALANDSIGN )
type BlockValidation ¶
type Blockchain ¶
type Blockchain struct { SemVer version.SemVer GenesisBlock []byte ChainStates map[string]*fsm.FSM BlockVals *BlockValidation *pb.Blockchain Bootnodes []interface{} // contains filtered or unexported fields }
func (*Blockchain) CreateOrLoadGenesis ¶
func (b *Blockchain) CreateOrLoadGenesis()
func (*Blockchain) GenerateID ¶
func (b *Blockchain) GenerateID()
func (*Blockchain) GenerateNewBlock ¶
func (*Blockchain) InitializeStateMachines ¶
func (*Blockchain) SetVersion ¶
func (b *Blockchain) SetVersion()
func (*Blockchain) TriggerStateEvent ¶
func (b *Blockchain) TriggerStateEvent(stateType string, evt string, args ...any) error
func (*Blockchain) ValidateBlock ¶
func (b *Blockchain) ValidateBlock(nb *pb.Block) bool
func (*Blockchain) ValidateBlockCandidate ¶
func (b *Blockchain) ValidateBlockCandidate(newBlock *pb.Block) error
func (*Blockchain) ValidateBlockchain ¶
func (b *Blockchain) ValidateBlockchain() error
type ConsensusConfig ¶
type GenesisBlock ¶
type GenesisBlock struct { NetworkID byte Account *account.Account `json:"-"` Address string CreationDate int64 Epoch uint32 GenesisValidators []*pb.Validator Block *pb.Block // contains filtered or unexported fields }
func NewLiveGenesisBlock ¶
func NewLiveGenesisBlock() *GenesisBlock
func (*GenesisBlock) Coinbase ¶
func (g *GenesisBlock) Coinbase() string
func (*GenesisBlock) Config ¶
func (g *GenesisBlock) Config() *any
func (*GenesisBlock) DNAProof ¶
func (g *GenesisBlock) DNAProof() string
func (*GenesisBlock) Hash ¶
func (g *GenesisBlock) Hash() any
func (*GenesisBlock) Hex ¶
func (g *GenesisBlock) Hex() string
func (*GenesisBlock) Metadata ¶
func (g *GenesisBlock) Metadata() map[string]any
func (*GenesisBlock) NewKyberKeys ¶
func (g *GenesisBlock) NewKyberKeys() (p2p.P2PPrivateKey, p2p.P2PPublicKey)
func (*GenesisBlock) Nonce ¶
func (g *GenesisBlock) Nonce() [8]byte
func (*GenesisBlock) Pb ¶
func (g *GenesisBlock) Pb() *pb.Block
func (*GenesisBlock) Raw ¶
func (g *GenesisBlock) Raw() []byte
func (*GenesisBlock) SaveContext ¶
func (g *GenesisBlock) SaveContext() error
func (*GenesisBlock) Sign ¶
func (g *GenesisBlock) Sign(msg string) []byte
func (*GenesisBlock) String ¶
func (g *GenesisBlock) String() string
func (*GenesisBlock) Timestamp ¶
func (g *GenesisBlock) Timestamp() timestamppb.Timestamp
type GenesisContext ¶
type GenesisContext struct {
// contains filtered or unexported fields
}
type Proxy ¶
type Proxy struct { BlockProxy // contains filtered or unexported fields }
type ProxyContextKey ¶
type ProxyContextKey string
type QuantosConsensus ¶
type QuantosConsensus struct { Round int Validators []*pb.Validator NumValidators int TotalStakes *big.Int Config *ConsensusConfig }
func (*QuantosConsensus) AddValidator ¶
func (c *QuantosConsensus) AddValidator(v *pb.Validator)
func (*QuantosConsensus) GetNumValidators ¶
func (c *QuantosConsensus) GetNumValidators() int
func (*QuantosConsensus) GetTotalStakes ¶
func (c *QuantosConsensus) GetTotalStakes() *big.Int
func (*QuantosConsensus) NewRound ¶
func (c *QuantosConsensus) NewRound() (*Round, error)
func (*QuantosConsensus) SetConfig ¶
func (c *QuantosConsensus) SetConfig()
Click to show internal directories.
Click to hide internal directories.