func toDirBlockInfosList(source []interfaces.BinaryMarshallableAndCopyable) []interfaces.IDirBlockInfo { answer := make([]interfaces.IDirBlockInfo, len(source)) for i, v := range source { answer[i] = v.(interfaces.IDirBlockInfo) } sort.Sort(util.ByDirBlockInfoIDAccending(answer)) return answer }
// FetchAllDirBlockInfos gets all of the dirblock info blocks func (db *Overlay) FetchAllDirBlockInfos() ([]interfaces.IDirBlockInfo, error) { unconfirmed, err := db.FetchAllUnconfirmedDirBlockInfos() if err != nil { return nil, err } confirmed, err := db.FetchAllConfirmedDirBlockInfos() if err != nil { return nil, err } all := append(unconfirmed, confirmed...) sort.Sort(util.ByDirBlockInfoIDAccending(all)) return all, nil }
func ExportDirBlockInfo(db interfaces.DBOverlay) error { fmt.Printf("ExportDirBlockInfo\n") // get all aBlocks from db dbi, err := db.FetchAllDirBlockInfos() if err != nil { return err } fmt.Printf("Fetched %v blocks\n", len(dbi)) sort.Sort(util.ByDirBlockInfoIDAccending(dbi)) for _, block := range dbi { err = ExportBlock(block) if err != nil { return err } } return nil }