Documentation ¶
Index ¶
- Variables
- func BuildLevelRoot(hashes []hash.Hash256) (hash.Hash256, error)
- func ChargeFee(ctx *types.Context, useGas uint64, signer common.Address) (*amount.Amount, error)
- func ExecuteContractTx(ctx *types.Context, tx *types.Transaction, signer common.Address, TXID string) error
- func ExecuteContractTxWithEvent(ctx *types.Context, tx *types.Transaction, signer common.Address, TXID string) ([]*ctypes.Event, error)
- func NewChainCommiter(cn *Chain) *chainCommiter
- func SetVersion(h uint32, v uint16)
- func TestContractWithOutSeq(ctx *types.Context, tx *types.Transaction, signer common.Address) error
- type BlockCreator
- func (bc *BlockCreator) AddTx(tx *types.Transaction, sig common.Signature) (*etypes.Receipt, error)
- func (bc *BlockCreator) Finalize(gasLv uint16, receipts types.Receipts) (*types.Block, error)
- func (bc *BlockCreator) UnsafeAddTx(TxHash hash.Hash256, tx *types.Transaction, sig common.Signature, ...) (receipt *etypes.Receipt, err error)
- type Chain
- func (cn *Chain) ApplyEvmTransaction(ctx *types.Context, tx *types.Transaction, ti uint16, signer common.Address) ([]*ctypes.Event, *etypes.Receipt, error)
- func (cn *Chain) Close()
- func (cn *Chain) ConnectBlock(b *types.Block, SigMap map[hash.Hash256]common.Address) error
- func (cn *Chain) ExecuteTransaction(ctx *types.Context, tx *types.Transaction, TXID string) ([]*ctypes.Event, error)
- func (cn *Chain) GeneratorsInMap(GeneratorMap map[common.Address]bool, Limit int) ([]common.Address, error)
- func (cn *Chain) GetCurrentDump() string
- func (cn *Chain) Init(genesisContextData *types.ContextData) error
- func (cn *Chain) InitWith(InitGenesisHash hash.Hash256, initHash hash.Hash256, initHeight uint32, ...) error
- func (cn *Chain) MustAddService(s types.Service)
- func (cn *Chain) NewContext() *types.Context
- func (cn *Chain) Provider() types.Provider
- func (cn *Chain) ServiceByName(name string) (types.Service, error)
- func (cn *Chain) Services() []types.Service
- func (cn *Chain) Store() *Store
- func (cn *Chain) TopGenerator(TimeoutCount uint32) (common.Address, error)
- func (cn *Chain) TopGeneratorInMap(GeneratorMap map[common.Address]bool) (common.Address, uint32, error)
- func (cn *Chain) UpdateBlock(b *types.Block, SigMap map[hash.Hash256]common.Address) error
- func (cn *Chain) UpdateExecuteBlockOnContext(b *types.Block, ctx *types.Context, sm map[hash.Hash256]common.Address) (types.Receipts, error)
- func (cn *Chain) UpdateInit(genesisContextData *types.ContextData) error
- func (cn *Chain) ValidateSignature(bh *types.Header, sigs []common.Signature) error
- func (cn *Chain) WaitConnectedBlock(targetBlock uint32)
- type Committer
- type DeployContractData
- type Rank
- func (rank *Rank) Clone() *Rank
- func (rank *Rank) Equal(b *Rank) bool
- func (rank *Rank) HashSpace() hash.Hash256
- func (rank *Rank) IsZero() bool
- func (rank *Rank) Key() string
- func (rank *Rank) Less(b *Rank) bool
- func (rank *Rank) Phase() uint32
- func (s *Rank) ReadFrom(r io.Reader) (int64, error)
- func (rank *Rank) Score() uint64
- func (rank *Rank) Set(phase uint32, hashSpace hash.Hash256)
- func (rank *Rank) SetHashSpace(hashSpace hash.Hash256)
- func (rank *Rank) SetPhase(phase uint32)
- func (rank *Rank) String() string
- func (s *Rank) WriteTo(w io.Writer) (int64, error)
- type RankTable
- func (rt *RankTable) CandidateCount() int
- func (rt *RankTable) Candidates() []*Rank
- func (rt *RankTable) GeneratorsInMap(GeneratorMap map[common.Address]bool, Limit int) ([]common.Address, error)
- func (rt *RankTable) IsGenerator(addr common.Address) bool
- func (s *RankTable) ReadFrom(r io.Reader) (int64, error)
- func (rt *RankTable) TopGeneratorInMap(GeneratorMap map[common.Address]bool) (common.Address, uint32, error)
- func (rt *RankTable) TopRank(TimeoutCount uint32) (*Rank, error)
- func (s *RankTable) WriteTo(w io.Writer) (int64, error)
- type Store
- func (st *Store) AddrSeq(addr common.Address) uint64
- func (st *Store) Admins() ([]common.Address, error)
- func (st *Store) BasicFee() *amount.Amount
- func (st *Store) Block(height uint32) (*types.Block, error)
- func (st *Store) BlockGenMap() (map[common.Address]uint32, error)
- func (st *Store) ChainID() *big.Int
- func (st *Store) Close()
- func (st *Store) Contract(addr common.Address) (types.Contract, error)
- func (st *Store) Contracts() ([]types.Contract, error)
- func (st *Store) CopyContext(zipContextPath string) error
- func (st *Store) Data(cont common.Address, addr common.Address, name []byte) []byte
- func (st *Store) GenHash() hash.Hash256
- func (st *Store) Generators() ([]common.Address, error)
- func (st *Store) GeneratorsInMap(GeneratorMap map[common.Address]bool, Limit int) ([]common.Address, error)
- func (st *Store) Hash(height uint32) (hash.Hash256, error)
- func (st *Store) Header(height uint32) (*types.Header, error)
- func (st *Store) Height() uint32
- func (st *Store) InitHeight() uint32
- func (st *Store) InitTimeSlot() error
- func (st *Store) InitTimestamp() uint64
- func (st *Store) IsAdmin(addr common.Address) bool
- func (st *Store) IsContract(addr common.Address) bool
- func (st *Store) IsGenerator(addr common.Address) bool
- func (st *Store) IsUsedTimeSlot(slot uint32, key string) bool
- func (st *Store) IterBlockAfterContext(fn func(b *types.Block) error) error
- func (st *Store) LastHash() hash.Hash256
- func (st *Store) LastStatus() (uint32, hash.Hash256)
- func (st *Store) LastTimestamp() uint64
- func (st *Store) MainToken() *common.Address
- func (st *Store) Prepare() error
- func (st *Store) PrevHash() hash.Hash256
- func (st *Store) ProcessReward(ctx *types.Context, b *types.Block) (map[common.Address][]byte, error)
- func (st *Store) Receipts(height uint32) (types.Receipts, error)
- func (st *Store) StoreBlock(b *types.Block, ctx *types.Context, receipts types.Receipts) error
- func (st *Store) StoreGenesis(genHash hash.Hash256, ctd *types.ContextData) error
- func (st *Store) StoreInit(genHash hash.Hash256, initHash hash.Hash256, initHeight uint32, ...) error
- func (st *Store) TargetHeight() uint32
- func (st *Store) TopGenerator(TimeoutCount uint32) (common.Address, error)
- func (st *Store) TopGeneratorInMap(GeneratorMap map[common.Address]bool) (common.Address, uint32, error)
- func (st *Store) UpdateContext(b *types.Block, ctx *types.Context, receipts types.Receipts) error
- func (st *Store) UpdatePrepare() error
- func (st *Store) UpdateStoreGenesis(genHash hash.Hash256, ctd *types.ContextData) error
- func (st *Store) Version(h uint32) uint16
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidVersion = errors.New("invalid version") ErrInvalidHeight = errors.New("invalid height") ErrInvalidPrevHash = errors.New("invalid prev hash") ErrInvalidTimestamp = errors.New("invalid timestamp") ErrInvalidGenerator = errors.New("invalid generator") ErrApplicationIDMustBe255 = errors.New("application id must be 255") ErrAddBeforeChainInit = errors.New("add before chain init") ErrReservedID = errors.New("reserved id") ErrNotExistService = errors.New("not exist service") ErrExistServiceName = errors.New("exist service name") ErrExistServiceID = errors.New("exist service id") ErrChainClosed = errors.New("chain closed") ErrInvalidContextHash = errors.New("invalid context hash") ErrInvalidLevelRootHash = errors.New("invalid level root hash") ErrInvalidReceiptHash = errors.New("invalid receipt hash") ErrStoreClosed = errors.New("store closed") ErrInvalidChainID = errors.New("invalid chain id") ErrAlreadyGenesised = errors.New("already genesised") ErrAlreadyInitialzed = errors.New("already initialized") ErrExceedHashCount = errors.New("exceed hash count") ErrInvalidHashCount = errors.New("invalid hash count") ErrInvalidAdminAddress = errors.New("invalid admin address") ErrInvalidSeqType = errors.New("invalid sequence type") ErrUnknownTransactionMethod = errors.New("unknown transaction method") ErrInvalidTopAddress = errors.New("invalid top address") ErrInvalidTopSignature = errors.New("invalid top signature") ErrInvalidSignatureCount = errors.New("invalid signature count") ErrInsufficientCandidateCount = errors.New("insufficient candidate count") ErrInvalidPhase = errors.New("invalid phase") ErrExistAddress = errors.New("exist address") ErrExceedCandidateCount = errors.New("exceed candidate count") ErrFoundForkedBlock = errors.New("found forked block") ErrInvalidBasicFee = errors.New("invalid basic fee") ErrNotExistContract = errors.New("not exist contract") )
errors
Functions ¶
func BuildLevelRoot ¶
BuildLevelRoot returns the level root hash
func ExecuteContractTx ¶
func NewChainCommiter ¶
func NewChainCommiter(cn *Chain) *chainCommiter
func SetVersion ¶
func TestContractWithOutSeq ¶
Types ¶
type BlockCreator ¶
type BlockCreator struct {
// contains filtered or unexported fields
}
BlockCreator helps to create block
func NewBlockCreator ¶
func NewBlockCreator(cn *Chain, ctx *types.Context, Generator common.Address, TimeoutCount uint32, Timestamp uint64, gasLv uint16) *BlockCreator
NewBlockCreator returns a BlockCreator
func (*BlockCreator) AddTx ¶
func (bc *BlockCreator) AddTx(tx *types.Transaction, sig common.Signature) (*etypes.Receipt, error)
AddTx validates, executes and adds transactions
func (*BlockCreator) UnsafeAddTx ¶
func (bc *BlockCreator) UnsafeAddTx(TxHash hash.Hash256, tx *types.Transaction, sig common.Signature, signer common.Address) (receipt *etypes.Receipt, err error)
UnsafeAddTx adds transactions without signer validation if signers is not empty
type Chain ¶
Chain manages the chain data
func (*Chain) ApplyEvmTransaction ¶
func (cn *Chain) ApplyEvmTransaction(ctx *types.Context, tx *types.Transaction, ti uint16, signer common.Address) ([]*ctypes.Event, *etypes.Receipt, error)
ethereum type transaction 실행
func (*Chain) ConnectBlock ¶
ConnectBlock try to connect block to the chain
func (*Chain) ExecuteTransaction ¶
func (*Chain) GeneratorsInMap ¶
func (cn *Chain) GeneratorsInMap(GeneratorMap map[common.Address]bool, Limit int) ([]common.Address, error)
GeneratorInMap returns current top generator
func (*Chain) GetCurrentDump ¶
func (*Chain) Init ¶
func (cn *Chain) Init(genesisContextData *types.ContextData) error
Init initializes the chain
func (*Chain) InitWith ¶
func (cn *Chain) InitWith(InitGenesisHash hash.Hash256, initHash hash.Hash256, initHeight uint32, initTimestamp uint64) error
InitWith initializes the chain with snapshot informations
func (*Chain) MustAddService ¶
MustAddService adds Service but panic when has the same name service
func (*Chain) NewContext ¶
NewContext returns the context of the chain
func (*Chain) ServiceByName ¶
ServiceByName returns the service by the name
func (*Chain) TopGenerator ¶
TopGenerator returns current top generator
func (*Chain) TopGeneratorInMap ¶
func (cn *Chain) TopGeneratorInMap(GeneratorMap map[common.Address]bool) (common.Address, uint32, error)
TopRankInMap returns current top generator
func (*Chain) UpdateBlock ¶
ConnectBlock try to connect block to the chain
func (*Chain) UpdateExecuteBlockOnContext ¶
func (*Chain) UpdateInit ¶
func (cn *Chain) UpdateInit(genesisContextData *types.ContextData) error
Init initializes the chain
func (*Chain) ValidateSignature ¶
func (*Chain) WaitConnectedBlock ¶
WaitConnectedBlock is wait untile target block stored
type Committer ¶
type Committer interface { Generators() ([]common.Address, error) ValidateHeader(bh *types.Header) error ExecuteBlockOnContext(b *types.Block, ctx *types.Context, SigMap map[hash.Hash256]common.Address) (types.Receipts, error) ConnectBlockWithContext(b *types.Block, ctx *types.Context, receipts types.Receipts) error NewContext() *types.Context }
Committer enables to commit block with pre-executed context
type DeployContractData ¶
DeployContractData defines data of deploy contract tx
type Rank ¶
Rank represents the rank information of the formulator account
func InsertRankToList ¶
InsertRankToList inserts the rank by the score to the rank list
func (*Rank) SetHashSpace ¶
SetHashSpace set the hash space and update the score
type RankTable ¶
RankTable implements the proof of Generator algorithm
func (*RankTable) CandidateCount ¶
CandidateCount returns a count of the rank table
func (*RankTable) Candidates ¶
Candidates returns a candidates
func (*RankTable) GeneratorsInMap ¶
func (rt *RankTable) GeneratorsInMap(GeneratorMap map[common.Address]bool, Limit int) ([]common.Address, error)
RanksInMap returns the ranks in the map
func (*RankTable) IsGenerator ¶
IsGenerator returns the given information is correct or not
func (*RankTable) TopGeneratorInMap ¶
func (rt *RankTable) TopGeneratorInMap(GeneratorMap map[common.Address]bool) (common.Address, uint32, error)
TopRankInMap returns the top rank by the given timeout count in the given map
type Store ¶
type Store struct { sync.Mutex AddrSeqMapLock sync.Mutex AddrSeqMap map[common.Address]uint64 // contains filtered or unexported fields }
Store saves the target chain state All updates are executed in one transaction with FileSync option
func (*Store) BlockGenMap ¶
BlockGenMap returns current block gen map
func (*Store) CopyContext ¶
func (*Store) Generators ¶
Generators returns all generators of the target chain
func (*Store) GeneratorsInMap ¶
func (st *Store) GeneratorsInMap(GeneratorMap map[common.Address]bool, Limit int) ([]common.Address, error)
RanksInMap returns current top generator
func (*Store) InitHeight ¶
InitHeight returns the initial height of the target chain
func (*Store) InitTimeSlot ¶
func (*Store) InitTimestamp ¶
InitTimestamp returns the initial timestamp of the target chain
func (*Store) IsContract ¶
IsContract returns is the contract
func (*Store) IsGenerator ¶
IsGenerator returns the account is generator or not
func (*Store) IsUsedTimeSlot ¶
IsUsedTimeSlot returns timeslot is used or not
func (*Store) IterBlockAfterContext ¶
func (*Store) LastStatus ¶
LastStatus returns the recored target height, prev hash and timestamp
func (*Store) LastTimestamp ¶
LastTimestamp returns the prev timestamp of the chain
func (*Store) ProcessReward ¶
func (*Store) StoreBlock ¶
StoreBlock stores the block
func (*Store) StoreGenesis ¶
StoreGenesis stores the genesis data
func (*Store) StoreInit ¶
func (st *Store) StoreInit(genHash hash.Hash256, initHash hash.Hash256, initHeight uint32, initTimestamp uint64) error
StoreInit stores the init data
func (*Store) TargetHeight ¶
TargetHeight returns the target height of the target chain
func (*Store) TopGenerator ¶
TopGenerator returns current top generator
func (*Store) TopGeneratorInMap ¶
func (st *Store) TopGeneratorInMap(GeneratorMap map[common.Address]bool) (common.Address, uint32, error)
TopRankInMap returns current top generator
func (*Store) UpdateContext ¶
StoreBlock stores the block
func (*Store) UpdateStoreGenesis ¶
StoreGenesis stores the genesis data