func (db *DB) SaveRoutingDBToFile() {

	routingEntries := db.routingEntriesStack.peekFromBlock(genesisBlock)
	var serializedRoutingEntry []byte
	var entry *routingEntry
	var routingDBPath = path.Join(db.filePath, routingDBFileName)

	//Open the routing database file
	log.Println("Writing Routing DB file...")
	fp, err := os.OpenFile(routingDBPath, os.O_CREATE|os.O_WRONLY, 0755)
	if err != nil {
		log.Fatal(err)
	}
	defer fp.Close()

	for _, entry = range routingEntries {

		//Serialize routing entry
		serializedRoutingEntry = serializeRoutingEntry(entry)

		//Write serialization to the file
		n, err := fp.Write(serializedRoutingEntry)
		log.Println("Wrote", n, "bytes to routing DB file.")
		if err != nil {
			log.Fatalln("Write failed:", err)
		}
	}
}
//SaveRoutingDBToFile writes the whole routing DB file.
//To be used on client exit
SaveRoutingDBToFile writes the whole routing DB file.
To be used on client exit
// SaveRoutingDBToFile writes the whole routing DB file . // To be used on client exit
func (db *DB) SaveRoutingDBToFile() {
	routingEntries := db.routingEntriesStack.peekFromBlock(genesisBlock)
	var serializedRoutingEntry []byte
	var entry *routingEntry
	var routingDBPath = path.Join(db.filePath, routingDBFileName)
	log.Println("Writing Routing DB file...")
	fp, err := os.OpenFile(routingDBPath, os.O_CREATE|os.O_WRONLY, 0755)
	if err != nil {
		log.Fatal(err)
	}
	defer fp.Close()
	for _, entry = range routingEntries {
		serializedRoutingEntry = serializeRoutingEntry(entry)
		n, err := fp.Write(serializedRoutingEntry)
		log.Println("Wrote", n, "bytes to routing DB file.")
		if err != nil {
			log.Fatalln("Write failed:", err)
		}
	}
}
func ( db * DB ) SaveRoutingDBToFile ( ) { routingEntries := db . routingEntriesStack . peekFromBlock ( genesisBlock ) var serializedRoutingEntry [ ] byte var entry * routingEntry var routingDBPath = path . Join ( db . filePath , routingDBFileName ) log . Println ( " " ) fp , err := os . OpenFile ( routingDBPath , os . O_CREATE | os . O_WRONLY , 0755 ) if err != nil { log . Fatal ( err ) } defer fp . Close ( ) for _ , entry = range routingEntries { serializedRoutingEntry = serializeRoutingEntry ( entry ) n , err := fp . Write ( serializedRoutingEntry ) log . Println ( " " , n , " " ) if err != nil { log . Fatalln ( " " , err ) } } }
SaveRoutingDBToFile writes the whole routing DB file.
SaveRoutingDBToFile writes the whole routing DB file .
//Open the routing database file //Serialize routing entry //Write serialization to the file