mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-24 15:56:42 +00:00

* [NOD-1567] Add clone methods to data stores types * [NOD-1567] Fix comments * [NOD-1567] Fix test
28 lines
714 B
Go
28 lines
714 B
Go
package externalapi
|
|
|
|
import "encoding/hex"
|
|
|
|
// DomainSubnetworkIDSize is the size of the array used to store subnetwork IDs.
|
|
const DomainSubnetworkIDSize = 20
|
|
|
|
// DomainSubnetworkID is the domain representation of a Subnetwork ID
|
|
type DomainSubnetworkID [DomainSubnetworkIDSize]byte
|
|
|
|
// String stringifies a subnetwork ID.
|
|
func (id DomainSubnetworkID) String() string {
|
|
for i := 0; i < DomainSubnetworkIDSize/2; i++ {
|
|
id[i], id[DomainSubnetworkIDSize-1-i] = id[DomainSubnetworkIDSize-1-i], id[i]
|
|
}
|
|
return hex.EncodeToString(id[:])
|
|
}
|
|
|
|
// Clone returns a clone of DomainSubnetworkID
|
|
func (id *DomainSubnetworkID) Clone() *DomainSubnetworkID {
|
|
if id == nil {
|
|
return nil
|
|
}
|
|
|
|
idClone := *id
|
|
return &idClone
|
|
}
|