From 46143fd37e97d77dfaedd7db299fa815d0739f74 Mon Sep 17 00:00:00 2001 From: Zaid Date: Mon, 15 Apr 2024 01:36:13 +0530 Subject: [PATCH] fix: added cbtx weight consideration --- Prioritize.go | 4 +++- main.go | 3 +++ output.txt | 7 +++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Prioritize.go b/Prioritize.go index 9e8986d1..334cd912 100644 --- a/Prioritize.go +++ b/Prioritize.go @@ -3,6 +3,7 @@ package main import ( "encoding/hex" "encoding/json" + "fmt" "os" "sort" ) @@ -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 { @@ -57,5 +58,6 @@ func Prioritize() (uint64, []string, []string) { reward += tx.Fee } } + fmt.Println("weight: ", PermissibleWeight) return reward, permittedTxIDs, permittedWTxIDs } diff --git a/main.go b/main.go index 25f4320b..49abd5e8 100644 --- a/main.go +++ b/main.go @@ -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)) diff --git a/output.txt b/output.txt index ebb46f67..7a6e3c0a 100644 --- a/output.txt +++ b/output.txt @@ -1,6 +1,6 @@ -0700000000000000000000000000000000000000000000000000000000000000000000001469c49fc3a805b159391bfc2921584aa21f67e9f545d1110bff17d3313b83f5ee341c66ffff001f0ba90000 -010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff02895d8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed392466efe913d353921707d69a39cfb22952a7d75de836728f73705b3c5db5e40120000000000000000000000000000000000000000000000000000000000000000000000000 -76bdb34d637ae63ec4ee9dc11c8e242c1ce89cef399dedbfc902e325c44e9e86 +0700000000000000000000000000000000000000000000000000000000000000000000003b0fcbaebce598b0ae1386125194000258b2bb5c5b42d9b71d9188a2eec82af815371c66ffff001ffb980100 +010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1b03951a0604f15ccf5609013803062b9b5a0100072f425443432f20ffffffff028d4e8c0100000000160014df4bf9f3621073202be59ae590f55f42879a21a00000000000000000266a24aa21a9ed790ff774f062f6a1cccb3e5b2fc2f220f44125d0aa32d9a26a189c6f8a7de5650120000000000000000000000000000000000000000000000000000000000000000000000000 +adc0f72f6d178bd42617e755d82703327082df7ba56d522c069e51b599441600 82f9f96db7bdbb9e70626747632e373b34eefd50d613dfea7092744169591b6e 7cb2a4f55245bae141a5d6ad51c08d7a9fdf2c2b905e4d97639ed80b82e69800 a9e537569db3c64340ed5abcdd983e9bb1b6ad6f90c93bc80d31c5cc0490bcea @@ -3352,5 +3352,4 @@ ec4b87ca63cec112765a1fe9236581ac5567c16be9e6c0cedcdb08283a8033ac dbb3b10ca1a6d0653bc1a9800de240020d6ac9d89fbebd77d6eb530401c8e5e8 f76c2690fe2a61749face27bf143e74a4d334fd201a91c579e96c6388354b544 faceb9ac544738ce1d3d7869e15ff79b4dc642bc9691ee785c0c629988a44d6a -4515dc4ad0d852d41d437a4706f700ee87c7654f505ec107e05daf832633cbb5 f532292494c68cfcba35f14e271a072dd074c0d6fb65806ea129780f7abfe7f4