Documentation ¶
Index ¶
- Variables
- func EnqueueTransactionData(data *BlockData)
- func IsBlockDataQueued(data *BlockData) bool
- func NewTransactionDataExists() bool
- func RemoveTransactionData(data *BlockData) (err error)
- func StringToTime(s string) (t time.Time, err error)
- func TimeToString(t time.Time) string
- type Block
- type BlockData
- type Blockchain
Constants ¶
This section is empty.
Variables ¶
var ( // BlockProcessedChan is a channel for indicating blocks have been processed BlockProcessedChan = make(chan int) )
Functions ¶
func EnqueueTransactionData ¶
func EnqueueTransactionData(data *BlockData)
EnqueueTransactionData enqueues the latest transaction data
func IsBlockDataQueued ¶
IsBlockDataQueued returns true if block data is queued
func NewTransactionDataExists ¶
func NewTransactionDataExists() bool
NewTransactionDataExists returns true if there is enqueued transaction data
func RemoveTransactionData ¶
RemoveTransactionData removes the specified transaction data TODO: may want to be more efficient here
func StringToTime ¶
StringToTime returns the time representation of a string
func TimeToString ¶
TimeToString returns the string representation of a time
Types ¶
type Block ¶
Block keeps block headers
func NewGenesisBlock ¶
func NewGenesisBlock() *Block
NewGenesisBlock creates and returns genesis Block
func (*Block) ComputeHash ¶
ComputeHash calculates the block hash
type BlockData ¶
type BlockData struct { Timestamp string PublicKey string Signature string ProjectID string CommitHash string FileHashes map[string]string MetaData map[string]string }
BlockData is the data for a block
func PeekLatestTransactionData ¶
PeekLatestTransactionData returns the latest transaction data
type Blockchain ¶
Blockchain keeps a sequence of Blocks
func NewBlockchain ¶
func NewBlockchain() *Blockchain
NewBlockchain creates a new Blockchain with genesis Block
func (*Blockchain) Commit ¶
func (bc *Blockchain) Commit() (err error)
Commit commits a staged block to the blockchain
func (*Blockchain) IsBlockValid ¶
func (bc *Blockchain) IsBlockValid(block *Block) error
IsBlockValid determines if the newBlock is a valid successor to oldBlock
func (*Blockchain) ProcessNewBlock ¶
func (bc *Blockchain) ProcessNewBlock(data BlockData) *Block
ProcessNewBlock saves provided data as a block in the blockchain
func (*Blockchain) StageBlock ¶
func (bc *Blockchain) StageBlock(b *Block)
StageBlock stages a block