Documentation
¶
Index ¶
- Constants
- func HashMatchesDifficulty(hash []byte, difficulty int) bool
- type Block
- type Input
- type Output
- type Peer
- func (p *Peer) CheckHeartBeat()
- func (p *Peer) DiscoverPeers(peer string) error
- func (p *Peer) Discovery() error
- func (p *Peer) Download() ([][]Block, error)
- func (p *Peer) DownloadChain(peer string) ([]Block, error)
- func (p *Peer) GetChain() ([]byte, error)
- func (p *Peer) GetPeers() ([]byte, error)
- func (p *Peer) GossipBlock(block Block)
- func (p *Peer) GossipTransaction(transaction Transaction)
- func (p *Peer) Handle(conn net.Conn)
- func (p *Peer) Ping(peer string) error
- func (p *Peer) Pong() []byte
- func (p *Peer) RegisterDefaultPeers() error
- func (p *Peer) RegisterPeer(peer string) []byte
- func (p *Peer) SendPayload(peer string, header []byte, payload []byte) error
- func (p *Peer) SendTransaction(peer string, transaction Transaction) error
- func (p *Peer) Start()
- type Store
- func (s *Store) AddBlock(block Block) error
- func (s *Store) AddPeer(peer string) error
- func (s *Store) AddTransaction(transaction Transaction) error
- func (s *Store) Delete(bucket []byte, key []byte) error
- func (s *Store) DeletePeer(peer string) error
- func (s *Store) EvaluateChains(chains [][]Block) ([]Block, error)
- func (s *Store) Get(bucket []byte, key []byte) ([]byte, error)
- func (s *Store) GetChain() ([]Block, error)
- func (s *Store) GetPeers() ([]string, error)
- func (s *Store) GetTransaction(hash []byte, mempool bool) (Transaction, error)
- func (s *Store) GetTransactions() ([]Transaction, error)
- func (s *Store) Open(location string, peer *Peer) error
- func (s *Store) Put(bucket []byte, key []byte, value []byte) error
- func (s *Store) StoreGenesisBlock(difficulty int) (Block, error)
- func (s *Store) VerifyTransaction(transaction Transaction, index int) (bool, error)
- type Transaction
- func (t *Transaction) GetBase58Hash() (string, error)
- func (t *Transaction) GetCBOR() ([]byte, error)
- func (t *Transaction) GetHash() ([]byte, error)
- func (t *Transaction) Sign(privateKey ed25519.PrivateKey, index int) error
- func (t *Transaction) Verify(publicKey ed25519.PublicKey, index int) (bool, error)
Constants ¶
View Source
const COINBASE_AMOUNT = 25
View Source
const (
CONN_TYPE = "tcp"
)
Variables ¶
This section is empty.
Functions ¶
func HashMatchesDifficulty ¶
Types ¶
type Block ¶
type Block struct {
Height int `json:"height"`
Hash []byte `json:"hash"`
Transactions []Transaction `json:"transactions"`
PreviousBlock []byte `json:"previous_block"`
Difficulty int `json:"difficulty"`
Nonce int32 `json:"nonce"`
}
func GenerateGenesisBlock ¶
func (*Block) GetBase58Hash ¶
type Peer ¶
func (*Peer) CheckHeartBeat ¶
func (p *Peer) CheckHeartBeat()
func (*Peer) DiscoverPeers ¶
func (*Peer) GossipBlock ¶
func (*Peer) GossipTransaction ¶
func (p *Peer) GossipTransaction(transaction Transaction)
func (*Peer) RegisterDefaultPeers ¶
func (*Peer) RegisterPeer ¶
func (*Peer) SendPayload ¶
func (*Peer) SendTransaction ¶
func (p *Peer) SendTransaction(peer string, transaction Transaction) error
type Store ¶
func (*Store) AddTransaction ¶
func (s *Store) AddTransaction(transaction Transaction) error
func (*Store) DeletePeer ¶
func (*Store) GetTransaction ¶
func (s *Store) GetTransaction(hash []byte, mempool bool) (Transaction, error)
func (*Store) GetTransactions ¶
func (s *Store) GetTransactions() ([]Transaction, error)
func (*Store) VerifyTransaction ¶
func (s *Store) VerifyTransaction(transaction Transaction, index int) (bool, error)
type Transaction ¶
type Transaction struct {
Hash []byte `json:"hash"`
Inputs []Input `json:"inputs"`
Outputs []Output `json:"outputs"`
}
func GenerateCoinbase ¶
func GenerateCoinbase(publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey, amount int) (Transaction, error)
func (*Transaction) GetBase58Hash ¶
func (t *Transaction) GetBase58Hash() (string, error)
func (*Transaction) GetCBOR ¶
func (t *Transaction) GetCBOR() ([]byte, error)
func (*Transaction) GetHash ¶
func (t *Transaction) GetHash() ([]byte, error)
func (*Transaction) Sign ¶
func (t *Transaction) Sign(privateKey ed25519.PrivateKey, index int) error
Click to show internal directories.
Click to hide internal directories.