stasatdaglabs 126e2e49bb
[NOD-1493] Implement serialization/deserialization inside BlockHeaderStore (#979)
* [NOD-1492] Rename dbmanager to database.

* [NOD-1492] Write messages.proto for DbBlock and DbTransaction.

* [NOD-1492] Implement serializeHeader.

* [NOD-1492] Implement deserializeHeader.
2020-10-29 11:15:14 +02:00

18 lines
513 B
Go

package hashes
import (
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/pkg/errors"
)
// FromBytes creates a DomainHash from the given byte slice
func FromBytes(hashBytes []byte) (*externalapi.DomainHash, error) {
if len(hashBytes) != externalapi.DomainHashSize {
return nil, errors.Errorf("invalid hash size. Want: %d, got: %d",
externalapi.DomainHashSize, len(hashBytes))
}
var domainHash externalapi.DomainHash
copy(domainHash[:], hashBytes)
return &domainHash, nil
}