Skip to content
Snippets Groups Projects
Commit fcc949a5 authored by capossele's avatar capossele
Browse files

:bug: fixes unmarshaling of tx hash

parent 39a918a8
No related branches found
No related tags found
No related merge requests found
package gossip package gossip
import ( import (
"errors"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
zL "github.com/iotaledger/autopeering-sim/logger" zL "github.com/iotaledger/autopeering-sim/logger"
"github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/peer/service"
...@@ -44,9 +46,10 @@ var ( ...@@ -44,9 +46,10 @@ var (
) )
func getTransaction(h []byte) ([]byte, error) { func getTransaction(h []byte) ([]byte, error) {
log.Info("Retrieving tx:", string(h))
tx, err := tangle.GetTransaction(string(h)) tx, err := tangle.GetTransaction(string(h))
if err != nil { if err != nil || tx == nil {
return []byte{}, err return []byte{}, errors.New("Not found")
} }
pTx := &pb.TransactionRequest{ pTx := &pb.TransactionRequest{
Hash: tx.GetBytes(), Hash: tx.GetBytes(),
...@@ -92,7 +95,7 @@ func configureEvents() { ...@@ -92,7 +95,7 @@ func configureEvents() {
})) }))
tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) {
log.Info("Tx solidified:", tx.MetaTransaction.GetBytes()) log.Info("Tx solidified:", tx.MetaTransaction.GetHash())
t := &pb.Transaction{ t := &pb.Transaction{
Body: tx.MetaTransaction.GetBytes(), Body: tx.MetaTransaction.GetBytes(),
} }
...@@ -104,7 +107,9 @@ func configureEvents() { ...@@ -104,7 +107,9 @@ func configureEvents() {
})) }))
gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) {
log.Info("Tx Requested:", ev.Hash) pTx := &pb.TransactionRequest{}
go mgr.RequestTransaction(ev.Hash) proto.Unmarshal(ev.Hash, pTx)
log.Info("Tx Requested:", string(pTx.Hash))
go mgr.RequestTransaction(pTx.Hash)
})) }))
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment