forked from kaspanet/kaspad
-
Notifications
You must be signed in to change notification settings - Fork 8
/
subnetworkid.go
33 lines (25 loc) · 943 Bytes
/
subnetworkid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 {
return hex.EncodeToString(id[:])
}
// Clone returns a clone of DomainSubnetworkID
func (id *DomainSubnetworkID) Clone() *DomainSubnetworkID {
idClone := *id
return &idClone
}
// If this doesn't compile, it means the type definition has been changed, so it's
// an indication to update Equal and Clone accordingly.
var _ DomainSubnetworkID = [DomainSubnetworkIDSize]byte{}
// Equal returns whether id equals to other
func (id *DomainSubnetworkID) Equal(other *DomainSubnetworkID) bool {
if id == nil || other == nil {
return id == other
}
return *id == *other
}