func appendable(datfile string, n *node.Node) bool { l := listLen(datfile) return ((datfile != "" && l < shareNodes) || (datfile == "" && l < defaultNodes)) && n != nil && n.IsAllowed() && !hasNodeInTable(datfile, n) }
//ReplaceNodeInList removes one node and say bye to the node and add n in nodelist. //if len(node)>defaultnode func ReplaceNodeInList(n *node.Node) *node.Node { l := ListLen() if !n.IsAllowed() || hasNodeInTable(list, n) { return nil } var old *node.Node if l >= defaultNodes { old = getFromList() RemoveFromList(old) old.Bye() } err := db.DB.Update(func(tx *bolt.Tx) error { appendToList(tx, n) return nil }) if err != nil { log.Println(err) } return old }