Documentation ¶
Index ¶
- Constants
- Variables
- func GetBookKeeperAddress(bookKeepers []*crypto.PubKey) (Uint160, error)
- type Block
- func (b *Block) Deserialize(r io.Reader) error
- func (b *Block) FromTrimmedData(r io.Reader) error
- func (b *Block) GetMessage() []byte
- func (b *Block) GetProgramHashes() ([]Uint160, error)
- func (b *Block) GetPrograms() []*program.Program
- func (b *Block) Hash() Uint256
- func (b *Block) RebuildMerkleRoot() error
- func (b *Block) Serialize(w io.Writer) error
- func (bd *Block) SerializeUnsigned(w io.Writer) error
- func (b *Block) SetPrograms(prog []*program.Program)
- func (b *Block) ToArray() []byte
- func (b *Block) Trim(w io.Writer) error
- func (b *Block) Type() InventoryType
- func (b *Block) Verify() error
- type Blockchain
- func (bc *Blockchain) AddBlock(block *Block) error
- func (bc *Blockchain) ContainsTransaction(hash Uint256) bool
- func (bc *Blockchain) CurrentBlockHash() Uint256
- func (bc *Blockchain) GetBookKeepers() []*crypto.PubKey
- func (bc *Blockchain) GetBookKeepersByTXs(others []*tx.Transaction) []*crypto.PubKey
- func (bc *Blockchain) GetHeader(hash Uint256) (*Header, error)
- func (bc *Blockchain) SaveBlock(block *Block) error
- type Blockdata
- func (bd *Blockdata) Deserialize(r io.Reader) error
- func (bd *Blockdata) DeserializeUnsigned(r io.Reader) error
- func (bd *Blockdata) GetMessage() []byte
- func (bd *Blockdata) GetProgramHashes() ([]Uint160, error)
- func (bd *Blockdata) GetPrograms() []*program.Program
- func (bd *Blockdata) Hash() Uint256
- func (bd *Blockdata) Serialize(w io.Writer) error
- func (bd *Blockdata) SerializeUnsigned(w io.Writer) error
- func (bd *Blockdata) SetPrograms(programs []*program.Program)
- func (bd *Blockdata) ToArray() []byte
- type Header
- type ILedgerStore
- type Ledger
- func (l *Ledger) BlockInLedger(hash Uint256) bool
- func (l *Ledger) GetAsset(assetId Uint256) (*asset.Asset, error)
- func (l *Ledger) GetBlockWithHash(hash Uint256) (*Block, error)
- func (l *Ledger) GetBlockWithHeight(height uint32) (*Block, error)
- func (l *Ledger) GetLocalBlockChainHeight() uint32
- func (l *Ledger) GetTransactionWithHash(hash Uint256) (*tx.Transaction, error)
- func (l *Ledger) IsDoubleSpend(Tx *tx.Transaction) bool
- type State
- type StateStore
Constants ¶
View Source
const BlockVersion uint32 = 0
View Source
const GenesisNonce uint64 = 2083236893
Variables ¶
View Source
var StandbyBookKeepers []*crypto.PubKey
Functions ¶
func GetBookKeeperAddress ¶
Types ¶
type Block ¶
type Block struct { Blockdata *Blockdata Transactions []*tx.Transaction // contains filtered or unexported fields }
func (*Block) GetMessage ¶
func (*Block) GetProgramHashes ¶
func (*Block) GetPrograms ¶
func (*Block) RebuildMerkleRoot ¶
func (*Block) SetPrograms ¶
type Blockchain ¶
type Blockchain struct { BlockHeight uint32 BCEvents *events.Event // contains filtered or unexported fields }
func GenesisBlock ¶
func GenesisBlock(defBookKeeper []*crypto.PubKey) (*Blockchain, error)
func NewBlockchain ¶
func NewBlockchain(height uint32) *Blockchain
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(block *Block) error
func (*Blockchain) ContainsTransaction ¶
func (bc *Blockchain) ContainsTransaction(hash Uint256) bool
func (*Blockchain) CurrentBlockHash ¶
func (bc *Blockchain) CurrentBlockHash() Uint256
func (*Blockchain) GetBookKeepers ¶
func (bc *Blockchain) GetBookKeepers() []*crypto.PubKey
func (*Blockchain) GetBookKeepersByTXs ¶
func (bc *Blockchain) GetBookKeepersByTXs(others []*tx.Transaction) []*crypto.PubKey
func (*Blockchain) GetHeader ¶
func (bc *Blockchain) GetHeader(hash Uint256) (*Header, error)
func (*Blockchain) SaveBlock ¶
func (bc *Blockchain) SaveBlock(block *Block) error
type Blockdata ¶
type Blockdata struct { Version uint32 PrevBlockHash Uint256 TransactionsRoot Uint256 Timestamp uint32 Height uint32 ConsensusData uint64 NextBookKeeper Uint160 Program *program.Program // contains filtered or unexported fields }
func (*Blockdata) GetMessage ¶
func (*Blockdata) GetProgramHashes ¶
func (*Blockdata) GetPrograms ¶
func (*Blockdata) SerializeUnsigned ¶
don't write the hash and program to writer
func (*Blockdata) SetPrograms ¶
type ILedgerStore ¶
type ILedgerStore interface { //TODO: define the state store func SaveBlock(b *Block, ledger *Ledger) error GetBlock(hash Uint256) (*Block, error) BlockInCache(hash Uint256) bool GetBlockHash(height uint32) (Uint256, error) InitLedgerStore(ledger *Ledger) error IsDoubleSpend(tx *tx.Transaction) bool //SaveHeader(header *Header,ledger *Ledger) error AddHeaders(headers []Header, ledger *Ledger) error GetHeader(hash Uint256) (*Header, error) GetTransaction(hash Uint256) (*tx.Transaction, error) SaveAsset(assetid Uint256, asset *Asset) error GetAsset(hash Uint256) (*Asset, error) GetContract(codeHash Uint160) ([]byte, error) GetStorage(key []byte) ([]byte, error) GetAccount(programHash Uint160) (*account.AccountState, error) GetAssetState(assetId Uint256) (*states.AssetState, error) GetCurrentBlockHash() Uint256 GetCurrentHeaderHash() Uint256 GetHeaderHeight() uint32 GetHeight() uint32 GetHeaderHashByHeight(height uint32) Uint256 GetBookKeeperList() ([]*crypto.PubKey, []*crypto.PubKey, error) InitLedgerStoreWithGenesisBlock(genesisblock *Block, defaultBookKeeper []*crypto.PubKey) (uint32, error) GetQuantityIssued(assetid Uint256) (Fixed64, error) GetUnspent(txid Uint256, index uint16) (*tx.TxOutput, error) ContainsUnspent(txid Uint256, index uint16) (bool, error) GetUnspentFromProgramHash(programHash Uint160, assetid Uint256) ([]*tx.UTXOUnspent, error) GetUnspentsFromProgramHash(programHash Uint160) (map[Uint256][]*tx.UTXOUnspent, error) GetLockedFromProgramHash(programHash Uint160, assetid Uint256) ([]*LockAsset, error) GetAvailableAsset(programHash Uint160, assetid Uint256) (Fixed64, Fixed64, error) GetAssets() map[Uint256]*Asset SaveRecord(hash string, txhash Uint256) error GetRecord(filehash string) (Uint256, error) IsTxHashDuplicate(txhash Uint256) bool IsBlockInStore(hash Uint256) bool Close() }
ILedgerStore provides func with store package.
type Ledger ¶
type Ledger struct { Blockchain *Blockchain State *State Store ILedgerStore }
var DefaultLedger *Ledger
func GetDefaultLedger ¶
func (*Ledger) BlockInLedger ¶
BlockInLedger checks if the block existed in ledger
func (*Ledger) GetBlockWithHash ¶
Get block with block hash.
func (*Ledger) GetBlockWithHeight ¶
func (*Ledger) GetLocalBlockChainHeight ¶
Get local block chain height.
func (*Ledger) GetTransactionWithHash ¶
func (l *Ledger) GetTransactionWithHash(hash Uint256) (*tx.Transaction, error)
Get transaction with hash.
func (*Ledger) IsDoubleSpend ¶
func (l *Ledger) IsDoubleSpend(Tx *tx.Transaction) bool
type StateStore ¶
Click to show internal directories.
Click to hide internal directories.