Documentation ¶
Index ¶
- Variables
- func CalculatePoW(data PoWData, difficulty uint64) (uint64, error)
- func CheckBlockPoW(block *Block, difficulty uint64) bool
- func CheckPoW(hash Hash, difficulty uint64) bool
- func CheckTx(tx *Tx) bool
- func NewKey() (*ecdsa.PrivateKey, error)
- func PackPubK(pubK *ecdsa.PublicKey) []byte
- func Uint64FromBytes(b []byte) uint64
- func Uint64ToBytes(u uint64) []byte
- func UnpackPubK(b []byte) *ecdsa.PublicKey
- func VerifySignature(pubK *ecdsa.PublicKey, m []byte, sig Signature) bool
- type Address
- type Block
- type Blockchain
- func (bc *Blockchain) AddBlock(block *Block) error
- func (bc *Blockchain) GetBalance(pubK *ecdsa.PublicKey) (uint64, error)
- func (bc *Blockchain) GetBlock(hash Hash) (*Block, error)
- func (bc *Blockchain) GetHeight() uint64
- func (bc *Blockchain) GetLastBlock() *Block
- func (bc *Blockchain) GetPrevBlock(hash Hash) (*Block, error)
- func (bc *Blockchain) UpdateWalletsWithNewTx(tx *Tx) error
- func (bc *Blockchain) VerifyBlock(block *Block) bool
- type Hash
- type Input
- type Output
- type PoA
- type PoWData
- type Signature
- type Tx
Constants ¶
This section is empty.
Variables ¶
View Source
var GenesisHashTxInput = HashBytes([]byte("genesis"))
Functions ¶
func CalculatePoW ¶
CalculatePoW calculates the nonce for the given data in order to fit in the current Proof of Work difficulty
func CheckBlockPoW ¶
func NewKey ¶
func NewKey() (*ecdsa.PrivateKey, error)
func Uint64FromBytes ¶
func Uint64ToBytes ¶
func UnpackPubK ¶
Types ¶
type Address ¶
type Address [32]byte
Address is the type data for addresses
func AddressFromPrivK ¶
func AddressFromPrivK(privK *ecdsa.PrivateKey) Address
func AddressFromPubK ¶
type Block ¶
type Block struct { Height uint64 PrevHash Hash Txs []Tx Miner Address MinerPubK *ecdsa.PublicKey // tmp meanwhile no ecrecover function Timestamp time.Time Nonce uint64 Hash Hash Signature []byte }
Block holds the data structure for the block
func BlockFromBytes ¶
func (*Block) CalculateHash ¶
func (block *Block) CalculateHash()
func (*Block) CalculatePoW ¶
func (*Block) IncrementNonce ¶
func (blk *Block) IncrementNonce()
type Blockchain ¶
type Blockchain struct { Id []byte // Id allows to have multiple blockchains Difficulty uint64 Genesis Hash LastBlock *Block PoA PoA // contains filtered or unexported fields }
func NewBlockchain ¶
func NewBlockchain(database *db.Db, dif uint64) *Blockchain
func NewPoABlockchain ¶
func NewPoABlockchain(database *db.Db, authNodes []*ecdsa.PublicKey) *Blockchain
func (*Blockchain) AddBlock ¶
func (bc *Blockchain) AddBlock(block *Block) error
func (*Blockchain) GetBalance ¶
func (bc *Blockchain) GetBalance(pubK *ecdsa.PublicKey) (uint64, error)
func (*Blockchain) GetHeight ¶
func (bc *Blockchain) GetHeight() uint64
func (*Blockchain) GetLastBlock ¶
func (bc *Blockchain) GetLastBlock() *Block
func (*Blockchain) GetPrevBlock ¶
func (bc *Blockchain) GetPrevBlock(hash Hash) (*Block, error)
func (*Blockchain) UpdateWalletsWithNewTx ¶
func (bc *Blockchain) UpdateWalletsWithNewTx(tx *Tx) error
func (*Blockchain) VerifyBlock ¶
func (bc *Blockchain) VerifyBlock(block *Block) bool
type Hash ¶
type Hash [32]byte
Hash is the type for a hash data packet
type PoWData ¶
PoWData is the interface for the data that have the Nonce parameter to calculate the Proof-of-Work
type Signature ¶
func SignatureFromBytes ¶
Click to show internal directories.
Click to hide internal directories.