func (db *DB) addAddressToDB(info *addressInfo) {
	// Get the head of the binaryTree
	var head = db.addressTreeHead
	var descendent *node
	//Get the address so we know the path in the binaryTree
	var bitAddress = byteToBit(info.address)

	for i := 0; i < len(bitAddress); i++ {
		if bitAddress[i] {
			descendent = head.rightChild()
			//Create the right child if it doesn't exist
			if descendent == nil {
				head = head.createRightChild()
			} else {
				head = descendent
			}
		} else {
			descendent = head.leftChild()
			//Create the left child if it doesn't exist
			if descendent == nil {
				head = head.createLeftChild()
			} else {
				head = descendent
			}
		}
	}

	//Save the address info into the tree node that represents the address
	head.saveData(info)

	//NodePubKey is a key to the map where we store pointers to the head where we previously stored the info
	db.keyToAddressMap[info.nodePubKey] = head

	log.Println("Address " + net.IP(info.address[:]).String() + " loaded to DB")
}
//loads the address into memory
loads the address into memory
// loads the address into memory
func (db *DB) addAddressToDB(info *addressInfo) {
	var head = db.addressTreeHead
	var descendent *node
	var bitAddress = byteToBit(info.address)
	for i := 0; i < len(bitAddress); i++ {
		if bitAddress[i] {
			descendent = head.rightChild()
			if descendent == nil {
				head = head.createRightChild()
			} else {
				head = descendent
			}
		} else {
			descendent = head.leftChild()
			if descendent == nil {
				head = head.createLeftChild()
			} else {
				head = descendent
			}
		}
	}
	head.saveData(info)
	db.keyToAddressMap[info.nodePubKey] = head
	log.Println("Address " + net.IP(info.address[:]).String() + " loaded to DB")
}
func ( db * DB ) addAddressToDB ( info * addressInfo ) { var head = db . addressTreeHead var descendent * node var bitAddress = byteToBit ( info . address ) for i := 0 ; i < len ( bitAddress ) ; i ++ { if bitAddress [ i ] { descendent = head . rightChild ( ) if descendent == nil { head = head . createRightChild ( ) } else { head = descendent } } else { descendent = head . leftChild ( ) if descendent == nil { head = head . createLeftChild ( ) } else { head = descendent } } } head . saveData ( info ) db . keyToAddressMap [ info . nodePubKey ] = head log . Println ( " " + net . IP ( info . address [ : ] ) . String ( ) + " " ) }
loads the address into memory
loads the address into memory
// Get the head of the binaryTree //Get the address so we know the path in the binaryTree //Create the right child if it doesn't exist //Create the left child if it doesn't exist //Save the address info into the tree node that represents the address //NodePubKey is a key to the map where we store pointers to the head where we previously stored the info