-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix subnetworks FromString and disable reversal (#1557)
* Remove DomainSubnetworkID reversal * Fix DomaiNSubnetworkID FromString implementation * Change RPC conversation logic to use Stringer/FromString Co-authored-by: Ori Newman <orinewman1@gmail.com>
- Loading branch information
1 parent
6597f24
commit 24a12cf
Showing
4 changed files
with
7 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
package subnetworks | ||
|
||
import ( | ||
"bytes" | ||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi" | ||
) | ||
|
||
func cmp(a, b externalapi.DomainSubnetworkID) int { | ||
// We compare the hashes backwards because Hash is stored as a little endian byte array. | ||
for i := externalapi.DomainSubnetworkIDSize - 1; i >= 0; i-- { | ||
switch { | ||
case a[i] < b[i]: | ||
return -1 | ||
case a[i] > b[i]: | ||
return 1 | ||
} | ||
} | ||
return 0 | ||
} | ||
|
||
// Less returns true iff id a is less than id b | ||
func Less(a, b externalapi.DomainSubnetworkID) bool { | ||
return cmp(a, b) < 0 | ||
return bytes.Compare(a[:], b[:]) < 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters