C# Class BitSharper.Block

Inheritance: Message
Afficher le fichier Open project: TangibleCryptography/BitSharper Class Usage Examples

Private Properties

Свойство Type Description
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

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
Parse ( ) : void

Private Methods

Méthode Description
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

Method Details

BitcoinSerializeToStream() public méthode

public BitcoinSerializeToStream ( Stream stream ) : void
stream Stream
Résultat void

Block() public méthode

Constructs a block object from the BitCoin wire format.
public Block ( NetworkParameters @params, byte payloadBytes ) : System
@params NetworkParameters
payloadBytes byte
Résultat System

CloneAsHeader() public méthode

Returns a copy of the block, but without any transactions.
public CloneAsHeader ( ) : Block
Résultat Block

CreateNextBlock() public méthode

public CreateNextBlock ( Address to ) : Block
to Address
Résultat Block

Equals() public méthode

public Equals ( object o ) : bool
o object
Résultat bool

GetDifficultyTargetAsInteger() public méthode

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
Résultat Org.BouncyCastle.Math.BigInteger

GetHashCode() public méthode

public GetHashCode ( ) : int
Résultat int

GetWork() public méthode

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
Résultat Org.BouncyCastle.Math.BigInteger

Parse() protected méthode

protected Parse ( ) : void
Résultat void

ToString() public méthode

Returns a multi-line string containing a description of the contents of the block. Use for debugging purposes only.
public ToString ( ) : string
Résultat string

Verify() public méthode

Verifies both the header and that the transactions hash to the merkle root.
public Verify ( ) : void
Résultat void

VerifyHeader() public méthode

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
Résultat void

VerifyTransactions() public méthode

Checks the block contents
public VerifyTransactions ( ) : void
Résultat void