cbitcoin
 All Data Structures Files Functions Variables Typedefs
src/structures/CBObject/CBMessage/CBBlock/CBBlock.h File Reference

Structure that holds a bitcoin block. Blocks contain transaction information and use a proof of work system to show that they are legitimate. Inherits CBMessage. More...

#include "CBTransaction.h"
#include "CBBigInt.h"

Go to the source code of this file.

Data Structures

struct  CBBlock
 Structure for CBBlock objects. More...

Functions

CBBlockCBNewBlock (void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBBlock object. Set the members after creating the block object.
CBBlockCBNewBlockFromData (CBByteArray *data, void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBBlock object.
CBBlockCBNewBlockGenesis (void(*onErrorReceived)(CBError error, char *,...))
 Creates a new CBBlock object with the genesis information for the bitcoin block chain. This will have serialised data as well as object data.
CBBlockCBGetBlock (void *self)
 Gets a CBBlock from another object. Use this to avoid casts.
bool CBInitBlock (CBBlock *self, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBBlock object.
bool CBInitBlockFromData (CBBlock *self, CBByteArray *data, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBBlock object from serialised data.
bool CBInitBlockGenesis (CBBlock *self, void(*onErrorReceived)(CBError error, char *,...))
 Initialises a CBBlock object with the genesis information for the bitcoin block chain. This will have serialised data as well as object data.
void CBFreeBlock (void *vself)
 Frees a CBBlock object.
CBByteArrayCBBlockCalculateHash (CBBlock *self)
 Calculates the hash for a block.
uint32_t CBBlockCalculateLength (CBBlock *self, bool transactions)
 Calculates the length needed to serialise the object.
uint32_t CBBlockDeserialise (CBBlock *self, bool transactions)
 Deserialises a CBBlock so that it can be used as an object.
CBByteArrayCBBlockGetHash (CBBlock *self)
 Retrieves or calculates the hash for a block. Hashes taken from this fuction are cached.
uint32_t CBBlockSerialise (CBBlock *self, bool transactions)
 Serialises a CBBlock to the byte data.

Detailed Description

Structure that holds a bitcoin block. Blocks contain transaction information and use a proof of work system to show that they are legitimate. Inherits CBMessage.


Function Documentation

Calculates the hash for a block.

Parameters:
selfThe CBBlock object. This should be serialised.
Returns:
The hash for the block. This is a 32 byte long, double SHA-256 hash.
uint32_t CBBlockCalculateLength ( CBBlock self,
bool  transactions 
)

Calculates the length needed to serialise the object.

Parameters:
selfThe CBBlock object.
transactionsIf true, the full block, if not true just the header.
Returns:
The length read on success, 0 on failure.
uint32_t CBBlockDeserialise ( CBBlock self,
bool  transactions 
)

Deserialises a CBBlock so that it can be used as an object.

Parameters:
selfThe CBBlock object
transactionsIf true deserialise transactions. If false there do not deserialise for transactions.
Returns:
The length read on success, 0 on failure.

Retrieves or calculates the hash for a block. Hashes taken from this fuction are cached.

Parameters:
selfThe CBBlock object. This should be serialised.
Returns:
The hash for the block. This is a 32 byte long, double SHA-256 hash.
uint32_t CBBlockSerialise ( CBBlock self,
bool  transactions 
)

Serialises a CBBlock to the byte data.

Parameters:
selfThe CBBlock object
transactionsIf true serialise transactions. If false there do not serialise for transactions.
Returns:
The length read on success, 0 on failure.
void CBFreeBlock ( void *  vself)

Frees a CBBlock object.

Parameters:
selfThe CBBlock object to free.
CBBlock* CBGetBlock ( void *  self)

Gets a CBBlock from another object. Use this to avoid casts.

Parameters:
selfThe object to obtain the CBBlock from.
Returns:
The CBBlock object.
bool CBInitBlock ( CBBlock self,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBBlock object.

Parameters:
selfThe CBBlock object to initialise
Returns:
true on success, false on failure.
bool CBInitBlockFromData ( CBBlock self,
CBByteArray data,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBBlock object from serialised data.

Parameters:
selfThe CBBlock object to initialise
dataThe serialised data.
Returns:
true on success, false on failure.
bool CBInitBlockGenesis ( CBBlock self,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Initialises a CBBlock object with the genesis information for the bitcoin block chain. This will have serialised data as well as object data.

Parameters:
selfThe CBBlock object to initialise.
dataSerialised block data.
Returns:
A new CBBlock object.
CBBlock* CBNewBlock ( void(*)(CBError error, char *,...)  onErrorReceived)

Creates a new CBBlock object. Set the members after creating the block object.

Returns:
A new CBBlock object.
CBBlock* CBNewBlockFromData ( CBByteArray data,
void(*)(CBError error, char *,...)  onErrorReceived 
)

Creates a new CBBlock object.

Parameters:
dataSerialised block data.
Returns:
A new CBBlock object.
CBBlock* CBNewBlockGenesis ( void(*)(CBError error, char *,...)  onErrorReceived)

Creates a new CBBlock object with the genesis information for the bitcoin block chain. This will have serialised data as well as object data.

Parameters:
dataSerialised block data.
Returns:
A new CBBlock object.