示例#1
0
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
}
示例#2
0
// 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
}
示例#3
0
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
}