Documentation
¶
Index ¶
- Constants
- func GetBlocksDbPath() string
- func GetDataDir() string
- func GetGenesisFilePath() string
- func InitFS() error
- func InitGenesis() error
- func SetConfig(config CoreConfig)
- type Block
- type BlockConfig
- type BlockFS
- type BlockHeader
- type CoreConfig
- type FsProvider
- type Genesis
- type GenesisConfig
- type State
- func (s *State) AddBlock(block Block) (common.Hash, error)
- func (s *State) AddTransaction(tx Transaction) error
- func (s *State) Close()
- func (s *State) Copy() State
- func (s *State) GetBlock(blockHash common.Hash) (BlockFS, error)
- func (s *State) GetBlockWithHashBytes(hashBytes []byte) (BlockFS, error)
- func (s *State) GetBlocksAfter(hash common.Hash) ([]Block, error)
- func (s *State) LatestBlock() Block
- func (s *State) LatestBlockHash() common.Hash
- func (s *State) NextBlockNumber() uint64
- func (s *State) ValidateTxn(tx Transaction) error
- type StateConfig
- type Transaction
- func (t *Transaction) Cost() uint
- func (t *Transaction) Data() string
- func (t *Transaction) Encode() ([]byte, error)
- func (t *Transaction) Fee() uint
- func (t *Transaction) From() common.Address
- func (t *Transaction) Hash() common.Hash
- func (t *Transaction) IsAuthentic() (bool, error)
- func (t *Transaction) Sign() error
- func (t *Transaction) To() common.Address
- func (t *Transaction) Value() uint
- func (t *Transaction) WithSignature(signature common.Signature)
- type TransactionContent
- type TransactionData
Constants ¶
View Source
const INDEX_BLOCK_HASH = "block_hash"
View Source
const INDEX_BLOCK_NUMBER = "block_no"
View Source
const MINING_ALGO_POW = "pow"
Variables ¶
This section is empty.
Functions ¶
func GetBlocksDbPath ¶
func GetBlocksDbPath() string
func GetDataDir ¶
func GetDataDir() string
func GetGenesisFilePath ¶
func GetGenesisFilePath() string
func InitGenesis ¶
func InitGenesis() error
func SetConfig ¶
func SetConfig(config CoreConfig)
Types ¶
type Block ¶
type Block struct { Header BlockHeader `json:"header"` Transactions []Transaction `json:"transactions"` Data []byte `json:"data,omitempty"` }
func (Block) IsBlockHashValid ¶
type BlockConfig ¶
type BlockHeader ¶
type BlockHeader struct { ParentHash common.Hash `json:"parentHash"` Timestamp uint64 `json:"timestamp"` Number uint64 `json:"number"` Nonce uint64 `json:"nonce"` Miner common.Address `json:"miner"` MiningAlgo string `json:"miningAlgo"` MiningComplexity uint64 `json:"miningComplexity"` Reward uint64 `json:"reward"` }
type CoreConfig ¶
type CoreConfig struct { State StateConfig `yaml:"state,omitempty"` Block BlockConfig `yaml:"block,omitempty"` }
var Config CoreConfig = Defaults()
func Defaults ¶
func Defaults() CoreConfig
type FsProvider ¶
type Genesis ¶
type Genesis struct { Timestamp uint64 `json:"timestamp"` Config GenesisConfig `json:"config"` Balances map[common.Address]uint `json:"balances"` }
type GenesisConfig ¶
type GenesisConfig struct {
ChainId string `json:"chainId"`
}
type State ¶
func (*State) AddTransaction ¶
func (s *State) AddTransaction(tx Transaction) error
func (*State) GetBlockWithHashBytes ¶
func (*State) GetBlocksAfter ¶
TODO : this needs to be fixed and changed to query from leveldb
func (*State) LatestBlock ¶
func (*State) LatestBlockHash ¶
func (*State) NextBlockNumber ¶
func (*State) ValidateTxn ¶
func (s *State) ValidateTxn(tx Transaction) error
type StateConfig ¶
type StateConfig struct {
DbFile string `yaml:"dbfile,omitempty"`
}
type Transaction ¶
type Transaction struct { TxnContent TransactionContent `json:"txnContent"` TxnHash common.Hash `json:"txnHash"` Signature common.Signature `json:"signature"` }
func NewTransaction ¶
func (*Transaction) Cost ¶
func (t *Transaction) Cost() uint
func (*Transaction) Data ¶
func (t *Transaction) Data() string
func (*Transaction) Encode ¶
func (t *Transaction) Encode() ([]byte, error)
func (*Transaction) Fee ¶
func (t *Transaction) Fee() uint
func (*Transaction) From ¶
func (t *Transaction) From() common.Address
func (*Transaction) Hash ¶
func (t *Transaction) Hash() common.Hash
func (*Transaction) IsAuthentic ¶
func (t *Transaction) IsAuthentic() (bool, error)
func (*Transaction) Sign ¶
func (t *Transaction) Sign() error
func (*Transaction) To ¶
func (t *Transaction) To() common.Address
func (*Transaction) Value ¶
func (t *Transaction) Value() uint
func (*Transaction) WithSignature ¶
func (t *Transaction) WithSignature(signature common.Signature)
type TransactionContent ¶
type TransactionContent struct { TxnData TransactionData `json:"txnData"` TxnFee uint `json:"txnFee"` Timestamp uint64 `json:"timestamp"` }
Click to show internal directories.
Click to hide internal directories.