Documentation ¶
Index ¶
- type Database
- 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) Init()
- func (db *Database) InitDatabase() error
- func (db *Database) OpenConnection(reason string, sessid string) error
- func (db *Database) OpenConnectionIfNeeded(reason string, sessid string) bool
- func (db *Database) PrepareConnection(sessid string)
- 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 (n *Node) CreateBlockchain(address, genesisCoinbaseData string) error
- func (n *Node) DropBlock() error
- func (n *Node) GetBCManager() (*blockchain.Blockchain, error)
- func (n *Node) GetBlockChainIterator() (*blockchain.BlockchainIterator, error)
- func (n *Node) GetNodeState() (nodeclient.ComGetNodeState, 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) Send(PubKey []byte, privKey ecdsa.PrivateKey, to string, amount float64) ([]byte, error)
- func (n *Node) SendBlockToAll(newBlock *structures.Block, skipaddr net.NodeAddr)
- func (n *Node) SendTransactionToAll(tx *structures.Transaction)
- func (n *Node) SendVersionToNodes(nodes []net.NodeAddr)
- func (n *Node) TryToMakeBlock(newTransactionID []byte) ([]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) 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 NodesListStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct { Logger *utils.LoggerMan Config database.DatabaseConfig // contains filtered or unexported fields }
func (*Database) CheckConnectionIsOpen ¶
func (*Database) CleanConnection ¶
func (db *Database) CleanConnection()
func (*Database) Clone ¶
Clone database object. all is clonned except locker object. locker object is shared between all objects
func (*Database) CloseConnection ¶
func (*Database) InitDatabase ¶
prepare database before the first user
func (*Database) OpenConnection ¶
func (*Database) OpenConnectionIfNeeded ¶
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 DataDir string MinterAddress string NodeClient *nodeclient.NodeClient OtherNodes []net.NodeAddr DBConn *Database SessionID string }
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) CheckAddressKnown ¶
* Check if the address is known . If not then add to known * and send list of all addresses to that node
func (*Node) CreateBlockchain ¶
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) GetNodeState ¶
func (n *Node) GetNodeState() (nodeclient.ComGetNodeState, error)
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) 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
func (*Node) SendBlockToAll ¶
func (n *Node) SendBlockToAll(newBlock *structures.Block, skipaddr net.NodeAddr)
Send block to all known nodes This is used in case when new block was received from other node or created by this node. We will notify our network about new block But not send full block, only hash and previous hash. So, other can copy it Address from where we get it will be skipped
func (*Node) SendTransactionToAll ¶
func (n *Node) SendTransactionToAll(tx *structures.Transaction)
* Send transaction to all known nodes. This wil send only hash and node hash to check if hash exists or no
func (*Node) SendVersionToNodes ¶
* Send own version to all known nodes
type NodeBlockchain ¶
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) 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)