Documentation ¶
Index ¶
- Variables
- func CreateTx(kp *types.KeyPair, amount types.Coin, fee types.Coin, recipient types.Hash) (*types.Tx, error)
- func LoadGenesis(filename string, h *ChainHelper) error
- func SubscribeNewBlock() chan events.Eventer
- type Chain
- type ChainHelper
- func (h *ChainHelper) AccountManager() *account.AccountManager
- func (h *ChainHelper) GetChainByAddress(address []byte) (*Chain, error)
- func (h *ChainHelper) GetChainById(id []byte) (*Chain, error)
- func (h *ChainHelper) GetTx(hash types.Hash) (*types.Tx, error)
- func (h *ChainHelper) NewTx(kp *types.KeyPair, amount types.Coin, fee types.Coin, recipient types.Hash) (*types.Tx, error)
- func (h *ChainHelper) ProcessTx(tx *types.Tx) error
- type DefaultProcessor
- type TxProcessor
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrGenesisLoaded returned if genesis chain already been loaded. ErrGenesisLoaded = errors.New("The genesis chain has already been loaded") // ErrTxInvalidPrevTx is returned if the transaction specified an invalid // previous transaction hash. ErrTxInvalidPrevTx = errors.New("Invalid previous tx") // ErrTxInvalidSignature is returned if signature incorrect. ErrTxInvalidSignature = errors.New("Invalid tx signature") // ErrTxInsufficientBalance is returned is sender does not have enough coins. ErrTxInsufficientBalance = errors.New("Insufficient balance") // ErrTxNotFoundInChain is returned if the transaction is not found // or is not in a particular chain. ErrTxNotFoundInChain = errors.New("Tx not found in chain") // ErrTxAlreadyExist is returned if tx already exist in tx list. ErrTxAlreadyExist = errors.New("Tx already exist") // ErrTxNil if a null pointer was passed when creating a chain ErrChainTxNil = errors.New("Genesis tx is nil") // ErrChainNotFound is returned is chain not found when writing a new transaction. ErrChainNotFound = errors.New("Chain not found") // ErrChainEmpty is returned is chain empty. ErrChainEmpty = errors.New("Chain empty") // ErrInsufficientData is returned if not found previous tx and sync needed. ErrInsufficientData = errors.New("Insufficient data") )
Functions ¶
func LoadGenesis ¶
func LoadGenesis(filename string, h *ChainHelper) error
LoadGenesis loads the genesis chain from the file.
func SubscribeNewBlock ¶
Types ¶
type Chain ¶
type Chain struct { Id types.Hash `json:"id"` Height uint32 `json:"height"` Payload types.Hash `json:"payload"` Txs []types.Hash `json:"txs"` // contains filtered or unexported fields }
Chain is a branch in a network.
func (*Chain) UpdatePayload ¶
UpdatePayload updates payload field responsible for the security of transactions inside.
type ChainHelper ¶
type ChainHelper struct {
// contains filtered or unexported fields
}
ChainHelper is an assistant for management of chains and transactions.
func NewChainHelper ¶
func NewChainHelper(db *leveldb.Db) *ChainHelper
NewChainHelper creates chain helper instance with database tables, TxProcessor and AccountManager instances.
func (*ChainHelper) AccountManager ¶
func (h *ChainHelper) AccountManager() *account.AccountManager
AccountManager gets AccountManager instance.
func (*ChainHelper) GetChainByAddress ¶
func (h *ChainHelper) GetChainByAddress(address []byte) (*Chain, error)
GetChainByAddress gets chain by address wallet.
func (*ChainHelper) GetChainById ¶
func (h *ChainHelper) GetChainById(id []byte) (*Chain, error)
GetChainById gets chain by chainid.
type DefaultProcessor ¶
type DefaultProcessor struct {
// contains filtered or unexported fields
}
DefaultProcessor is the base processor for blocks.
func NewProcessor ¶
func NewProcessor(db *leveldb.Db) *DefaultProcessor
NewProcessor creates a new DefaultProcessor.
type TxProcessor ¶
type TxProcessor interface { // Process processes the transaction, but does not write to the chain. Process(tx *types.Tx, ch *Chain) error // Validate checks the transaction for validity. Validate(tx *types.Tx, ch *Chain) error }
TxProcessor responsible for the validation of the transaction and its processing.
Click to show internal directories.
Click to hide internal directories.