aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/queue_test.go
blob: ee6141f7177464f97de882d972a8c3f46f4ee526 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
}