mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-23 23:36:56 +00:00

* [NOD-1492] Rename dbmanager to database. * [NOD-1492] Write messages.proto for DbBlock and DbTransaction. * [NOD-1492] Implement serializeHeader. * [NOD-1492] Implement deserializeHeader.
18 lines
513 B
Go
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
|
|
}
|