Documentation ¶
Index ¶
- Constants
- func NewBucketNotFoundDBError() error
- func NewDBCursorStopError() error
- func NewDBError(err string, kind string) error
- func NewDBIsNotReadyError() error
- func NewHashDBError(err string) error
- func NewHashEmptyDBError() error
- func NewHashNotFoundDBError(err string) error
- func NewNotFoundDBError(kind string) error
- type Blockchain
- func (bc *Blockchain) AddToChain(hash, prevHash []byte) error
- func (bc *Blockchain) BlockInChain(hash []byte) (bool, error)
- func (bc *Blockchain) CheckBlockExists(hash []byte) (bool, error)
- func (bc *Blockchain) DeleteBlock(hash []byte) error
- func (bc *Blockchain) GetBlock(hash []byte) ([]byte, error)
- func (bc *Blockchain) GetFirstHash() ([]byte, error)
- func (bc *Blockchain) GetLocationInChain(hash []byte) (bool, []byte, []byte, error)
- func (bc *Blockchain) GetTopBlock() ([]byte, error)
- func (bc *Blockchain) GetTopHash() ([]byte, error)
- func (bc *Blockchain) InitDB() error
- func (bc *Blockchain) PutBlock(hash []byte, blockdata []byte) error
- func (bc *Blockchain) PutBlockOnTop(hash []byte, blockdata []byte) error
- func (bc *Blockchain) RemoveFromChain(hash []byte) error
- func (bc *Blockchain) SaveFirstHash(hash []byte) error
- func (bc *Blockchain) SaveTopHash(hash []byte) error
- type BlockchainInterface
- type BoltDB
- type BoltDBLocker
- type BoltDBManager
- func (bdm *BoltDBManager) CheckDBExists() (bool, error)
- func (bdm *BoltDBManager) CloseConnection() error
- func (bdm *BoltDBManager) GetBlockchainObject() (BlockchainInterface, error)
- func (bdm *BoltDBManager) GetLockerObject() DatabaseLocker
- func (bdm *BoltDBManager) GetNodesObject() (NodesInterface, error)
- func (bdm *BoltDBManager) GetTransactionsObject() (TranactionsInterface, error)
- func (bdm *BoltDBManager) GetUnapprovedTransactionsObject() (UnapprovedTransactionsInterface, error)
- func (bdm *BoltDBManager) GetUnspentOutputsObject() (UnspentOutputsInterface, error)
- func (bdm *BoltDBManager) InitDatabase() error
- func (bdm *BoltDBManager) IsConnectionOpen() bool
- func (bdm *BoltDBManager) OpenConnection(reason string) error
- func (bdm *BoltDBManager) SetConfig(config DatabaseConfig) error
- func (bdm *BoltDBManager) SetLockerObject(lockerobj DatabaseLocker)
- func (bdm *BoltDBManager) SetLogger(logger *utils.LoggerMan) error
- type DBError
- type DBManager
- type DatabaseConfig
- type DatabaseConnection
- type DatabaseLocker
- type ForEachKeyIteratorInterface
- type Nodes
- type NodesInterface
- type Tranactions
- func (txs *Tranactions) DeleteTXSpentData(txID []byte) error
- func (txs *Tranactions) DeleteTXToBlockLink(txID []byte) error
- func (txs *Tranactions) GetBlockHashForTX(txID []byte) ([]byte, error)
- func (txs *Tranactions) GetTXSpentOutputs(txID []byte) ([]byte, error)
- func (txs *Tranactions) InitDB() error
- func (txs *Tranactions) PutTXSpentOutputs(txID []byte, outputs []byte) error
- func (txs *Tranactions) PutTXToBlockLink(txID []byte, blockHash []byte) error
- func (txs *Tranactions) TruncateDB() error
- type TranactionsInterface
- type UnapprovedTransactions
- func (uts *UnapprovedTransactions) DeleteTransaction(txID []byte) error
- func (uts *UnapprovedTransactions) ForEach(callback ForEachKeyIteratorInterface) error
- func (uts *UnapprovedTransactions) GetCount() (int, error)
- func (uts *UnapprovedTransactions) GetTransaction(txID []byte) ([]byte, error)
- func (uts *UnapprovedTransactions) InitDB() error
- func (uts *UnapprovedTransactions) PutTransaction(txID []byte, txdata []byte) error
- func (uts *UnapprovedTransactions) TruncateDB() error
- type UnapprovedTransactionsInterface
- type UnspentOutputs
- func (uos *UnspentOutputs) DeleteDataForTransaction(txID []byte) error
- func (uos *UnspentOutputs) ForEach(callback ForEachKeyIteratorInterface) error
- func (uos *UnspentOutputs) GetCount() (int, error)
- func (uos *UnspentOutputs) GetDataForTransaction(txID []byte) ([]byte, error)
- func (uos *UnspentOutputs) InitDB() error
- func (uos *UnspentOutputs) PutDataForTransaction(txID []byte, txData []byte) error
- func (uos *UnspentOutputs) TruncateDB() error
- type UnspentOutputsInterface
Constants ¶
const ( ClassNameNodes = "nodes" ClassNameBlockchain = "blockchain" ClassNameTransactions = "transactions" ClassNameUnapprovedTransactions = "unapprovedtransactions" ClassNameUnspentOutputs = "unspentoutputs" )
const DBCursorBreak = "cursorbreak"
const DBHashEmptyError = "hashisemptyd"
const DBHashError = "hashemptyd"
const DBHashNotFoundError = "hashnotfound"
const TXVerifyErrorNoInput = "noinput"
Variables ¶
This section is empty.
Functions ¶
func NewBucketNotFoundDBError ¶
func NewBucketNotFoundDBError() error
func NewDBCursorStopError ¶
func NewDBCursorStopError() error
func NewDBError ¶
func NewDBIsNotReadyError ¶
func NewDBIsNotReadyError() error
func NewHashDBError ¶
func NewHashEmptyDBError ¶
func NewHashEmptyDBError() error
func NewHashNotFoundDBError ¶
func NewNotFoundDBError ¶
Types ¶
type Blockchain ¶
type Blockchain struct {
DB *BoltDB
}
func (*Blockchain) AddToChain ¶
func (bc *Blockchain) AddToChain(hash, prevHash []byte) error
add block to chain
func (*Blockchain) BlockInChain ¶
func (bc *Blockchain) BlockInChain(hash []byte) (bool, error)
func (*Blockchain) CheckBlockExists ¶
func (bc *Blockchain) CheckBlockExists(hash []byte) (bool, error)
Check if block exists by hash
func (*Blockchain) DeleteBlock ¶
func (bc *Blockchain) DeleteBlock(hash []byte) error
Delete block record
func (*Blockchain) GetBlock ¶
func (bc *Blockchain) GetBlock(hash []byte) ([]byte, error)
Get block data by hash. It returns just []byte and and must be deserialised on ther place
func (*Blockchain) GetFirstHash ¶
func (bc *Blockchain) GetFirstHash() ([]byte, error)
func (*Blockchain) GetLocationInChain ¶
func (*Blockchain) GetTopBlock ¶
func (bc *Blockchain) GetTopBlock() ([]byte, error)
Get block on the top of blockchain
func (*Blockchain) GetTopHash ¶
func (bc *Blockchain) GetTopHash() ([]byte, error)
Get top level block hash
func (*Blockchain) InitDB ¶
func (bc *Blockchain) InitDB() error
create bucket etc. DB is already inited
func (*Blockchain) PutBlock ¶
func (bc *Blockchain) PutBlock(hash []byte, blockdata []byte) error
Add block record
func (*Blockchain) PutBlockOnTop ¶
func (bc *Blockchain) PutBlockOnTop(hash []byte, blockdata []byte) error
Add block to the top of block chain
func (*Blockchain) RemoveFromChain ¶
func (bc *Blockchain) RemoveFromChain(hash []byte) error
remove block from chain
func (*Blockchain) SaveFirstHash ¶
func (bc *Blockchain) SaveFirstHash(hash []byte) error
Save first (or genesis) block hash. It should be called when blockchain is created
func (*Blockchain) SaveTopHash ¶
func (bc *Blockchain) SaveTopHash(hash []byte) error
Save top level block hash
type BlockchainInterface ¶
type BlockchainInterface interface { InitDB() error GetTopBlock() ([]byte, error) GetBlock(hash []byte) ([]byte, error) PutBlockOnTop(hash []byte, blockdata []byte) error PutBlock(hash []byte, blockdata []byte) error CheckBlockExists(hash []byte) (bool, error) DeleteBlock(hash []byte) error SaveTopHash(hash []byte) error GetTopHash() ([]byte, error) SaveFirstHash(hash []byte) error GetFirstHash() ([]byte, error) GetLocationInChain(hash []byte) (bool, []byte, []byte, error) BlockInChain(hash []byte) (bool, error) RemoveFromChain(hash []byte) error AddToChain(hash, prevHash []byte) error }
type BoltDBLocker ¶
type BoltDBLocker struct {
// contains filtered or unexported fields
}
type BoltDBManager ¶
type BoltDBManager struct { Logger *utils.LoggerMan Config DatabaseConfig SessID string // contains filtered or unexported fields }
func (*BoltDBManager) CheckDBExists ¶
func (bdm *BoltDBManager) CheckDBExists() (bool, error)
Check if database was already inited
func (*BoltDBManager) CloseConnection ¶
func (bdm *BoltDBManager) CloseConnection() error
func (*BoltDBManager) GetBlockchainObject ¶
func (bdm *BoltDBManager) GetBlockchainObject() (BlockchainInterface, error)
returns BlockChain Database structure. does al init
func (*BoltDBManager) GetLockerObject ¶
func (bdm *BoltDBManager) GetLockerObject() DatabaseLocker
func (*BoltDBManager) GetNodesObject ¶
func (bdm *BoltDBManager) GetNodesObject() (NodesInterface, error)
returns Nodes Database structure. does al init
func (*BoltDBManager) GetTransactionsObject ¶
func (bdm *BoltDBManager) GetTransactionsObject() (TranactionsInterface, error)
returns Transaction Index Database structure. does al init
func (*BoltDBManager) GetUnapprovedTransactionsObject ¶
func (bdm *BoltDBManager) GetUnapprovedTransactionsObject() (UnapprovedTransactionsInterface, error)
returns Unapproved Transaction Database structure. does al init
func (*BoltDBManager) GetUnspentOutputsObject ¶
func (bdm *BoltDBManager) GetUnspentOutputsObject() (UnspentOutputsInterface, error)
returns Unspent Transactions Database structure. does al init
func (*BoltDBManager) InitDatabase ¶
func (bdm *BoltDBManager) InitDatabase() error
create empty database. must create all
func (*BoltDBManager) IsConnectionOpen ¶
func (bdm *BoltDBManager) IsConnectionOpen() bool
func (*BoltDBManager) OpenConnection ¶
func (bdm *BoltDBManager) OpenConnection(reason string) error
func (*BoltDBManager) SetConfig ¶
func (bdm *BoltDBManager) SetConfig(config DatabaseConfig) error
func (*BoltDBManager) SetLockerObject ¶
func (bdm *BoltDBManager) SetLockerObject(lockerobj DatabaseLocker)
type DBManager ¶
type DBManager interface { SetConfig(config DatabaseConfig) error SetLogger(logger *utils.LoggerMan) error GetLockerObject() DatabaseLocker SetLockerObject(lockerobj DatabaseLocker) InitDatabase() error CheckDBExists() (bool, error) OpenConnection(reason string) error CloseConnection() error IsConnectionOpen() bool GetBlockchainObject() (BlockchainInterface, error) GetTransactionsObject() (TranactionsInterface, error) GetUnapprovedTransactionsObject() (UnapprovedTransactionsInterface, error) GetUnspentOutputsObject() (UnspentOutputsInterface, error) GetNodesObject() (NodesInterface, error) }
type DatabaseConfig ¶
func (*DatabaseConfig) IsEmpty ¶
func (dbc *DatabaseConfig) IsEmpty() bool
func (*DatabaseConfig) SetDefault ¶
func (dbc *DatabaseConfig) SetDefault() error
type DatabaseConnection ¶
type DatabaseConnection interface {
Close() error
}
type DatabaseLocker ¶
type DatabaseLocker interface { }
locker interface. is empty for now. maybe in future we will have some methods
type Nodes ¶
type Nodes struct {
DB *BoltDB
}
func (*Nodes) DeleteNode ¶
func (*Nodes) ForEach ¶
func (ns *Nodes) ForEach(callback ForEachKeyIteratorInterface) error
retrns nodes list iterator
type NodesInterface ¶
type Tranactions ¶
type Tranactions struct {
DB *BoltDB
}
func (*Tranactions) DeleteTXSpentData ¶
func (txs *Tranactions) DeleteTXSpentData(txID []byte) error
Delete info about spent outputs for TX
func (*Tranactions) DeleteTXToBlockLink ¶
func (txs *Tranactions) DeleteTXToBlockLink(txID []byte) error
Delete link between TX and a block hash
func (*Tranactions) GetBlockHashForTX ¶
func (txs *Tranactions) GetBlockHashForTX(txID []byte) ([]byte, error)
Get block hash for TX
func (*Tranactions) GetTXSpentOutputs ¶
func (txs *Tranactions) GetTXSpentOutputs(txID []byte) ([]byte, error)
Get spent outputs for TX , seialised to bytes
func (*Tranactions) PutTXSpentOutputs ¶
func (txs *Tranactions) PutTXSpentOutputs(txID []byte, outputs []byte) error
Save spent outputs for TX
func (*Tranactions) PutTXToBlockLink ¶
func (txs *Tranactions) PutTXToBlockLink(txID []byte, blockHash []byte) error
Save link between TX and block hash
func (*Tranactions) TruncateDB ¶
func (txs *Tranactions) TruncateDB() error
type TranactionsInterface ¶
type TranactionsInterface interface { InitDB() error TruncateDB() error PutTXToBlockLink(txID []byte, blockHash []byte) error GetBlockHashForTX(txID []byte) ([]byte, error) DeleteTXToBlockLink(txID []byte) error PutTXSpentOutputs(txID []byte, outputs []byte) error GetTXSpentOutputs(txID []byte) ([]byte, error) DeleteTXSpentData(txID []byte) error }
type UnapprovedTransactions ¶
type UnapprovedTransactions struct {
DB *BoltDB
}
func (*UnapprovedTransactions) DeleteTransaction ¶
func (uts *UnapprovedTransactions) DeleteTransaction(txID []byte) error
delete transation from DB
func (*UnapprovedTransactions) ForEach ¶
func (uts *UnapprovedTransactions) ForEach(callback ForEachKeyIteratorInterface) error
execute functon for each key/value in the bucket
func (*UnapprovedTransactions) GetCount ¶
func (uts *UnapprovedTransactions) GetCount() (int, error)
get count of records in the table
func (*UnapprovedTransactions) GetTransaction ¶
func (uts *UnapprovedTransactions) GetTransaction(txID []byte) ([]byte, error)
returns transaction by ID if it exists
func (*UnapprovedTransactions) InitDB ¶
func (uts *UnapprovedTransactions) InitDB() error
func (*UnapprovedTransactions) PutTransaction ¶
func (uts *UnapprovedTransactions) PutTransaction(txID []byte, txdata []byte) error
Add transaction record
func (*UnapprovedTransactions) TruncateDB ¶
func (uts *UnapprovedTransactions) TruncateDB() error
type UnspentOutputs ¶
type UnspentOutputs struct {
DB *BoltDB
}
func (*UnspentOutputs) DeleteDataForTransaction ¶
func (uos *UnspentOutputs) DeleteDataForTransaction(txID []byte) error
func (*UnspentOutputs) ForEach ¶
func (uos *UnspentOutputs) ForEach(callback ForEachKeyIteratorInterface) error
execute functon for each key/value in the bucket
func (*UnspentOutputs) GetCount ¶
func (uos *UnspentOutputs) GetCount() (int, error)
get count of records in the table
func (*UnspentOutputs) GetDataForTransaction ¶
func (uos *UnspentOutputs) GetDataForTransaction(txID []byte) ([]byte, error)
func (*UnspentOutputs) InitDB ¶
func (uos *UnspentOutputs) InitDB() error
func (*UnspentOutputs) PutDataForTransaction ¶
func (uos *UnspentOutputs) PutDataForTransaction(txID []byte, txData []byte) error
func (*UnspentOutputs) TruncateDB ¶
func (uos *UnspentOutputs) TruncateDB() error
type UnspentOutputsInterface ¶
type UnspentOutputsInterface interface { InitDB() error TruncateDB() error ForEach(callback ForEachKeyIteratorInterface) error GetCount() (int, error) GetDataForTransaction(txID []byte) ([]byte, error) DeleteDataForTransaction(txID []byte) error PutDataForTransaction(txID []byte, txData []byte) error }