Documentation
¶
Overview ¶
Copyright (C) 2018 go-gamc authors
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Copyright (C) 2018 go-gamc authors ¶
This file is part of the go-gamc library.
the go-gamc library 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.
the go-gamc library 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 the go-gamc library. If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func HashPbBlock(pbBlock *corepb.Block) (byteutils.Hash, error)
- type Account
- type AccountManager
- type AccountState
- type Address
- type AddressType
- type Block
- func (b *Block) Begin() error
- func (b *Block) CalcHash() byteutils.Hash
- func (b *Block) Coinbase() *Address
- func (b *Block) Commit()
- func (b *Block) FromProto(msg proto.Message) error
- func (b *Block) Hash() byteutils.Hash
- func (b *Block) Header() *BlockHeader
- func (b *Block) Height() uint64
- func (b *Block) LinkParentBlock(chain *BlockChain, parentBlock *Block) error
- func (b *Block) ParentHash() byteutils.Hash
- func (b *Block) RollBack()
- func (b *Block) SetHeight(height uint64)
- func (b *Block) SetParent(hash byteutils.Hash)
- func (b *Block) SetTimestamp(time int64)
- func (b *Block) SetWorldState(parent *Block)
- func (b *Block) Sign(signature keystore.Signature) error
- func (b *Block) SignHash() byteutils.Hash
- func (b *Block) Signature() *corepb.Signature
- func (b *Block) StateRoot() byteutils.Hash
- func (b *Block) Timestamp() int64
- func (b *Block) ToProto() (proto.Message, error)
- func (b *Block) Transactions() Transactions
- func (b *Block) TxsRoot() byteutils.Hash
- func (b *Block) VerifyExecution() error
- func (b *Block) VerifyIntegrity(chainId uint32, consensus Consensus) error
- func (b *Block) Witness() []*Witness
- func (b *Block) WorldState() WorldState
- type BlockChain
- func (bc *BlockChain) BlockPool() *BlockPool
- func (bc *BlockChain) ChainId() uint32
- func (bc *BlockChain) Consensus() Consensus
- func (bc *BlockChain) CurrentBlock() *Block
- func (bc *BlockChain) FixedBlock() *Block
- func (bc *BlockChain) GenesisBlock() *Block
- func (bc *BlockChain) GetBlock(hash byteutils.Hash) *Block
- func (bc *BlockChain) GetBlockOnCanonicalChainByHash(blockHash byteutils.Hash) *Block
- func (bc *BlockChain) GetBlockOnCanonicalChainByHeight(height uint64) *Block
- func (bc *BlockChain) IsActiveSyncing() bool
- func (bc *BlockChain) LoadBlockFromStorage(blockHash byteutils.Hash) *Block
- func (bc *BlockChain) LoadFixedFromStorage() (*Block, error)
- func (bc *BlockChain) LoadGenesisFromStorage() (*Block, error)
- func (bc *BlockChain) LoadTailFromStorage() (*Block, error)
- func (bc *BlockChain) SetFixedBlock(block *Block)
- func (bc *BlockChain) SetSyncEngine(syncEngine Synchronize)
- func (bc *BlockChain) SetTailBlock(newTail *Block) error
- func (bc *BlockChain) Setup(gamc gamc) error
- func (bc *BlockChain) Start()
- func (bc *BlockChain) StartActiveSync() bool
- func (bc *BlockChain) Stop()
- func (bc *BlockChain) StoreBlockToStorage(block *Block) error
- func (bc *BlockChain) StoreFIXEDHashToStorage(block *Block) error
- func (bc *BlockChain) StoreTailHashToStorage(block *Block) error
- func (bc *BlockChain) TailBlock() *Block
- func (bc *BlockChain) TxPool() *TxPool
- type BlockHeader
- func (h *BlockHeader) ChainId() uint32
- func (h *BlockHeader) Coinbase() *Address
- func (h *BlockHeader) Extra() []byte
- func (h *BlockHeader) FromProto(msg proto.Message) error
- func (h *BlockHeader) Hash() []byte
- func (h *BlockHeader) Height() uint64
- func (h *BlockHeader) ParentHash() []byte
- func (h *BlockHeader) PsecData() *PsecData
- func (h *BlockHeader) SetAccountsRoot(hash byteutils.Hash)
- func (h *BlockHeader) SetChainId(id uint32)
- func (h *BlockHeader) SetCoinbase(addr Address)
- func (h *BlockHeader) SetHash(hash byteutils.Hash)
- func (h *BlockHeader) SetHeight(height uint64)
- func (h *BlockHeader) SetParentHash(hash []byte)
- func (h *BlockHeader) SetPsecData(pd PsecData)
- func (h *BlockHeader) SetTimestamp(t int64)
- func (h *BlockHeader) SetTxsRoot(hash byteutils.Hash)
- func (h *BlockHeader) SetWitnessReward(reward int64)
- func (h *BlockHeader) Sign() *corepb.Signature
- func (h *BlockHeader) Timestamp() int64
- func (h *BlockHeader) ToProto() (proto.Message, error)
- func (h *BlockHeader) TxsRoot() []byte
- func (h *BlockHeader) WitnessReward() *big.Int
- func (h *BlockHeader) Witnesses() []*Witness
- type BlockPool
- type Consensus
- type ConsensusState
- type ContractSet
- type Genesis
- type HandledData
- type Iterator
- type Synchronize
- type Token
- type Transaction
- func (tx *Transaction) From() *Address
- func (tx *Transaction) FromProto(msg proto.Message) error
- func (tx *Transaction) Hash() byteutils.Hash
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) Timestamp() int64
- func (tx *Transaction) To() *Address
- func (tx *Transaction) ToProto() (proto.Message, error)
- func (tx *Transaction) VerifyIntegrity(chainId uint32) error
- type TransactionSet
- type Transactions
- type TxPool
- type TxWorldState
- type Voter
- type Witness
- type WorldState
Constants ¶
const ( // AddressPaddingLength the length of headpadding in byte AddressPaddingLength = 1 // AddressPaddingIndex the index of headpadding bytes AddressPaddingIndex = 0 // AddressTypeLength the length of address type in byte AddressTypeLength = 1 // AddressTypeIndex the index of address type bytes AddressTypeIndex = 1 AddressVersionLength = 1 // AddressVersionIndex the index of address version bytes AddressVersionIndex = 2 // AddressDataLength the length of data of address in byte. AddressDataLength = 20 // AddressChecksumLength the checksum of address in byte. AddressChecksumLength = 4 AddressLength = AddressPaddingLength + AddressTypeLength + AddressVersionLength + AddressDataLength + AddressChecksumLength // AddressDataEnd the end of the address data AddressDataEnd = 23 // AddressBase58Length length of base58(Address.address) AddressBase58Length = 37 // PublicKeyDataLength length of public key PublicKeyDataLength = 32 )
const ( // ChunkSize is the size of blocks in a chunk ChunkSize = 32 // Tail Key in storage Tail = "blockchain_tail" // Fixed in storage FIXED = "blockchain_fixed" )
const ( MessageTypeNewBlock = "newblock" MessageTypeParentBlockDownloadRequest = "dlblock" MessageTypeBlockDownloadResponse = "dlreply" MessageTypeNewTx = "newtx" )
MessageType
const (
AddressVersion = 0x80
)
const (
DefaultGenesisPath = "conf/genesis.yaml"
)
const (
NoSender = ""
)
constants
const (
Padding byte = 0x68
)
const
Variables ¶
var ( ErrBalanceInsufficient = errors.New("cannot subtract a value which is bigger than current balance") ErrFrozenFundInsufficient = errors.New("cannot subtract a value which is bigger than frozen fund") ErrPledgeFundInsufficient = errors.New("cannot subtract a value which is bigger than pledge fund") ErrAccountNotFound = errors.New("cannot found account in storage") ErrContractAccountNotFound = errors.New("cannot found contract account in storage please check contract address is valid or deploy is success") )
Errors
var ( ErrUnknownAncestor = errors.New("unknown ancestor") ErrFutureBlock = errors.New("block in the future") ErrInvalidNumber = errors.New("invalid block number") )
var ( GenesisHash = []byte{10, 107, 126, 98, 237, 120, 159, 139, 240, 67, 134, 227, 127, 108, 206, 197, 236, 51, 176, 26, 218, 146, 194, 126, 194, 149, 216, 63, 18, 108, 55, 102} GenesisTimestamp = int64(1561615240) )
Genesis Block Hash
var ( ErrInvalidAddress = errors.New("address: invalid address") ErrInvalidAddressFormat = errors.New("address: invalid address format") ErrInvalidAddressType = errors.New("address: invalid address type") ErrInvalidAddressChecksum = errors.New("address: invalid address checksum") ErrInvalidArgument = errors.New("invalid argument(s)") ErrNilArgument = errors.New("argument(s) is nil") ErrInvalidAmount = errors.New("invalid amount") ErrInvalidProtoToBlock = errors.New("protobuf message cannot be converted into Block") ErrInvalidProtoToBlockHeader = errors.New("protobuf message cannot be converted into BlockHeader") ErrInvalidProtoToTransaction = errors.New("protobuf message cannot be converted into Transaction") ErrInvalidProtoToWitness = errors.New("protobuf message cannot be converted into Witness") ErrInvalidProtoToPsecData = errors.New("protobuf message cannot be converted into PsecData") ErrDuplicatedBlock = errors.New("duplicated block") ErrInvalidChainID = errors.New("invalid transaction chainID") ErrInvalidTransactionHash = errors.New("invalid transaction hash") ErrInvalidBlockHeaderChainID = errors.New("invalid block header chainId") ErrInvalidBlockHash = errors.New("invalid block hash") ErrInvalidTransactionSigner = errors.New("invalid transaction signer") ErrInvalidPublicKey = errors.New("invalid public key") ErrMissingParentBlock = errors.New("cannot find the block's parent block in storage") ErrInvalidBlockCannotFindParentInLocalAndTrySync = errors.New("invalid block received, sync its parent from others") ErrInvalidBlockCannotFindParentInLocalAndTryDownload = errors.New("invalid block received, download its parent from others") ErrLinkToWrongParentBlock = errors.New("link the block to a block who is not its parent") ErrCloneAccountState = errors.New("failed to clone account state") ErrInvalidBlockStateRoot = errors.New("invalid block state root hash") ErrInvalidBlockTxsRoot = errors.New("invalid block txs root hash") )
var (
BlockHashLength = 32
)
var (
ErrTxPoolFull = errors.New("tx pool is full")
)
Functions ¶
Types ¶
type Account ¶
type Account interface { Address() byteutils.Hash Balance() *big.Int FrozenFund() *big.Int PledgeFund() *big.Int Nonce() uint64 CreditIndex() *big.Int VarsHash() byteutils.Hash Clone() (Account, error) ToBytes() ([]byte, error) FromBytes(bytes []byte, storage cdb.Storage) error IncrNonce() AddBalance(value *big.Int) error SubBalance(value *big.Int) error AddFrozenFund(value *big.Int) error SubFrozenFund(value *big.Int) error AddPledgeFund(value *big.Int) error SubPledgeFund(value *big.Int) error AddCreditIndex(value *big.Int) error SubCreditIndex(value *big.Int) error Put(key []byte, value []byte) error Get(key []byte) ([]byte, error) Del(key []byte) error Iterator(prefix []byte) (Iterator, error) }
Account Interface
type AccountManager ¶
type AccountManager interface { NewAccount(passphrase []byte) (*Address, string, error) UpdateAccount(address string, oldPassphrase, newPassphrase []byte) error Sign(address *Address, hash []byte) ([]byte, error) SignBlock(address *Address, block *Block) error Verify(pubKey []byte, message, sig []byte) bool }
type AccountState ¶
type AccountState interface { RootHash() byteutils.Hash Flush() error Abort() error DirtyAccounts() ([]Account, error) Accounts() ([]Account, error) Clone() (AccountState, error) Replay(AccountState) error GetOrCreateAccount(byteutils.Hash) (Account, error) }
AccountState Interface
func NewAccountState ¶
NewAccountState create a new account state
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func AddressParse ¶
func AddressParseFromBytes ¶
func NewAddress ¶
func NewAddressFromPublicKey ¶
NewAddressFromPublicKey return new address from publickey bytes
type AddressType ¶
type AddressType byte
const ( AccountAddress AddressType = 0x63 + iota ContractAddress )
const UndefinedAddressType AddressType = 0x00
UndefinedAddressType undefined
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block
func LoadBlockFromStorage ¶
func LoadBlockFromStorage(hash byteutils.Hash, chain *BlockChain) (*Block, error)
LoadBlockFromStorage return a block from storage
func NewBlockWithHeader ¶
func NewBlockWithHeader(header *BlockHeader) *Block
func NewGenesis ¶
func NewGenesis(cfg *config.Config, chain *BlockChain) (*Block, error)
func (*Block) Header ¶
func (b *Block) Header() *BlockHeader
func (*Block) LinkParentBlock ¶
func (b *Block) LinkParentBlock(chain *BlockChain, parentBlock *Block) error
LinkParentBlock link parent block, return true if hash is the same; false otherwise.
func (*Block) ParentHash ¶
ParentHash return parent hash.
func (*Block) SetTimestamp ¶
func (*Block) SetWorldState ¶
func (*Block) Transactions ¶
func (b *Block) Transactions() Transactions
Transactions returns block transactions
func (*Block) VerifyExecution ¶
VerifyExecution execute the block and verify the execution result.
func (*Block) VerifyIntegrity ¶
VerifyIntegrity verify block's hash, txs' integrity and consensus acceptable.
func (*Block) WorldState ¶
func (b *Block) WorldState() WorldState
WorldState return the world state of the block
type BlockChain ¶
type BlockChain struct {
// contains filtered or unexported fields
}
BlockChain
func NewBlockChain ¶
NewBlockChain
func (*BlockChain) BlockPool ¶
func (bc *BlockChain) BlockPool() *BlockPool
func (*BlockChain) ChainId ¶
func (bc *BlockChain) ChainId() uint32
func (*BlockChain) Consensus ¶
func (bc *BlockChain) Consensus() Consensus
func (*BlockChain) CurrentBlock ¶
func (bc *BlockChain) CurrentBlock() *Block
func (*BlockChain) FixedBlock ¶
func (bc *BlockChain) FixedBlock() *Block
func (*BlockChain) GenesisBlock ¶
func (bc *BlockChain) GenesisBlock() *Block
func (*BlockChain) GetBlock ¶
func (bc *BlockChain) GetBlock(hash byteutils.Hash) *Block
GetBlock return block of given hash from local storage and detachedBlocks.
func (*BlockChain) GetBlockOnCanonicalChainByHash ¶
func (bc *BlockChain) GetBlockOnCanonicalChainByHash(blockHash byteutils.Hash) *Block
GetBlockOnCanonicalChainByHash check if a block is on canonical chain
func (*BlockChain) GetBlockOnCanonicalChainByHeight ¶
func (bc *BlockChain) GetBlockOnCanonicalChainByHeight(height uint64) *Block
GetBlockOnCanonicalChainByHeight return block in given height
func (*BlockChain) IsActiveSyncing ¶
func (bc *BlockChain) IsActiveSyncing() bool
IsActiveSyncing returns true if being syncing
func (*BlockChain) LoadBlockFromStorage ¶
func (bc *BlockChain) LoadBlockFromStorage(blockHash byteutils.Hash) *Block
func (*BlockChain) LoadFixedFromStorage ¶
func (bc *BlockChain) LoadFixedFromStorage() (*Block, error)
LoadFixedFromStorage load FIXED
func (*BlockChain) LoadGenesisFromStorage ¶
func (bc *BlockChain) LoadGenesisFromStorage() (*Block, error)
LoadGenesisFromStorage load genesis
func (*BlockChain) LoadTailFromStorage ¶
func (bc *BlockChain) LoadTailFromStorage() (*Block, error)
LoadTailFromStorage load tail block
func (*BlockChain) SetFixedBlock ¶
func (bc *BlockChain) SetFixedBlock(block *Block)
func (*BlockChain) SetSyncEngine ¶
func (bc *BlockChain) SetSyncEngine(syncEngine Synchronize)
SetSyncEngine set sync engine
func (*BlockChain) SetTailBlock ¶
func (bc *BlockChain) SetTailBlock(newTail *Block) error
func (*BlockChain) Setup ¶
func (bc *BlockChain) Setup(gamc gamc) error
func (*BlockChain) StartActiveSync ¶
func (bc *BlockChain) StartActiveSync() bool
StartActiveSync start active sync task
func (*BlockChain) StoreBlockToStorage ¶
func (bc *BlockChain) StoreBlockToStorage(block *Block) error
StoreBlockToStorage store block
func (*BlockChain) StoreFIXEDHashToStorage ¶
func (bc *BlockChain) StoreFIXEDHashToStorage(block *Block) error
StoreFIXEDHashToStorage store FIXED block hash
func (*BlockChain) StoreTailHashToStorage ¶
func (bc *BlockChain) StoreTailHashToStorage(block *Block) error
func (*BlockChain) TailBlock ¶
func (bc *BlockChain) TailBlock() *Block
func (*BlockChain) TxPool ¶
func (bc *BlockChain) TxPool() *TxPool
type BlockHeader ¶
type BlockHeader struct {
// contains filtered or unexported fields
}
BlockHeader
func CopyHeader ¶
func CopyHeader(h *BlockHeader) *BlockHeader
CopyHeader creates a deep copy of a block header to prevent side effects from modifying a header variable.
func (*BlockHeader) ChainId ¶
func (h *BlockHeader) ChainId() uint32
func (*BlockHeader) Coinbase ¶
func (h *BlockHeader) Coinbase() *Address
func (*BlockHeader) Extra ¶
func (h *BlockHeader) Extra() []byte
func (*BlockHeader) FromProto ¶
func (h *BlockHeader) FromProto(msg proto.Message) error
FromProto converts proto BlockHeader to domain BlockHeader
func (*BlockHeader) Hash ¶
func (h *BlockHeader) Hash() []byte
func (*BlockHeader) Height ¶
func (h *BlockHeader) Height() uint64
func (*BlockHeader) ParentHash ¶
func (h *BlockHeader) ParentHash() []byte
func (*BlockHeader) PsecData ¶
func (h *BlockHeader) PsecData() *PsecData
func (*BlockHeader) SetAccountsRoot ¶
func (h *BlockHeader) SetAccountsRoot(hash byteutils.Hash)
func (*BlockHeader) SetChainId ¶
func (h *BlockHeader) SetChainId(id uint32)
func (*BlockHeader) SetCoinbase ¶
func (h *BlockHeader) SetCoinbase(addr Address)
func (*BlockHeader) SetHash ¶
func (h *BlockHeader) SetHash(hash byteutils.Hash)
func (*BlockHeader) SetHeight ¶
func (h *BlockHeader) SetHeight(height uint64)
func (*BlockHeader) SetParentHash ¶
func (h *BlockHeader) SetParentHash(hash []byte)
func (*BlockHeader) SetPsecData ¶
func (h *BlockHeader) SetPsecData(pd PsecData)
func (*BlockHeader) SetTimestamp ¶
func (h *BlockHeader) SetTimestamp(t int64)
func (*BlockHeader) SetTxsRoot ¶
func (h *BlockHeader) SetTxsRoot(hash byteutils.Hash)
func (*BlockHeader) SetWitnessReward ¶
func (h *BlockHeader) SetWitnessReward(reward int64)
func (*BlockHeader) Sign ¶
func (h *BlockHeader) Sign() *corepb.Signature
func (*BlockHeader) Timestamp ¶
func (h *BlockHeader) Timestamp() int64
func (*BlockHeader) ToProto ¶
func (h *BlockHeader) ToProto() (proto.Message, error)
ToProto converts domain BlockHeader to proto BlockHeader
func (*BlockHeader) TxsRoot ¶
func (h *BlockHeader) TxsRoot() []byte
func (*BlockHeader) WitnessReward ¶
func (h *BlockHeader) WitnessReward() *big.Int
func (*BlockHeader) Witnesses ¶
func (h *BlockHeader) Witnesses() []*Witness
type BlockPool ¶
type BlockPool struct {
// contains filtered or unexported fields
}
func NewBlockPool ¶
NewBlockPool return new #BlockPool instance.
func (*BlockPool) PushAndBroadcast ¶
func (*BlockPool) PushAndRelay ¶
PushAndRelay push block into block pool and relay it.
func (*BlockPool) RegisterInNetwork ¶
RegisterInNetwork register message subscriber in network.
type Consensus ¶
type Consensus interface { Setup(gamc gamc) Start() Stop() EnableMining() // DisableMining() // IsEnable() bool ResumeMining() SuspendMining() // IsSuspend() bool // UpdateFixedBlock() VerifyBlock(block *Block) error AccumulateRewards(addr Address, reward *big.Int) error }
ConsensusEngine
type ConsensusState ¶
type ConsensusState interface { RootHash() *corepb.ConsensusRoot String() string Clone() (ConsensusState, error) Replay(ConsensusState) error Proposer() byteutils.Hash Timestamp() int64 NextConsensusState(int64, WorldState) (ConsensusState, error) Term() ([]byteutils.Hash, error) TermRoot() byteutils.Hash }
ConsensusState interface of consensus state
type ContractSet ¶
type ContractSet struct {
// contains filtered or unexported fields
}
ContractSet
func (*ContractSet) NormalContracts ¶
func (cs *ContractSet) NormalContracts() uint64
func (*ContractSet) TemplateContracts ¶
func (cs *ContractSet) TemplateContracts() uint64
func (*ContractSet) TemplateContractsRefs ¶
func (cs *ContractSet) TemplateContractsRefs() uint64
func (*ContractSet) Value ¶
func (cs *ContractSet) Value() *big.Int
type Genesis ¶
type Genesis struct { ChainId uint32 `yaml:"chain_id"` Token []Token `yaml:"token"` Coinbase string `yaml:"coinbase"` StandbyNode []string `yaml:"standby_node"` Foundation Token `yaml:"foundation"` FoundingTeam Token `yaml:"founding_team"` NodeDeployment Token `yaml:"node_deployment"` EcologicalConstruction Token `yaml:"ecological_construction"` FoundingCommunity Token `yaml:"founding_community"` }
func LoadGenesisConf ¶
type HandledData ¶
type HandledData struct {
// contains filtered or unexported fields
}
CreditScore
func (*HandledData) HandledContracts ¶
func (hd *HandledData) HandledContracts() *ContractSet
func (*HandledData) HandledTxs ¶
func (hd *HandledData) HandledTxs() *TransactionSet
func (*HandledData) PrevRoundProductions ¶
func (hd *HandledData) PrevRoundProductions() int
func (*HandledData) Value ¶
func (hd *HandledData) Value() *big.Int
func (*HandledData) WinningTimes ¶
func (hd *HandledData) WinningTimes() uint64
type Synchronize ¶
type Synchronize interface { Start() Stop() StartActiveSync() bool StopActiveSync() WaitingForFinish() IsActiveSyncing() bool }
Synchronize interface of sync service
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction
func NewContractCreation ¶
func NewContractCreation(nonce uint64, from *Address, amount *big.Int) *Transaction
NewContractCreation
func NewTransaction ¶
func NewTransaction(nonce uint64, from, to *Address, amount *big.Int) *Transaction
NewTransaction
func (*Transaction) FromProto ¶
func (tx *Transaction) FromProto(msg proto.Message) error
FromProto converts proto Tx to domain Tx
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() byteutils.Hash
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() uint64
func (*Transaction) Timestamp ¶
func (tx *Transaction) Timestamp() int64
func (*Transaction) ToProto ¶
func (tx *Transaction) ToProto() (proto.Message, error)
ToProto converts domain Tx to proto Tx
func (*Transaction) VerifyIntegrity ¶
func (tx *Transaction) VerifyIntegrity(chainId uint32) error
VerifyIntegrity return transaction verify result, including Hash and Signature.
type TransactionSet ¶
type TransactionSet struct {
// contains filtered or unexported fields
}
TransactionSet
func (*TransactionSet) ContractTxs ¶
func (ts *TransactionSet) ContractTxs() uint64
func (*TransactionSet) NormalTxs ¶
func (ts *TransactionSet) NormalTxs() uint64
func (*TransactionSet) Value ¶
func (ts *TransactionSet) Value() *big.Int
type TxPool ¶
type TxPool struct {
// contains filtered or unexported fields
}
TxPool
func (*TxPool) GetAccountTxAmount ¶
GetAccountTxAmount
type TxWorldState ¶
type TxWorldState interface { AccountsRoot() byteutils.Hash TxsRoot() byteutils.Hash CheckAndUpdate() ([]interface{}, error) Reset(addr byteutils.Hash, isResetChangeLog bool) error Close() error Accounts() ([]Account, error) GetOrCreateAccount(addr byteutils.Hash) (Account, error) GetTx(txHash byteutils.Hash) ([]byte, error) PutTx(txHash byteutils.Hash, txBytes []byte) error GetBlockHashByHeight(height uint64) ([]byte, error) GetBlock(txHash byteutils.Hash) ([]byte, error) }
TxWorldState is the world state of a single transaction
type Voter ¶
type Voter struct {
// contains filtered or unexported fields
}
Voter
func (*Voter) HandledData ¶
func (v *Voter) HandledData() *HandledData
type Witness ¶
type Witness struct {
// contains filtered or unexported fields
}
func (*Witness) AddFollower ¶
type WorldState ¶
type WorldState interface { Begin() error Commit() error RollBack() error Prepare(interface{}) (TxWorldState, error) Reset(addr byteutils.Hash, isResetChangeLog bool) error Flush() error Abort() error NextConsensusState(int64) (ConsensusState, error) SetConsensusState(ConsensusState) LoadAccountsRoot(byteutils.Hash) error LoadTxsRoot(byteutils.Hash) error Clone() (WorldState, error) AccountsRoot() byteutils.Hash TxsRoot() byteutils.Hash Accounts() ([]Account, error) GetOrCreateAccount(addr byteutils.Hash) (Account, error) GetTx(txHash byteutils.Hash) ([]byte, error) PutTx(txHash byteutils.Hash, txBytes []byte) error GetBlockHashByHeight(height uint64) ([]byte, error) GetBlock(txHash byteutils.Hash) ([]byte, error) }
WorldState interface of world state
func NewWorldState ¶
func NewWorldState(storage cdb.Storage) (WorldState, error)
NewWorldState create a new empty WorldState