Documentation ¶
Index ¶
- Constants
- func RunRestAPI(api BlockchainAPI)
- type API
- func (api *API) AccountTransactions(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
- func (api *API) Balances(keys []string) []int64
- func (api *API) BlockByHash(hashBase64 string) *block.Block
- func (api *API) BlockByHeight(height uint64) *block.Block
- func (api *API) BlockHeight() uint64
- func (api *API) BlockTime() int64
- func (api *API) BlockTransactionsByHeight(blockHeight uint64, offset, limit uint64) (*block.Transactions, uint64)
- func (api *API) Blocks(offset, limit uint64) ([]block.Block, uint64)
- func (api *API) BlocksTotal() uint64
- func (api *API) MintKey() ed25519.PublicKey
- func (api *API) Nodes() map[string]*replication.NodeData
- func (api *API) RandomKeys(num uint64) []ed25519.PublicKey
- func (api *API) TPS() int64
- func (api *API) TransactionsFrom(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
- func (api *API) TransactionsTo(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
- func (api *API) TransactionsTotal() uint64
- type AccountModel
- type BlockDetailsModel
- type BlockListModel
- type BlockModel
- type BlockchainAPI
- type BlockchainApiMock
- func (apiMock *BlockchainApiMock) AccountTransactions(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
- func (apiMock *BlockchainApiMock) Balances(keys []string) []int64
- func (apiMock *BlockchainApiMock) BlockByHash(hashBase64 string) *block.Block
- func (apiMock *BlockchainApiMock) BlockByHeight(height uint64) *block.Block
- func (apiMock *BlockchainApiMock) BlockHeight() uint64
- func (apiMock *BlockchainApiMock) BlockTime() int64
- func (apiMock *BlockchainApiMock) BlockTransactionsByHeight(blockHeight uint64, offset, limit uint64) (*block.Transactions, uint64)
- func (apiMock *BlockchainApiMock) Blocks(offset, limit uint64) ([]block.Block, uint64)
- func (apiMock *BlockchainApiMock) BlocksTotal() uint64
- func (apiMock *BlockchainApiMock) MintKey() ed25519.PublicKey
- func (apiMock *BlockchainApiMock) Nodes() map[string]*replication.NodeData
- func (apiMock *BlockchainApiMock) RandomKeys(uint64) []ed25519.PublicKey
- func (apiMock *BlockchainApiMock) TPS() int64
- func (apiMock *BlockchainApiMock) TransactionsFrom(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
- func (apiMock *BlockchainApiMock) TransactionsTo(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
- func (apiMock *BlockchainApiMock) TransactionsTotal() uint64
- type DB
- func (db *DB) GetAccountTransactions(account []byte, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DB) GetBlockByHash(hash []byte) *block.Block
- func (db *DB) GetBlockByHeight(height uint64) *block.Block
- func (db *DB) GetBlocksAfterHeight(offset, limit uint64) ([]block.Block, uint64)
- func (db *DB) GetBlocksBeforeHeight(offset, limit uint64) ([]block.Block, uint64)
- func (db *DB) GetTransactionsFrom(from []byte, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DB) GetTransactionsTo(to []byte, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DB) GetTxFromBlockByHeight(height uint64, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DB) SaveBlock(blk block.Block) error
- type DBMock
- func (db *DBMock) GetAccountTransactions(account []byte, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DBMock) GetBlockByHash(hash []byte) *block.Block
- func (db *DBMock) GetBlockByHeight(height uint64) *block.Block
- func (db *DBMock) GetBlocksAfterHeight(offset, limit uint64) ([]block.Block, uint64)
- func (db *DBMock) GetBlocksBeforeHeight(offset, limit uint64) ([]block.Block, uint64)
- func (db *DBMock) GetTransactionsFrom(from []byte, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DBMock) GetTransactionsTo(to []byte, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DBMock) GetTxFromBlockByHeight(height uint64, offset, limit uint64) (*block.Transactions, uint64)
- func (db *DBMock) SaveBlock(blk block.Block) error
- type DataBase
- type NodeDataModel
- type Stats
- type StatsModel
- type TransactinListModel
- type TransactionModel
Constants ¶
const ( // DBFilename is a path of the database file DBFilename = "./api.db" // MaxOffset is maximum number of transactions in database // https://github.com/golang/go/issues/9373 issue prevents to use max uint64 value MaxOffset = ^uint64(0) / 2 )
Variables ¶
This section is empty.
Functions ¶
func RunRestAPI ¶
func RunRestAPI(api BlockchainAPI)
RunRestAPI registers router and runs web server
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API struct stores all data source objects for blockchain api methods
func (*API) AccountTransactions ¶
func (api *API) AccountTransactions(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
AccountTransactions returns transactions from and to 'keyBase64' account
func (*API) Balances ¶
Balances takes array of account public keys in base64 format and returns balances
func (*API) BlockByHash ¶
BlockByHash returns block with hash
func (*API) BlockByHeight ¶
BlockByHeight returns meta info of block with specific height value
func (*API) BlockHeight ¶
BlockHeight returns last block's height, registered in the ledger
func (*API) BlockTransactionsByHeight ¶
func (api *API) BlockTransactionsByHeight(blockHeight uint64, offset, limit uint64) (*block.Transactions, uint64)
BlockTransactionsByHeight looks for block according heigh and returns it's transactions
func (*API) BlocksTotal ¶
BlocksTotal returns number of processed blocks from books
func (*API) Nodes ¶
func (api *API) Nodes() map[string]*replication.NodeData
Nodes returns remote nodes connected to us
func (*API) RandomKeys ¶
RandomKeys returns account keys from book manager, to monitor them on web site
func (*API) TransactionsFrom ¶
func (api *API) TransactionsFrom(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
TransactionsFrom returns transactions from 'keyBase64' account
func (*API) TransactionsTo ¶
func (api *API) TransactionsTo(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
TransactionsTo returns transactions to 'keyBase64' account
func (*API) TransactionsTotal ¶
TransactionsTotal returns total transactions count
type AccountModel ¶
AccountModel is the data model of the Ansiblock blockchain Accounts. It is passed to the front end to display each account public key with its balance
type BlockDetailsModel ¶
type BlockDetailsModel struct { Count uint64 VDF string BlockHeight uint64 Taransactions []TransactionModel }
BlockDetailsModel is the data model of the Ansiblock blockchain detailed blocks. It is passed to the front end to display detailed info of the block
type BlockListModel ¶
type BlockListModel struct { Blocks []BlockModel Offset uint64 }
BlockListModel stores block list and offset value, for paging, to get next part of blocks
type BlockModel ¶
BlockModel is the data model of the Ansiblock blockchain blocks. It is passed to the front end to display each block
type BlockchainAPI ¶
type BlockchainAPI interface { Nodes() map[string]*replication.NodeData TransactionsTotal() uint64 BlocksTotal() uint64 Balances(keys []string) []int64 TransactionsFrom(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64) TransactionsTo(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64) AccountTransactions(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64) BlockTransactionsByHeight(blockHeight uint64, offset, limit uint64) (*block.Transactions, uint64) Blocks(offset, limit uint64) ([]block.Block, uint64) BlockByHeight(height uint64) *block.Block BlockByHash(hashBase64 string) *block.Block BlockHeight() uint64 TPS() int64 BlockTime() int64 RandomKeys(uint64) []ed25519.PublicKey MintKey() ed25519.PublicKey }
BlockchainAPI gives access to information about blocks, transactions, nodes etc. part of information is extracted from db.
type BlockchainApiMock ¶
type BlockchainApiMock struct { NodesMap map[string]*replication.NodeData TransactionsTotalVal uint64 BlocksToTalVal uint64 BalanceValues []int64 AccTransactions *block.Transactions BlockTransactions *block.Transactions BlocksList []block.Block Block *block.Block BlockHeightVal uint64 TPSVal int64 BlockTimeVal int64 QueryParams map[string]string }
func NewBlockchainAPIMock ¶
func NewBlockchainAPIMock() *BlockchainApiMock
func (*BlockchainApiMock) AccountTransactions ¶
func (apiMock *BlockchainApiMock) AccountTransactions(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
func (*BlockchainApiMock) Balances ¶
func (apiMock *BlockchainApiMock) Balances(keys []string) []int64
func (*BlockchainApiMock) BlockByHash ¶
func (apiMock *BlockchainApiMock) BlockByHash(hashBase64 string) *block.Block
func (*BlockchainApiMock) BlockByHeight ¶
func (apiMock *BlockchainApiMock) BlockByHeight(height uint64) *block.Block
func (*BlockchainApiMock) BlockHeight ¶
func (apiMock *BlockchainApiMock) BlockHeight() uint64
func (*BlockchainApiMock) BlockTime ¶
func (apiMock *BlockchainApiMock) BlockTime() int64
func (*BlockchainApiMock) BlockTransactionsByHeight ¶
func (apiMock *BlockchainApiMock) BlockTransactionsByHeight(blockHeight uint64, offset, limit uint64) (*block.Transactions, uint64)
func (*BlockchainApiMock) Blocks ¶
func (apiMock *BlockchainApiMock) Blocks(offset, limit uint64) ([]block.Block, uint64)
func (*BlockchainApiMock) BlocksTotal ¶
func (apiMock *BlockchainApiMock) BlocksTotal() uint64
func (*BlockchainApiMock) MintKey ¶
func (apiMock *BlockchainApiMock) MintKey() ed25519.PublicKey
func (*BlockchainApiMock) Nodes ¶
func (apiMock *BlockchainApiMock) Nodes() map[string]*replication.NodeData
func (*BlockchainApiMock) RandomKeys ¶
func (apiMock *BlockchainApiMock) RandomKeys(uint64) []ed25519.PublicKey
func (*BlockchainApiMock) TPS ¶
func (apiMock *BlockchainApiMock) TPS() int64
func (*BlockchainApiMock) TransactionsFrom ¶
func (apiMock *BlockchainApiMock) TransactionsFrom(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
func (*BlockchainApiMock) TransactionsTo ¶
func (apiMock *BlockchainApiMock) TransactionsTo(keyBase64 string, offset, limit uint64) (*block.Transactions, uint64)
func (*BlockchainApiMock) TransactionsTotal ¶
func (apiMock *BlockchainApiMock) TransactionsTotal() uint64
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is database object, created by NewDBConnection method
func NewDBConnection ¶
NewDBConnection creates a connection to database Database will be initialized with tables and indexes if there is no file or it does not contain necessary schema
func (*DB) GetAccountTransactions ¶
func (db *DB) GetAccountTransactions(account []byte, offset, limit uint64) (*block.Transactions, uint64)
GetAccountTransactions gets abstract of given account from database including transaction with given offset
func (*DB) GetBlockByHash ¶
GetBlockByHash gets block from database with VDF value returns pointer to block or nil if not found
func (*DB) GetBlockByHeight ¶
GetBlockByHeight gets block from database searching by height returns pointer to block or nil if not found
func (*DB) GetBlocksAfterHeight ¶
GetBlocksAfterHeight gets unseen new blocks from database by height, including block with given height
func (*DB) GetBlocksBeforeHeight ¶
GetBlocksBeforeHeight gets old blocks from database by height, including block with given height
func (*DB) GetTransactionsFrom ¶
GetTransactionsFrom gets transactions from DB sent from given address including transaction with given offset
func (*DB) GetTransactionsTo ¶
GetTransactionsTo gets transactions from DB received by given address including transaction with given offset
func (*DB) GetTxFromBlockByHeight ¶
func (db *DB) GetTxFromBlockByHeight(height uint64, offset, limit uint64) (*block.Transactions, uint64)
GetTxFromBlockByHeight returns transactions associated with block given by height including transaction with given offset
type DBMock ¶
type DBMock struct { Trans *block.Transactions Block *block.Block Blocks []*block.Block From []byte To []byte }
func (*DBMock) GetAccountTransactions ¶
func (*DBMock) GetBlocksAfterHeight ¶
func (*DBMock) GetBlocksBeforeHeight ¶
func (*DBMock) GetTransactionsFrom ¶
func (*DBMock) GetTransactionsTo ¶
func (*DBMock) GetTxFromBlockByHeight ¶
type DataBase ¶
type DataBase interface { SaveBlock(blk block.Block) error GetBlockByHash(hash []byte) *block.Block GetBlockByHeight(Height uint64) *block.Block GetBlocksAfterHeight(offset, limit uint64) ([]block.Block, uint64) GetBlocksBeforeHeight(offset, limit uint64) ([]block.Block, uint64) GetTxFromBlockByHeight(height uint64, offset, limit uint64) (*block.Transactions, uint64) GetTransactionsFrom(from []byte, offset, limit uint64) (*block.Transactions, uint64) GetTransactionsTo(to []byte, offset, limit uint64) (*block.Transactions, uint64) GetAccountTransactions(account []byte, offset, limit uint64) (*block.Transactions, uint64) }
DataBase interface
type NodeDataModel ¶
NodeDataModel is the data model of the Ansiblock blockchain nodes. It is passed to the front end to display info of the nodes in the blockchain
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats struct stores global statistics
type StatsModel ¶
StatsModel is the data model of the Ansiblock blockchain stats. It is passed to the front end to display
type TransactinListModel ¶
type TransactinListModel struct { Ts []TransactionModel Offset uint64 }
TransactinListModel stores transaction list and offset value, for gaping, to get next part of transactions