Documentation ¶
Index ¶
- Constants
- Variables
- func CompareBlockHash(h1 Hash, h2 Hash) bool
- type Account
- type Block
- type BlockDB
- type BlockHeader
- type FromFileState
- func (s *FromFileState) Add(tx Transaction) error
- func (s *FromFileState) AddBlock(block Block) error
- func (s *FromFileState) AddBlocks(blocks []Block) error
- func (s *FromFileState) Balances() map[Account]uint
- func (s *FromFileState) Close() error
- func (s *FromFileState) GetLatestBlockHash() Hash
- func (s *FromFileState) GetLatestBlockHeight() uint64
- func (s *FromFileState) Persist() (Hash, error)
- func (s *FromFileState) Print()
- type GenesisFile
- type Hash
- type PendingBlock
- type Reason
- type State
- type Transaction
- type TransactionId
- type User
Constants ¶
View Source
const ( OTHER Reason = "" SELF_REWARD = "self-reward" BIRTHDAY = "birthday" LOAN = "loan" )
Variables ¶
Functions ¶
func CompareBlockHash ¶
Types ¶
type Block ¶
type Block struct { Header BlockHeader `json:"header"` Txs []Transaction `json:"transactions"` }
type BlockHeader ¶
type FromFileState ¶
type FromFileState struct {
// contains filtered or unexported fields
}
func NewStateFromFile ¶
func NewStateFromFile(genesisFilePath string, transactionFilePath string) (*FromFileState, error)
func (*FromFileState) Add ¶
func (s *FromFileState) Add(tx Transaction) error
func (*FromFileState) AddBlock ¶
func (s *FromFileState) AddBlock(block Block) error
func (*FromFileState) AddBlocks ¶
func (s *FromFileState) AddBlocks(blocks []Block) error
func (*FromFileState) Balances ¶
func (s *FromFileState) Balances() map[Account]uint
func (*FromFileState) Close ¶
func (s *FromFileState) Close() error
func (*FromFileState) GetLatestBlockHash ¶
func (s *FromFileState) GetLatestBlockHash() Hash
func (*FromFileState) GetLatestBlockHeight ¶
func (s *FromFileState) GetLatestBlockHeight() uint64
func (*FromFileState) Persist ¶
func (s *FromFileState) Persist() (Hash, error)
func (*FromFileState) Print ¶
func (s *FromFileState) Print()
type GenesisFile ¶
type PendingBlock ¶
type PendingBlock struct { Parent Hash Height uint64 Time uint64 MinerAddress Account Txs []Transaction }
func NewPendingBlock ¶
func NewPendingBlock(parent Hash, height uint64, minerAddress Account, time uint64, txs []Transaction) PendingBlock
type State ¶
type State interface { // Add adds a transaction Add(Transaction) error // AddBlock to the state AddBlock(Block) error // AddBlocks to the state AddBlocks([]Block) error // Balances return the balances as map Balances() map[Account]uint Persist() (Hash, error) Close() error GetLatestBlockHash() Hash GetLatestBlockHeight() uint64 Print() }
type Transaction ¶
type Transaction struct { From Account `json:"from"` To Account `json:"to"` Value uint `json:"value"` Reason string `json:"reason"` Time uint64 `json:"time"` }
func NewTransaction ¶
func (Transaction) Hash ¶
func (t Transaction) Hash() (TransactionId, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.