Documentation
¶
Index ¶
- type Base
- func (b *Base) DecodeBinary(br *io.BinReader)
- func (b *Base) EncodeBinary(bw *io.BinWriter)
- func (b *Base) GetHashableData() []byte
- func (b *Base) Hash() util.Uint256
- func (b Base) MarshalJSON() ([]byte, error)
- func (b *Base) UnmarshalJSON(data []byte) error
- func (b *Base) VerificationHash() util.Uint256
- func (b *Base) Verify() bool
- type Block
- func (b *Block) Compare(item queue.Item) int
- func (b *Block) DecodeBinary(br *io.BinReader)
- func (b *Block) EncodeBinary(bw *io.BinWriter)
- func (b *Block) Header() *Header
- func (b Block) MarshalJSON() ([]byte, error)
- func (b *Block) RebuildMerkleRoot() error
- func (b *Block) Trim() ([]byte, error)
- func (b *Block) UnmarshalJSON(data []byte) error
- func (b *Block) Verify() error
- type Header
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
// Version of the block.
Version uint32
// hash of the previous block.
PrevHash util.Uint256
// Root hash of a transaction list.
MerkleRoot util.Uint256
// The time stamp of each block must be later than previous block's time stamp.
// Generally the difference of two block's time stamp is about 15 seconds and imprecision is allowed.
// The height of the block must be exactly equal to the height of the previous block plus 1.
Timestamp uint32
// index/height of the block
Index uint32
// Random number also called nonce
ConsensusData uint64
// Contract address of the next miner
NextConsensus util.Uint160
// Script used to validate the block
Script transaction.Witness
// contains filtered or unexported fields
}
Base holds the base info of a block
func (*Base) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Base) EncodeBinary ¶
EncodeBinary implements Serializable interface
func (*Base) GetHashableData ¶
GetHashableData returns serialized hashable data of the block.
func (Base) MarshalJSON ¶ added in v0.75.0
MarshalJSON implements json.Marshaler interface.
func (*Base) UnmarshalJSON ¶ added in v0.75.0
UnmarshalJSON implements json.Unmarshaler interface.
func (*Base) VerificationHash ¶
VerificationHash returns the hash of the block used to verify it.
type Block ¶
type Block struct {
// The base of the block.
Base
// Transaction list.
Transactions []*transaction.Transaction
// True if this block is created from trimmed data.
Trimmed bool
}
Block represents one block in the chain.
func NewBlockFromTrimmedBytes ¶
NewBlockFromTrimmedBytes returns a new block from trimmed data. This is commonly used to create a block from stored data. Blocks created from trimmed data will have their Trimmed field set to true.
func (*Block) DecodeBinary ¶
DecodeBinary decodes the block from the given BinReader, implementing Serializable interface.
func (*Block) EncodeBinary ¶
EncodeBinary encodes the block to the given BinWriter, implementing Serializable interface.
func (Block) MarshalJSON ¶ added in v0.75.0
MarshalJSON implements json.Marshaler interface.
func (*Block) RebuildMerkleRoot ¶
RebuildMerkleRoot rebuilds the merkleroot of the block.
func (*Block) Trim ¶
Trim returns a subset of the block data to save up space in storage. Notice that only the hashes of the transactions are stored.
func (*Block) UnmarshalJSON ¶ added in v0.75.0
UnmarshalJSON implements json.Unmarshaler interface.
type Header ¶
type Header struct {
// Base of the block.
Base
// contains filtered or unexported fields
}
Header holds the head info of a block.
func (*Header) DecodeBinary ¶
DecodeBinary implements Serializable interface.
func (*Header) EncodeBinary ¶
EncodeBinary implements Serializable interface.