mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-01 19:56:45 +00:00

* Remove DomainSubnetworkID reversal * Fix DomaiNSubnetworkID FromString implementation * Change RPC conversation logic to use Stringer/FromString Co-authored-by: Ori Newman <orinewman1@gmail.com>
34 lines
943 B
Go
34 lines
943 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 {
|
|
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
|
|
}
|