func (db *DB) addRoutingEntryToDB(entry *routingEntry) {

	// Get the head of the binaryTree
	var head = db.addressTreeHead
	//Get the address so we know the path in the binaryTree
	var bitAddress = byteToBit(entry.destination)

	for i := 0; i < len(bitAddress); i++ {
		if bitAddress[i] {
			head = head.rightChild()
		} else {
			head = head.leftChild()
		}
	}

	addressInfo := (head.getData().(*addressInfo))
	currentEntry := addressInfo.routingEntry
	//If there's already a routing entry for this destination we need to delete it from the stack
	if currentEntry != nil {
		//Delete routing entry from stack
		db.routingEntriesStack.remove(currentEntry)
	}

	//Add entry to the tree
	addressInfo.routingEntry = entry

	//Add the entry to the stack
	db.routingEntriesStack.put(entry)

	log.Println("Added routing entry to DB:", entry)
}
//loads a routing entry into the DB, replacing the existing one, if it exists
loads a routing entry into the DB, replacing the existing one, if it exists
// loads a routing entry into the DB replacing the existing one if it exists
func (db *DB) addRoutingEntryToDB(entry *routingEntry) {
	var head = db.addressTreeHead
	var bitAddress = byteToBit(entry.destination)
	for i := 0; i < len(bitAddress); i++ {
		if bitAddress[i] {
			head = head.rightChild()
		} else {
			head = head.leftChild()
		}
	}
	addressInfo := (head.getData().(*addressInfo))
	currentEntry := addressInfo.routingEntry
	if currentEntry != nil {
		db.routingEntriesStack.remove(currentEntry)
	}
	addressInfo.routingEntry = entry
	db.routingEntriesStack.put(entry)
	log.Println("Added routing entry to DB:", entry)
}
func ( db * DB ) addRoutingEntryToDB ( entry * routingEntry ) { var head = db . addressTreeHead var bitAddress = byteToBit ( entry . destination ) for i := 0 ; i < len ( bitAddress ) ; i ++ { if bitAddress [ i ] { head = head . rightChild ( ) } else { head = head . leftChild ( ) } } addressInfo := ( head . getData ( ) . ( * addressInfo ) ) currentEntry := addressInfo . routingEntry if currentEntry != nil { db . routingEntriesStack . remove ( currentEntry ) } addressInfo . routingEntry = entry db . routingEntriesStack . put ( entry ) log . Println ( " " , entry ) }
loads a routing entry into the DB, replacing the existing one, if it exists
loads a routing entry into the DB replacing the existing one if it exists
// Get the head of the binaryTree //Get the address so we know the path in the binaryTree //If there's already a routing entry for this destination we need to delete it from the stack //Delete routing entry from stack //Add entry to the tree //Add the entry to the stack