Documentation
¶
Index ¶
- type ChangesPullResults
- type Database
- func (db *Database) CheckConnection() error
- func (db *Database) CheckConnectionIsOpen() bool
- func (db *Database) CleanConnection()
- func (db *Database) Clone() Database
- func (db *Database) CloseConnection() error
- func (db *Database) DB() database.DBManager
- func (db *Database) Dump(file string) error
- func (db *Database) GetAllTables() ([]string, error)
- func (db *Database) Init()
- func (db *Database) InitDatabase() error
- func (db *Database) OpenConnection(sessid string) error
- func (db *Database) OpenConnectionIfNeeded(reason string, sessid string) bool
- func (db *Database) PrepareConnection(sessid string)
- func (db *Database) Restore(file string) error
- func (db *Database) SetConfig(config database.DatabaseConfig)
- func (db *Database) SetLogger(Logger *utils.LoggerMan)
- type Node
- func (n *Node) AddBlock(block *structures.Block) (uint, error)
- func (n *Node) AddNodeToKnown(addr net.NodeAddr, sendversion bool)
- func (n *Node) BlockchainExist() bool
- func (n *Node) CheckAddressKnown(addr net.NodeAddr) bool
- func (orignode *Node) Clone() *Node
- func (n *Node) CreateBlockchain(minterAddress string, pubKey []byte, privateKey ecdsa.PrivateKey) error
- func (n *Node) DropBlock() error
- func (n *Node) DumpBlockchain(file string) error
- func (n *Node) GetBCManager() (*blockchain.Blockchain, error)
- func (n *Node) GetBlockChainIterator() (*blockchain.BlockchainIterator, error)
- func (n *Node) GetCommunicationManager() *communicationManager
- func (n *Node) GetNodeState() (nodeclient.ComGetNodeState, error)
- func (n *Node) GetSQLQueryManager() (consensus.SQLTransactionsInterface, error)
- func (n *Node) GetTransactionsManager() transactions.TransactionsManagerInterface
- func (n *Node) Init()
- func (n *Node) InitBlockchainFromOther(host string, port int) (bool, error)
- func (n *Node) InitClient() error
- func (n *Node) InitNodes(list []net.NodeAddr, force bool) error
- func (n *Node) ReceivedBlockFromOtherNode(addrfrom net.NodeAddr, bsdata []byte) (int, error)
- func (n *Node) ReceivedFullBlockFromOtherNode(blockdata []byte) (int, uint, *structures.Block, error)
- func (n *Node) ReceivedNewCurrencyTransactionData(txBytes []byte, Signature []byte) (*structures.Transaction, error)
- func (n *Node) ReceivedNewTransaction(tx *structures.Transaction, flags int) error
- func (n *Node) RestoreBlockchain(file string) error
- func (n *Node) SQLTransaction(PubKey []byte, privKey ecdsa.PrivateKey, sqlcommand string) ([]byte, error)
- func (n *Node) Send(PubKey []byte, privKey ecdsa.PrivateKey, to string, amount float64) ([]byte, error)
- func (n *Node) SendVersionToNodes(nodes []net.NodeAddr)
- func (n *Node) TryToMakeBlock(newTransactionID []byte, callback PreparedTransactionsCallback) ([]byte, error)
- type NodeBlockchain
- func (n *NodeBlockchain) AddBlock(block *structures.Block) (uint, error)
- func (n *NodeBlockchain) CheckBlockExists(blockHash []byte) (bool, error)
- func (n *NodeBlockchain) CheckBlockState(hash, prevhash []byte) (int, error)
- func (n *NodeBlockchain) DropBlock() (*structures.Block, error)
- func (n *NodeBlockchain) GetAddressHistory(address string) ([]structures.TransactionsHistory, error)
- func (n *NodeBlockchain) GetBCManager() *blockchain.Blockchain
- func (n *NodeBlockchain) GetBCTopState(bcount int) (height int, topBlocks [][]byte, err error)
- func (n *NodeBlockchain) GetBestHeight() (int, error)
- func (n *NodeBlockchain) GetBlock(hash []byte) (*structures.Block, error)
- func (n *NodeBlockchain) GetBlocksAfter(hash []byte) ([]*structures.BlockShort, error)
- func (n *NodeBlockchain) GetBranchesReplacement(sideBranchHash []byte, tip []byte) ([]*structures.Block, []*structures.Block, error)
- func (n *NodeBlockchain) GetTopBlockHash() ([]byte, error)
- type NodeLocks
- type NodesListStorage
- type PreparedTransactionsCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangesPullResults ¶
type ChangesPullResults struct { AddedTransactions [][]byte AddedBlocks [][]byte AddedNodes []net.NodeAddr }
func (ChangesPullResults) AnyChangesPulled ¶
func (p ChangesPullResults) AnyChangesPulled() bool
Detects if there were any changes pulled
type Database ¶
type Database struct { Logger *utils.LoggerMan Config database.DatabaseConfig // contains filtered or unexported fields }
func (*Database) CheckConnection ¶
check if connection to DB can be set
func (*Database) CheckConnectionIsOpen ¶
check if connection was opened
func (*Database) Clone ¶
Clone database object. all is clonned except locker object. locker object is shared between all objects
func (*Database) CloseConnection ¶
func (*Database) GetAllTables ¶
check if connection to DB can be set
func (*Database) InitDatabase ¶
prepare database before the first user
func (*Database) OpenConnection ¶
open DB connection if it is not yet opened
func (*Database) OpenConnectionIfNeeded ¶
open connection if it is not yet opened
func (*Database) PrepareConnection ¶
func (*Database) SetConfig ¶
func (db *Database) SetConfig(config database.DatabaseConfig)
type Node ¶
type Node struct { NodeBC NodeBlockchain NodeNet net.NodeNetwork Logger *utils.LoggerMan NodeClient *nodeclient.NodeClient DBConn *Database ConfigDir string MinterAddress string ProxyPubKey []byte ProxyPrivateKey ecdsa.PrivateKey OtherNodes []net.NodeAddr SessionID string ConsensusConfig *consensus.ConsensusConfig // contains filtered or unexported fields }
This structure is central part of the application. only it can acces to blockchain and inside it all operation are done
func (*Node) AddNodeToKnown ¶
Add node We need this for case when we want to do some more actions after node added
func (*Node) BlockchainExist ¶
func (*Node) CreateBlockchain ¶
func (n *Node) CreateBlockchain(minterAddress string, pubKey []byte, privateKey ecdsa.PrivateKey) error
Create new blockchain, add genesis block witha given text
func (*Node) DropBlock ¶
* Drop block from the top of blockchain * This will not check if there are other branch that can now be longest and becomes main branch
func (*Node) GetBCManager ¶
func (n *Node) GetBCManager() (*blockchain.Blockchain, error)
Build BC manager structure
func (*Node) GetBlockChainIterator ¶
func (n *Node) GetBlockChainIterator() (*blockchain.BlockchainIterator, error)
Creates iterator to go over blockchain
func (*Node) GetCommunicationManager ¶
func (n *Node) GetCommunicationManager() *communicationManager
Create communication object to do requests to othernodes
func (*Node) GetNodeState ¶
func (n *Node) GetNodeState() (nodeclient.ComGetNodeState, error)
Get node state
func (*Node) GetSQLQueryManager ¶
func (n *Node) GetSQLQueryManager() (consensus.SQLTransactionsInterface, error)
Init SQL transactions manager
func (*Node) GetTransactionsManager ¶
func (n *Node) GetTransactionsManager() transactions.TransactionsManagerInterface
Build transaction manager structure
func (*Node) Init ¶
func (n *Node) Init()
Init node. Init interfaces of all DBs, blockchain, unspent transactions, unapproved transactions
func (*Node) InitBlockchainFromOther ¶
func (*Node) InitClient ¶
Init network client object. It is used to communicate with other nodes
func (*Node) ReceivedBlockFromOtherNode ¶
New block info received from oher node. It is only Hash and PrevHash, not full block Check if this is new block and if previous block is fine returns state of processing. if a block data was requested or exists or prev doesn't exist
func (*Node) ReceivedFullBlockFromOtherNode ¶
func (n *Node) ReceivedFullBlockFromOtherNode(blockdata []byte) (int, uint, *structures.Block, error)
* New block info received from oher node * Check if this is new block and if previous block is fine * returns state of processing. if a block data was requested or exists or prev doesn't exist
func (*Node) ReceivedNewCurrencyTransactionData ¶
func (n *Node) ReceivedNewCurrencyTransactionData(txBytes []byte, Signature []byte) (*structures.Transaction, error)
New transactions created. It is received in serialysed view and signatures separately This data is ready to be convertd to complete gransaction
func (*Node) ReceivedNewTransaction ¶
func (n *Node) ReceivedNewTransaction(tx *structures.Transaction, flags int) error
Received new transaction . This must verify and if all ok it adds to the pool
func (*Node) RestoreBlockchain ¶
Create new blockchain in empty DB using a DB dump
func (*Node) SQLTransaction ¶
func (n *Node) SQLTransaction(PubKey []byte, privKey ecdsa.PrivateKey, sqlcommand string) ([]byte, error)
Execute SQL query This adds a transaction directly to the DB. Can be executed when a node server is not running This creates SQL transaction . Currency part can be present if SQL query "costs money"
func (*Node) Send ¶
func (n *Node) Send(PubKey []byte, privKey ecdsa.PrivateKey, to string, amount float64) ([]byte, error)
Send money . This adds a transaction directly to the DB. Can be executed when a node server is not running This creates currency transfer transaction where SQL command is not present
func (*Node) SendVersionToNodes ¶
Send own version to all known node
func (*Node) TryToMakeBlock ¶
func (n *Node) TryToMakeBlock(newTransactionID []byte, callback PreparedTransactionsCallback) ([]byte, error)
Try to make a block. If no enough transactions, send new transaction to all other nodes
type NodeBlockchain ¶
type NodeBlockchain struct { Logger *utils.LoggerMan MinterAddress string DBConn *Database // contains filtered or unexported fields }
func (*NodeBlockchain) AddBlock ¶
func (n *NodeBlockchain) AddBlock(block *structures.Block) (uint, error)
Add block to blockchain Block is not yet verified
func (*NodeBlockchain) CheckBlockExists ¶
func (n *NodeBlockchain) CheckBlockExists(blockHash []byte) (bool, error)
Checks if a block exists in the chain. It will go over blocks list
func (*NodeBlockchain) CheckBlockState ¶
func (n *NodeBlockchain) CheckBlockState(hash, prevhash []byte) (int, error)
* Checks state of a block by hashes * returns * -1 BCBState_error * 0 BCBState_canAdd if block doesn't exist and prev block exists * 1 BCBState_exists if block exists * 2 BCBState_notExistAndPrevNotExist if block doesn't exist and prev block doesn't exist
func (*NodeBlockchain) DropBlock ¶
func (n *NodeBlockchain) DropBlock() (*structures.Block, error)
Drop block from a top of blockchain
func (*NodeBlockchain) GetAddressHistory ¶
func (n *NodeBlockchain) GetAddressHistory(address string) ([]structures.TransactionsHistory, error)
Returns history of transactions for given address
func (*NodeBlockchain) GetBCManager ¶
func (n *NodeBlockchain) GetBCManager() *blockchain.Blockchain
func (*NodeBlockchain) GetBCTopState ¶
func (n *NodeBlockchain) GetBCTopState(bcount int) (height int, topBlocks [][]byte, err error)
Get BC top info, height and last N block hashes
func (*NodeBlockchain) GetBestHeight ¶
func (n *NodeBlockchain) GetBestHeight() (int, error)
Returns height of the chain. Index of top block
func (*NodeBlockchain) GetBlock ¶
func (n *NodeBlockchain) GetBlock(hash []byte) (*structures.Block, error)
Get block objet by hash
func (*NodeBlockchain) GetBlocksAfter ¶
func (n *NodeBlockchain) GetBlocksAfter(hash []byte) ([]*structures.BlockShort, error)
Get next blocks uppper then given
func (*NodeBlockchain) GetBranchesReplacement ¶
func (n *NodeBlockchain) GetBranchesReplacement(sideBranchHash []byte, tip []byte) ([]*structures.Block, []*structures.Block, error)
returns two branches of a block starting from their common block. One of branches is primary at this time
func (*NodeBlockchain) GetTopBlockHash ¶
func (n *NodeBlockchain) GetTopBlockHash() ([]byte, error)
Return top hash
type NodesListStorage ¶
func (NodesListStorage) AddNodeToKnown ¶
func (s NodesListStorage) AddNodeToKnown(addr net.NodeAddr)
func (NodesListStorage) GetCountOfKnownNodes ¶
func (s NodesListStorage) GetCountOfKnownNodes() (int, error)
func (NodesListStorage) RemoveNodeFromKnown ¶
func (s NodesListStorage) RemoveNodeFromKnown(addr net.NodeAddr)