Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { Timestamp int64 `json:"timestamp"` Data []byte `json:"data"` PrevBlockHash []byte `json:"prev_block_hash"` Hash string `json:"hash"` Nonce int `json:"nonce"` }
Block represents a single block in the blockchain
type Blockchain ¶
type Blockchain struct {
Blocks []*Block
}
Blockchain represents the chain of blocks
func NewBlockchain ¶
func NewBlockchain() *Blockchain
NewBlockchain creates a new Blockchain with genesis Block
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(data string) error
AddBlock adds a new block to the blockchain Returns an error if it fails to create a new block
type Transaction ¶
type Transaction struct { ID string `json:"id"` Timestamp time.Time `json:"timestamp"` Sender string `json:"sender"` Recipient string `json:"recipient"` Amount float64 `json:"amount"` Signature string `json:"signature"` // Placeholder for digital signature }
Transaction represents a blockchain transaction
func NewTransaction ¶
func NewTransaction(sender, recipient string, amount float64) *Transaction
NewTransaction creates a new Transaction
Click to show internal directories.
Click to hide internal directories.