mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-28 14:47:16 +00:00
27 lines
514 B
Go
27 lines
514 B
Go
|
package generate
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/anacrolix/torrent/bencode"
|
||
|
"github.com/anacrolix/torrent/metainfo"
|
||
|
"github.com/ledgerwatch/turbo-geth/turbo/torrent"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func MetaInfoHash(path string) error {
|
||
|
t := time.Now()
|
||
|
mi := metainfo.MetaInfo{}
|
||
|
info, err := torrent.BuildInfoBytesForLMDBSnapshot(path)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
mi.InfoBytes, err = bencode.Marshal(info)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
fmt.Println(mi.HashInfoBytes())
|
||
|
fmt.Println("It took", time.Since(t))
|
||
|
return nil
|
||
|
}
|