Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
pred695 committed Apr 20, 2024
1 parent 3ecf3c1 commit a79575c
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions Blockchain/mine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package Blockchain

import (
"encoding/hex"
"encoding/json"
"fmt"
"os"
"time"
Expand All @@ -20,31 +19,13 @@ var Bh Structs.BlockHeader = Structs.BlockHeader{
Nonce: 0,
}

func GetAllTxid() []string {
var permittedTxIDs []string
dir := "./mempool"
files, _ := os.ReadDir(dir)
for _, file := range files {
txData, err := Utils.JsonData(dir + "/" + file.Name())
Utils.Handle(err)
var tx Structs.Transaction
err = json.Unmarshal([]byte(txData), &tx)
serialized, _ := Utils.SerializeTransaction(&tx)
txID := Utils.ReverseBytes(Utils.To_sha(Utils.To_sha(serialized)))
permittedTxIDs = append(permittedTxIDs, hex.EncodeToString(txID))
}
return permittedTxIDs

}
func MineBlock() {
netReward, TxIDs, _ := Utils.Prioritize()

cbTx := Utils.CreateCoinbase(netReward)
serializedcbTx, _ := Utils.SerializeTransaction(cbTx)
fmt.Printf("CBTX: %x\n", serializedcbTx)
txidsnew := GetAllTxid()
fmt.Println("Length of txids: ", len(txidsnew))
TxIDs = append([]string{hex.EncodeToString(Utils.ReverseBytes(Utils.To_sha(Utils.To_sha(serializedcbTx))))}, GetAllTxid()...)
TxIDs = append([]string{hex.EncodeToString(Utils.ReverseBytes(Utils.To_sha(Utils.To_sha(serializedcbTx))))}, TxIDs...)
mkr := Utils.NewMerkleTree(TxIDs)
Bh.MerkleRoot = hex.EncodeToString(mkr.Data)
cbtxbase := Utils.CalculateBaseSize(cbTx)
Expand Down

0 comments on commit a79575c

Please sign in to comment.