예제 #1
0
func toDBlocksList(source []interfaces.BinaryMarshallableAndCopyable) []interfaces.IDirectoryBlock {
	answer := make([]interfaces.IDirectoryBlock, len(source))
	for i, v := range source {
		answer[i] = v.(interfaces.IDirectoryBlock)
	}
	sort.Sort(util.ByDBlockIDAccending(answer))
	return answer
}
예제 #2
0
func ExportDChain(db interfaces.DBOverlay) error {
	fmt.Printf("ExportDChain\n")
	// get all ecBlocks from db
	dBlocks, err := db.FetchAllDBlocks()
	if err != nil {
		return err
	}
	sort.Sort(util.ByDBlockIDAccending(dBlocks))

	for _, block := range dBlocks {
		err = ExportBlock(block.(interfaces.DatabaseBatchable))
		if err != nil {
			return err
		}
	}
	return nil
}
예제 #3
0
func (be *BlockExtractor) ExportDChain(db interfaces.DBOverlay) error {
	fmt.Printf("ExportDChain\n")
	// get all ecBlocks from db
	dBlocks, err := db.FetchAllDBlocks()
	if err != nil {
		return err
	}
	sort.Sort(util.ByDBlockIDAccending(dBlocks))

	for _, block := range dBlocks {
		//Making sure Hash and KeyMR are set for the JSON export
		block.GetFullHash()
		block.GetKeyMR()
		err = be.ExportBlock(block.(interfaces.DatabaseBatchable))
		if err != nil {
			return err
		}
	}
	return nil
}