blockchain

package
v0.0.0-...-53feb6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2016 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Bitcoin-blockchain specific functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadBlock

func DownloadBlock(dir string) (string, error)

DownloadBlock takes 'dir' as the directory where to download the block. It returns the downloaded file

func EnsureBlockIsAvailable

func EnsureBlockIsAvailable(dir string) error

EnsureBlockIsAvailable tests if the block is already downloaded, else it will download it. Finally the block will be copied to the 'simul'-provided directory for simulation.

func GetBlockDir

func GetBlockDir() string

Gets the block-directory starting from the current directory - this will hold up when running it with 'simul'

func GetBlockName

func GetBlockName(dir string) string

CheckBlockAvailable looks if the directory with the block exists or not. It takes 'dir' as the base-directory, generated from 'cothority/simul'.

func HashHeader

func HashHeader(h *Header) string

func HashRootTransactions

func HashRootTransactions(transactions TransactionList) string

func SimulDirToBlockDir

func SimulDirToBlockDir(dir string) string

SimulDirToBlockDir creates a path to the 'protocols/byzcoin/block'-dir by using 'dir' which comes from 'cothority/simul' If that directory doesn't exist, it will be created.

Types

type BitCoSiMessage

type BitCoSiMessage struct {
	ReqNo SeqNo // Request sequence number
	// ErrorReply *ErrorReply // Generic error reply to any request
	Type MessageType
	Treq *TransactionAnnouncment
	Brep *BlockReply
}

func (BitCoSiMessage) MarshalBinary

func (tsm BitCoSiMessage) MarshalBinary() ([]byte, error)

func (*BitCoSiMessage) UnmarshalBinary

func (sm *BitCoSiMessage) UnmarshalBinary(data []byte) error

type Block

type Block struct {
	Magic      [4]byte
	BlockSize  uint32
	HeaderHash string
	*Header
	TransactionList
}

func (*Block) Calculate_root

func (trb *Block) Calculate_root(transactions TransactionList) (res string)

func (*Block) Hash

func (trb *Block) Hash(h *Header) (res string)

type BlockReply

type BlockReply struct {
	SuiteStr      string
	Timestamp     int64           // The timestamp requested for the block to prove its ordering
	BlockLen      int             // Length of Block
	Block         Block           // The Block including a number of transactions
	MerkleRoot    []byte          // root of the merkle tree
	PrfLen        int             // Length of proof
	Prf           crypto.Proof    // Merkle proof of value
	Response      abstract.Secret // Aggregate response
	Challenge     abstract.Secret // Aggregate challenge
	AggCommit     abstract.Point  // Aggregate commitment key
	AggPublic     abstract.Point  // Aggregate public key (use for easy troubleshooting)
	SignatureInfo []byte          // All other elements necessary
}

NOTE: In order to decode correctly the proof, we need to the get the suite somehow. We could just simply add it as a field and not (un)marhsal it We'd just make sure that the suite is setup before unmarshaling.

func (BlockReply) MarshalBinary

func (Treq BlockReply) MarshalBinary() ([]byte, error)

func (*BlockReply) MarshalJSON

func (sr *BlockReply) MarshalJSON() ([]byte, error)

func (*BlockReply) UnmarshalBinary

func (Treq *BlockReply) UnmarshalBinary(data []byte) error

func (*BlockReply) UnmarshalJSON

func (sr *BlockReply) UnmarshalJSON(dataJSON []byte) error
type Header struct {
	MerkleRoot string
	Parent     string
	ParentKey  string
	PublicKey  string
	LeaderId   net.IP
}

func NewHeader

func NewHeader(transactions TransactionList, parent, parentKey string) *Header

func (*Header) HashSum

func (h *Header) HashSum() []byte

HashSum returns a hash representation of the header

type KeyBlock

type KeyBlock struct {
	Block
}

func (*KeyBlock) NewHeader

func (t *KeyBlock) NewHeader(transactions TransactionList, parent string, IP net.IP, key string) (hd Header)

func (*KeyBlock) NewKeyBlock

func (*KeyBlock) NewKeyBlock(transactions TransactionList, header *Header) (tr KeyBlock)

func (*KeyBlock) Print

func (trb *KeyBlock) Print()

type MessageType

type MessageType int

type Parser

type Parser struct {
	Path      string
	Magic     [4]byte
	CurrentId uint32
}

func NewParser

func NewParser(path string, magic [4]byte) (parser *Parser, err error)

func (*Parser) Parse

func (p *Parser) Parse(first_block, last_block int) ([]blkparser.Tx, error)

type SeqNo

type SeqNo byte

type TrBlock

type TrBlock struct {
	Block
}

func NewTrBlock

func NewTrBlock(transactions TransactionList, header *Header) *TrBlock

Porting to public method non related to Header / TrBlock whatsoever

func (*TrBlock) HashSum

func (tr *TrBlock) HashSum() []byte

Hash returns a hash representation of the block

func (*TrBlock) MarshalBinary

func (tr *TrBlock) MarshalBinary() ([]byte, error)

func (*TrBlock) NewHeader

func (t *TrBlock) NewHeader(transactions TransactionList, parent string, parentKey string) *Header

func (*TrBlock) NewTrBlock

func (trb *TrBlock) NewTrBlock(transactions TransactionList, header *Header) *TrBlock

type TransactionAnnouncment

type TransactionAnnouncment struct {
	Val blkparser.Tx // Trasaction to be included in a block
}

type TransactionList

type TransactionList struct {
	Txs   []blkparser.Tx `json:"tx,omitempty"`
	TxCnt uint32         `json:"n_tx"`
	Fees  float64        `json:"-"`
}

func NewTransactionList

func NewTransactionList(transactions []blkparser.Tx, n int) (tr TransactionList)

func (*TransactionList) HashSum

func (tl *TransactionList) HashSum() []byte

func (*TransactionList) Print

func (tran *TransactionList) Print()

Directories

Path Synopsis
Basically adapation from the file at https://github.com/tsileo/blkparser Copy/paste from the file at https://github.com/tsileo/blkparser Basically adapation from the file at https://github.com/tsileo/blkparser Package blkparser basically is an adaptation from a file at https://github.com/tsileo/blkparser
Basically adapation from the file at https://github.com/tsileo/blkparser Copy/paste from the file at https://github.com/tsileo/blkparser Basically adapation from the file at https://github.com/tsileo/blkparser Package blkparser basically is an adaptation from a file at https://github.com/tsileo/blkparser

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL