diff --git a/internal/coreapi/broker.go b/internal/coreapi/broker.go index 13d4356..113a040 100644 --- a/internal/coreapi/broker.go +++ b/internal/coreapi/broker.go @@ -21,6 +21,14 @@ type BrokerAPI CoreAPI var _ api.BrokerAPI = (*BrokerAPI)(nil) func (b *BrokerAPI) HandleTransaction(tx *pb.Transaction) error { + if tx.TransactionHash == nil { + if tx.Hash() != nil { + tx.TransactionHash = tx.Hash() + } else { + return fmt.Errorf("transaction hash is nil") + } + } + b.logger.WithFields(logrus.Fields{ "hash": tx.TransactionHash.String(), }).Debugf("Receive tx") @@ -35,6 +43,14 @@ func (b *BrokerAPI) HandleTransaction(tx *pb.Transaction) error { } func (b *BrokerAPI) HandleView(tx *pb.Transaction) (*pb.Receipt, error) { + if tx.TransactionHash == nil { + if tx.Hash() != nil { + tx.TransactionHash = tx.Hash() + } else { + return nil, fmt.Errorf("transaction hash is nil") + } + } + b.logger.WithFields(logrus.Fields{ "hash": tx.TransactionHash.String(), }).Debugf("Receive view") diff --git a/tester/case001_api_test.go b/tester/case001_api_test.go index f3c114b..385db97 100644 --- a/tester/case001_api_test.go +++ b/tester/case001_api_test.go @@ -72,6 +72,7 @@ func testSendView(suite *API) { suite.Equal(receipt.Status, pb.Receipt_SUCCESS) suite.Equal(value, string(receipt.Ret)) } + // //func (suite *API) TestDelVPNode() { // err := suite.api.Broker().DelVPNode(1)