Apply suggestions from code review
avoid regex in partial txid ordering conversion Co-authored-by: Jonathan Underwood <jonathan.underwood4649@gmail.com>
This commit is contained in:
parent
23d487b904
commit
d16d961cb2
@ -56,5 +56,11 @@ function mempoolFromArrayBuffer(buf: ArrayBuffer): ThreadTransaction[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function txidToOrdering(txid: string): number {
|
function txidToOrdering(txid: string): number {
|
||||||
return parseInt(txid.slice(56).match(/../g)?.reverse().join('') as string, 16);
|
return (
|
||||||
|
((parseInt(txid.substring(62, 64), 16) << 24) |
|
||||||
|
(parseInt(txid.substring(60, 62), 16) << 16) |
|
||||||
|
(parseInt(txid.substring(58, 60), 16) << 8) |
|
||||||
|
parseInt(txid.substring(56, 58), 16)) >>>
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,13 @@ class TransactionUtils {
|
|||||||
|
|
||||||
// returns the most significant 4 bytes of the txid as an integer
|
// returns the most significant 4 bytes of the txid as an integer
|
||||||
public txidToOrdering(txid: string): number {
|
public txidToOrdering(txid: string): number {
|
||||||
return parseInt(txid.slice(56).match(/../g)?.reverse().join('') as string, 16);
|
return (
|
||||||
|
((parseInt(txid.substring(62, 64), 16) << 24) |
|
||||||
|
(parseInt(txid.substring(60, 62), 16) << 16) |
|
||||||
|
(parseInt(txid.substring(58, 60), 16) << 8) |
|
||||||
|
parseInt(txid.substring(56, 58), 16)) >>>
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user