Documentation ¶
Index ¶
- Constants
- func HeaderCheck(header *Header, receiveTime int64) error
- func TransactionCheck(block *Block) 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) GetSigner() ([]byte, []byte, error)
- func (b *Block) Hash() Uint256
- func (bd *Block) MarshalJson() ([]byte, error)
- 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 (bd *Block) UnmarshalJson(data []byte) error
- func (b *Block) Verify() error
- type Blockchain
- func (bc *Blockchain) AddBlock(block *Block) error
- func (bc *Blockchain) AddBlockTime(hash Uint256, time int64)
- func (bc *Blockchain) ContainsTransaction(hash Uint256) bool
- func (bc *Blockchain) CurrentBlockHash() Uint256
- func (bc *Blockchain) GetBlockTime(hash Uint256) (int64, error)
- func (bc *Blockchain) GetHeader(hash Uint256) (*Header, error)
- func (bc *Blockchain) SaveBlock(block *Block) error
- type BlocksInfo
- type Header
- func (h *Header) Deserialize(r io.Reader) error
- func (h *Header) DeserializeUnsigned(r io.Reader) error
- func (h *Header) GetMessage() []byte
- func (h *Header) GetProgramHashes() ([]Uint160, error)
- func (h *Header) GetPrograms() []*program.Program
- func (h *Header) Hash() Uint256
- func (h *Header) MarshalJson() ([]byte, error)
- func (h *Header) Serialize(w io.Writer) error
- func (h *Header) SerializeUnsigned(w io.Writer) error
- func (h *Header) SetPrograms(programs []*program.Program)
- func (h *Header) ToArray() []byte
- func (h *Header) UnmarshalJson(data []byte) error
- type HeaderInfo
- 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 TransactionArray
- type VBlock
- type WinnerType
Constants ¶
View Source
const BlockVersion uint32 = 0
View Source
const (
GenesisBlockProposedHeight = 4
)
View Source
const GenesisNonce uint64 = 2083236893
View Source
const (
// initial version is 0, current version is 1
HeaderVersion = 1
)
Variables ¶
This section is empty.
Functions ¶
func HeaderCheck ¶
func TransactionCheck ¶
Types ¶
type Block ¶
type Block struct { Header *Header Transactions []*tx.Transaction // contains filtered or unexported fields }
func GenesisBlockInit ¶
func (*Block) GetMessage ¶
func (*Block) GetProgramHashes ¶
func (*Block) GetPrograms ¶
func (*Block) MarshalJson ¶
func (*Block) RebuildMerkleRoot ¶
func (*Block) SetPrograms ¶
func (*Block) UnmarshalJson ¶
type Blockchain ¶
type Blockchain struct { BlockHeight uint32 AssetID Uint256 BlockPersistTime map[Uint256]int64 BCEvents *events.Event // contains filtered or unexported fields }
func NewBlockchain ¶
func NewBlockchain(height uint32, asset Uint256) *Blockchain
func NewBlockchainWithGenesisBlock ¶
func NewBlockchainWithGenesisBlock(store ILedgerStore) (*Blockchain, error)
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(block *Block) error
func (*Blockchain) AddBlockTime ¶
func (bc *Blockchain) AddBlockTime(hash Uint256, time int64)
func (*Blockchain) ContainsTransaction ¶
func (bc *Blockchain) ContainsTransaction(hash Uint256) bool
func (*Blockchain) CurrentBlockHash ¶
func (bc *Blockchain) CurrentBlockHash() Uint256
func (*Blockchain) GetBlockTime ¶
func (bc *Blockchain) GetBlockTime(hash Uint256) (int64, error)
func (*Blockchain) GetHeader ¶
func (bc *Blockchain) GetHeader(hash Uint256) (*Header, error)
func (*Blockchain) SaveBlock ¶
func (bc *Blockchain) SaveBlock(block *Block) error
type BlocksInfo ¶
type BlocksInfo struct { Hash string `json:"hash"` Header *HeaderInfo `json:"header"` Transactions []*transaction.TransactionInfo `json:"transactions"` }
type Header ¶
type Header struct { Version uint32 PrevBlockHash Uint256 TransactionsRoot Uint256 Timestamp int64 Height uint32 ConsensusData uint64 NextBookKeeper Uint160 WinnerHash Uint256 WinnerType WinnerType Signer []byte ChordID []byte Signature []byte Program *program.Program // contains filtered or unexported fields }
func (*Header) GetMessage ¶
func (*Header) GetProgramHashes ¶
func (*Header) GetPrograms ¶
func (*Header) MarshalJson ¶
func (*Header) SerializeUnsigned ¶
Serialize the blockheader data without program
func (*Header) SetPrograms ¶
func (*Header) UnmarshalJson ¶
type HeaderInfo ¶
type HeaderInfo struct { Version uint32 `json:"version"` PrevBlockHash string `json:"prevBlockHash"` TransactionsRoot string `json:"transactionsRoot"` Timestamp int64 `json:"timestamp"` Height uint32 `json:"height"` ConsensusData uint64 `json:"consensusData"` NextBookKeeper string `json:"nextBookKeeper"` WinnerHash string `json:"winningHash"` WinnerType byte `json:"winningHashType"` Signer string `json:"signer"` ChordID string `json:"chordID"` Signature string `json:"signature"` Program program.ProgramInfo `json:"program"` Hash string `json:"hash"` }
type ILedgerStore ¶
type ILedgerStore interface { SaveBlock(b *Block, ledger *Ledger) error GetBlock(hash Uint256) (*Block, error) GetBlockByHeight(height uint32) (*Block, error) BlockInCache(hash Uint256) bool GetBlockHash(height uint32) (Uint256, error) GetBlockHistory(startHeight, blockNum uint32) map[uint32]Uint256 CheckBlockHistory(history map[uint32]Uint256) (uint32, bool) GetVotingWeight(hash Uint160) (int, error) IsDoubleSpend(tx *tx.Transaction) bool 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) SaveName(registrant []byte, name string) error GetName(registrant []byte) (*string, error) GetRegistrant(name string) ([]byte, error) GetContract(codeHash Uint160) ([]byte, error) GetStorage(key []byte) ([]byte, error) GetAccount(programHash Uint160) (*account.AccountState, error) GetCurrentBlockHash() Uint256 GetCurrentHeaderHash() Uint256 GetHeaderHeight() uint32 GetHeight() uint32 GetHeightByBlockHash(hash Uint256) (uint32, error) GetHeaderHashByHeight(height uint32) Uint256 InitLedgerStoreWithGenesisBlock(genesisblock *Block) (uint32, error) GetQuantityIssued(assetid Uint256) (Fixed64, error) GetUnspent(txid Uint256, index uint16) (*tx.TxnOutput, error) ContainsUnspent(txid Uint256, index uint16) (bool, error) GetUnspentFromProgramHash(programHash Uint160, assetid Uint256) ([]*tx.UTXOUnspent, error) GetUnspentsFromProgramHash(programHash Uint160) (map[Uint256][]*tx.UTXOUnspent, error) GetPrepaidInfo(programHash Uint160) (*Fixed64, *Fixed64, error) GetAssets() map[Uint256]*Asset IsTxHashDuplicate(txhash Uint256) bool IsBlockInStore(hash Uint256) bool Rollback(b *Block) error Close() }
ILedgerStore provides func with store package.
type Ledger ¶
type Ledger struct { Blockchain *Blockchain Store ILedgerStore }
var DefaultLedger *Ledger
func (*Ledger) BlockInLedger ¶
BlockInLedger checks if the block existed in ledger
func (*Ledger) GetBlockWithHash ¶
Get block with block hash.
func (*Ledger) GetBlockWithHeight ¶
Get Block With Height.
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
double spend checking for transaction
type TransactionArray ¶
type TransactionArray []*tx.Transaction
func (TransactionArray) Iterate ¶
func (iterable TransactionArray) Iterate(handler func(item *tx.Transaction) ErrCode) ErrCode
type WinnerType ¶
type WinnerType byte
const ( // The proof of Block proposer validity should exists in previous Block header. // GenesisHash means next Block proposer is GenesisBlockProposer. GenesisSigner WinnerType = 0 // WinningTxnHash means next Block proposer is a node on signature chain. TxnSigner WinnerType = 1 // WinningBlockHash means next Block proposer is signer of historical Block. BlockSigner WinnerType = 2 )
Click to show internal directories.
Click to hide internal directories.