C# Класс BitSharper.Block

Наследование: Message
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
AddCoinbaseTransaction void
AddTransaction void
Block System
BuildMerkleTree IList
CalculateHash Sha256Hash
CalculateMerkleRoot Sha256Hash
CheckMerkleRoot void
CheckProofOfWork bool
CheckTimestamp void
CheckTransactions void
CreateNextBlock Block
Solve void
WriteHeader void

Открытые методы

Метод Описание
BitcoinSerializeToStream ( Stream stream ) : void
Block ( NetworkParameters @params, byte payloadBytes ) : System

Constructs a block object from the BitCoin wire format.

CloneAsHeader ( ) : Block

Returns a copy of the block, but without any transactions.

CreateNextBlock ( Address to ) : Block
Equals ( object o ) : bool
GetDifficultyTargetAsInteger ( ) : BigInteger

Returns the difficulty target as a 256 bit value that can be compared to a SHA-256 hash. Inside a block the target is represented using a compact form. If this form decodes to a value that is out of bounds, an exception is thrown.

GetHashCode ( ) : int
GetWork ( ) : BigInteger

Returns the work represented by this block.

Work is defined as the number of tries needed to solve a block in the average case. Consider a difficulty target that covers 5% of all possible hash values. Then the work of the block will be 20. As the target gets lower, the amount of work goes up.

ToString ( ) : string

Returns a multi-line string containing a description of the contents of the block. Use for debugging purposes only.

Verify ( ) : void

Verifies both the header and that the transactions hash to the merkle root.

VerifyHeader ( ) : void

Checks the block data to ensure it follows the rules laid out in the network parameters. Specifically, throws an exception if the proof of work is invalid, if the timestamp is too far from what it should be. This is not everything that is required for a block to be valid, only what is checkable independent of the chain and without a transaction index.

VerifyTransactions ( ) : void

Checks the block contents

Защищенные методы

Метод Описание
Parse ( ) : void

Приватные методы

Метод Описание
AddCoinbaseTransaction ( byte pubKeyTo ) : void

Adds a coinbase transaction to the block. This exists for unit tests.

AddTransaction ( Transaction t ) : void

Adds a transaction to this block.

Block ( NetworkParameters @params ) : System

Special case constructor, used for the genesis node, cloneAsHeader and unit tests.

BuildMerkleTree ( ) : IList
CalculateHash ( ) : Sha256Hash

Calculates the block hash by serializing the block and hashing the resulting bytes.

CalculateMerkleRoot ( ) : Sha256Hash
CheckMerkleRoot ( ) : void
CheckProofOfWork ( bool throwException ) : bool

Returns true if the hash of the block is OK (lower than difficulty target).

CheckTimestamp ( ) : void
CheckTransactions ( ) : void
CreateNextBlock ( Address to, uint time ) : Block

Returns a solved block that builds on top of this one. This exists for unit tests.

Solve ( ) : void

Finds a value of nonce that makes the blocks hash lower than the difficulty target. This is called mining, but solve() is far too slow to do real mining with. It exists only for unit testing purposes and is not a part of the public API.

This can loop forever if a solution cannot be found solely by incrementing nonce. It doesn't change extraNonce.

WriteHeader ( Stream stream ) : void

Описание методов

BitcoinSerializeToStream() публичный Метод

public BitcoinSerializeToStream ( Stream stream ) : void
stream Stream
Результат void

Block() публичный Метод

Constructs a block object from the BitCoin wire format.
public Block ( NetworkParameters @params, byte payloadBytes ) : System
@params NetworkParameters
payloadBytes byte
Результат System

CloneAsHeader() публичный Метод

Returns a copy of the block, but without any transactions.
public CloneAsHeader ( ) : Block
Результат Block

CreateNextBlock() публичный Метод

public CreateNextBlock ( Address to ) : Block
to Address
Результат Block

Equals() публичный Метод

public Equals ( object o ) : bool
o object
Результат bool

GetDifficultyTargetAsInteger() публичный Метод

Returns the difficulty target as a 256 bit value that can be compared to a SHA-256 hash. Inside a block the target is represented using a compact form. If this form decodes to a value that is out of bounds, an exception is thrown.
public GetDifficultyTargetAsInteger ( ) : BigInteger
Результат Org.BouncyCastle.Math.BigInteger

GetHashCode() публичный Метод

public GetHashCode ( ) : int
Результат int

GetWork() публичный Метод

Returns the work represented by this block.
Work is defined as the number of tries needed to solve a block in the average case. Consider a difficulty target that covers 5% of all possible hash values. Then the work of the block will be 20. As the target gets lower, the amount of work goes up.
public GetWork ( ) : BigInteger
Результат Org.BouncyCastle.Math.BigInteger

Parse() защищенный Метод

protected Parse ( ) : void
Результат void

ToString() публичный Метод

Returns a multi-line string containing a description of the contents of the block. Use for debugging purposes only.
public ToString ( ) : string
Результат string

Verify() публичный Метод

Verifies both the header and that the transactions hash to the merkle root.
public Verify ( ) : void
Результат void

VerifyHeader() публичный Метод

Checks the block data to ensure it follows the rules laid out in the network parameters. Specifically, throws an exception if the proof of work is invalid, if the timestamp is too far from what it should be. This is not everything that is required for a block to be valid, only what is checkable independent of the chain and without a transaction index.
public VerifyHeader ( ) : void
Результат void

VerifyTransactions() публичный Метод

Checks the block contents
public VerifyTransactions ( ) : void
Результат void