func (n *Node) SendVersionToNodes(nodes []net.NodeAddr) {
	opened := n.DBConn.OpenConnectionIfNeeded("GetHeigh", n.SessionID)
	bestHeight, err := n.NodeBC.GetBestHeight()
	if opened {
		n.DBConn.CloseConnection()
	}
	if err != nil {
		return
	}
	if len(nodes) == 0 {
		nodes = n.NodeNet.Nodes
	}
	for _, node := range nodes {
		if node.CompareToAddress(n.NodeClient.NodeAddress) {
			continue
		}
		n.NodeClient.SendVersion(node, bestHeight)
	}
}
/*
Send own version to all known nodes
package nodemanager
import (
	"crypto/ecdsa"
	"errors"
	"math/rand"
	"time"
	"github.com/gelembjuk/democoin/lib/net"
	"github.com/gelembjuk/democoin/lib/nodeclient"
	"github.com/gelembjuk/democoin/lib/utils"
	"github.com/gelembjuk/democoin/lib/wallet"
	"github.com/gelembjuk/democoin/node/blockchain"
	"github.com/gelembjuk/democoin/node/consensus"
	"github.com/gelembjuk/democoin/node/structures"
	"github.com/gelembjuk/democoin/node/transactions"
)
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
}
func (n *Node) Init() {
	n.NodeNet.Init()
	n.NodeNet.Logger = n.Logger
	n.NodeBC.Logger = n.Logger
	n.NodeBC.MinterAddress = n.MinterAddress
	n.NodeBC.DBConn = n.DBConn
	n.NodeNet.SetExtraManager(NodesListStorage{n.DBConn, n.SessionID})
	n.NodeNet.SetNodes([]net.NodeAddr{}, true)
	n.InitClient()
	rand.Seed(time.Now().UTC().UnixNano())
}
func (n *Node) GetTransactionsManager() transactions.TransactionsManagerInterface {
	return transactions.NewManager(n.DBConn.DB(), n.Logger)
}
func (n *Node) GetBCManager() (*blockchain.Blockchain, error) {
	return blockchain.NewBlockchainManager(n.DBConn.DB(), n.Logger)
}
func (n *Node) GetBlockChainIterator() (*blockchain.BlockchainIterator, error) {
	return blockchain.NewBlockchainIterator(n.DBConn.DB())
}
func (n *Node) getBlockMakeManager() (consensus.ConsensusInterface, error) {
	return consensus.NewConsensusManager(n.MinterAddress, n.DBConn.DB(), n.Logger)
}
func (n *Node) getCreateManager() *makeBlockchain {
	return &makeBlockchain{n.Logger, n.MinterAddress, n.DBConn}
}
func (n *Node) InitClient() error {
	if n.NodeClient != nil {
		return nil
	}
	client := nodeclient.NodeClient{}
	client.Logger = n.Logger
	client.NodeNet = &n.NodeNet
	n.NodeClient = &client
	return nil
}
func (n *Node) InitNodes(list []net.NodeAddr, force bool) error {
	if n.DBConn.OpenConnectionIfNeeded("CheckNodesAndGenesis", n.SessionID) {
		defer n.DBConn.CloseConnection()
	}
	if len(list) == 0 && !force {
		n.NodeNet.LoadNodes()
		if n.NodeNet.GetCountOfKnownNodes() == 0 && n.BlockchainExist() {
			bcm := n.NodeBC.GetBCManager()
			genesisHash, err := bcm.GetGenesisBlockHash()
			if err == nil {
				n.NodeNet.LoadInitialNodes(genesisHash)
			}
		}
	} else {
		n.NodeNet.SetNodes(list, true)
	}
	return nil
}
func (n *Node) BlockchainExist() bool {
	exists, _ := n.DBConn.DB().CheckDBExists()
	n.DBConn.CloseConnection()
	return exists
}
func (n *Node) CreateBlockchain(address, genesisCoinbaseData string) error {
	bccreator := n.getCreateManager()
	bccreator.MinterAddress = address
	return bccreator.CreateBlockchain(genesisCoinbaseData)
}
func (n *Node) InitBlockchainFromOther(host string, port int) (bool, error) {
	if host == "" {
		n.NodeNet.LoadInitialNodes(nil)
		if len(n.NodeNet.Nodes) == 0 {
			return false, errors.New("No known nodes to request a blockchain")
		}
		nd := n.NodeNet.Nodes[rand.Intn(len(n.NodeNet.Nodes))]
		host = nd.Host
		port = nd.Port
	}
	addr := net.NodeAddr{host, port}
	complete, err := n.getCreateManager().InitBlockchainFromOther(addr, n.NodeClient, &n.NodeBC)
	if err != nil {
		return false, err
	}
	n.NodeNet.AddNodeToKnown(addr)
	return complete, nil
}
func (n *Node) SendTransactionToAll(tx *structures.Transaction) {
	n.Logger.Trace.Printf("Send transaction to %d nodes", len(n.NodeNet.Nodes))
	for _, node := range n.NodeNet.Nodes {
		if node.CompareToAddress(n.NodeClient.NodeAddress) {
			continue
		}
		n.Logger.Trace.Printf("Send TX %x to %s", tx.ID, node.NodeAddrToString())
		n.NodeClient.SendInv(node, "tx", [][]byte{tx.ID})
	}
}
func (n *Node) AddNodeToKnown(addr net.NodeAddr, sendversion bool) {
	added := n.CheckAddressKnown(addr)
	if added && sendversion {
		n.Logger.Trace.Printf("Added node %s\n", addr.NodeAddrToString())
		n.SendVersionToNodes([]net.NodeAddr{addr})
	}
}
func (n *Node) SendBlockToAll(newBlock *structures.Block, skipaddr net.NodeAddr) {
	for _, node := range n.NodeNet.Nodes {
		if node.CompareToAddress(n.NodeClient.NodeAddress) {
			continue
		}
		blockshortdata, err := newBlock.GetShortCopy().Serialize()
		if err == nil {
			n.NodeClient.SendInv(node, "block", [][]byte{blockshortdata})
		}
	}
}