mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
550 B
31 lines
550 B
10 years ago
|
package downloader
|
||
|
|
||
|
import (
|
||
|
"github.com/ethereum/go-ethereum/common"
|
||
|
"github.com/ethereum/go-ethereum/core/types"
|
||
|
"gopkg.in/fatih/set.v0"
|
||
|
)
|
||
|
|
||
|
func createHashSet(hashes []common.Hash) *set.Set {
|
||
|
hset := set.New()
|
||
|
|
||
|
for _, hash := range hashes {
|
||
|
hset.Add(hash)
|
||
|
}
|
||
|
|
||
|
return hset
|
||
|
}
|
||
|
|
||
|
func createBlocksFromHashSet(hashes *set.Set) []*types.Block {
|
||
|
blocks := make([]*types.Block, hashes.Size())
|
||
|
|
||
|
var i int
|
||
|
hashes.Each(func(v interface{}) bool {
|
||
|
blocks[i] = createBlock(i, common.Hash{}, v.(common.Hash))
|
||
|
i++
|
||
|
return true
|
||
|
})
|
||
|
|
||
|
return blocks
|
||
|
}
|