Skip to content

Commit

Permalink
fix: added cbtx weight consideration
Browse files Browse the repository at this point in the history
  • Loading branch information
pred695 committed Apr 14, 2024
1 parent 50637dc commit 46143fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Prioritize.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"encoding/hex"
"encoding/json"
"fmt"
"os"
"sort"
)
Expand Down Expand Up @@ -46,7 +47,7 @@ func Prioritize() (uint64, []string, []string) {
return comp(txInfo[i], txInfo[j])
})
var PermissibleTxs []TxInfo
var PermissibleWeight uint64 = 4000000
var PermissibleWeight uint64 = 3999000
var reward uint64 = 0
for _, tx := range txInfo {
if PermissibleWeight >= tx.Weight {
Expand All @@ -57,5 +58,6 @@ func Prioritize() (uint64, []string, []string) {
reward += tx.Fee
}
}
fmt.Println("weight: ", PermissibleWeight)
return reward, permittedTxIDs, permittedWTxIDs
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func main() {
TxIDs = append([]string{hex.EncodeToString(reverseBytes(to_sha(to_sha(serializedcbTx))))}, TxIDs...)
mkr := NewMerkleTree(TxIDs)
Bh.merkleRoot = hex.EncodeToString(mkr.Data)
cbtxbase := CalculateBaseSize(cbTx)
cbtxwitness := calculateWitnessSize(cbTx)
fmt.Println("Cbtx wt: ", cbtxwitness+(cbtxbase*4))
// witnessMerkle := NewMerkleTree(wTxIDs)
// fmt.Println("Length of the witness merkles: ", len(wTxIDs))
// fmt.Println("WMKR: ", hex.EncodeToString(witnessMerkle.Data))
Expand Down
7 changes: 3 additions & 4 deletions output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
0700000000000000000000000000000000000000000000000000000000000000000000001469c49fc3a805b159391bfc2921584aa21f67e9f545d1110bff17d3313b83f5ee341c66ffff001f0ba90000
010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff02895d8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed392466efe913d353921707d69a39cfb22952a7d75de836728f73705b3c5db5e40120000000000000000000000000000000000000000000000000000000000000000000000000
76bdb34d637ae63ec4ee9dc11c8e242c1ce89cef399dedbfc902e325c44e9e86
0700000000000000000000000000000000000000000000000000000000000000000000003b0fcbaebce598b0ae1386125194000258b2bb5c5b42d9b71d9188a2eec82af815371c66ffff001ffb980100
010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff028d4e8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed790ff774f062f6a1cccb3e5b2fc2f220f44125d0aa32d9a26a189c6f8a7de5650120000000000000000000000000000000000000000000000000000000000000000000000000
adc0f72f6d178bd42617e755d82703327082df7ba56d522c069e51b599441600
82f9f96db7bdbb9e70626747632e373b34eefd50d613dfea7092744169591b6e
7cb2a4f55245bae141a5d6ad51c08d7a9fdf2c2b905e4d97639ed80b82e69800
a9e537569db3c64340ed5abcdd983e9bb1b6ad6f90c93bc80d31c5cc0490bcea
Expand Down Expand Up @@ -3352,5 +3352,4 @@ ec4b87ca63cec112765a1fe9236581ac5567c16be9e6c0cedcdb08283a8033ac
dbb3b10ca1a6d0653bc1a9800de240020d6ac9d89fbebd77d6eb530401c8e5e8
f76c2690fe2a61749face27bf143e74a4d334fd201a91c579e96c6388354b544
faceb9ac544738ce1d3d7869e15ff79b4dc642bc9691ee785c0c629988a44d6a
4515dc4ad0d852d41d437a4706f700ee87c7654f505ec107e05daf832633cbb5
f532292494c68cfcba35f14e271a072dd074c0d6fb65806ea129780f7abfe7f4

0 comments on commit 46143fd

Please sign in to comment.