2018-11-26 05:52:53 +00:00
|
|
|
// Copyright 2015 The go-ethereum Authors
|
|
|
|
// This file is part of the go-ethereum library.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// Contains a batch of utility type declarations used by the tests. As the node
|
|
|
|
// operates on unique types, a lot of them are needed to check various features.
|
|
|
|
|
2018-11-26 08:37:25 +00:00
|
|
|
package ipfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
mh "gx/ipfs/QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua/go-multihash"
|
2018-12-12 17:54:51 +00:00
|
|
|
"gx/ipfs/QmR8BauakNcBa3RbE4nbQu76PDiJgoQgz8AJdhJuiU4TAw/go-cid"
|
2018-11-26 08:37:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func RawToCid(codec uint64, raw []byte) (*cid.Cid, error) {
|
|
|
|
c, err := cid.Prefix{
|
|
|
|
Codec: codec,
|
|
|
|
Version: 1,
|
|
|
|
MhType: mh.KECCAK_256,
|
|
|
|
MhLength: -1,
|
|
|
|
}.Sum(raw)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2018-11-26 05:52:53 +00:00
|
|
|
}
|
2018-12-12 17:54:51 +00:00
|
|
|
return &c, nil
|
2018-11-26 05:52:53 +00:00
|
|
|
}
|