Skip to content

40 post transaction #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jul 29, 2019
Merged

40 post transaction #96

merged 30 commits into from
Jul 29, 2019

Conversation

andy-shi88
Copy link
Contributor

Description

Open post-transaction rpc endpoint.

Breakdown

  • Update schema
  • Open post-transaction endpoint
  • Update VET handling for account-balance
  • close unclosed db usages
  • add cmd for generating tx bytes
  • add client for posting transaction

Reference Issue

Close #40

Step to Test (optional)

  • go run main.go
  • go run api/client/PostTransaction/client.go
  • expected: after block created, should account-balance should be versioned updated.

@andy-shi88 andy-shi88 added the FEATURE New feature or request label Jul 26, 2019
@andy-shi88 andy-shi88 self-assigned this Jul 26, 2019
api/api.go Outdated
@@ -4,6 +4,12 @@ import (
"fmt"
"net"

"github.com/zoobc/zoobc-core/common/chaintype"
service2 "github.com/zoobc/zoobc-core/core/service"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what the service2 ?

cmd/main.go Outdated
@@ -3,12 +3,15 @@ package main
import (
"github.com/spf13/cobra"
"github.com/zoobc/zoobc-core/cmd/account"
"github.com/zoobc/zoobc-core/cmd/transaction"
"github.com/zoobc/zoobc-core/common/crypto"
"github.com/zoobc/zoobc-core/common/util"
)

func main() {
var rootCmd = &cobra.Command{Use: "zoobc"}
logger, _ := util.InitLogger(".log/", "debug.log")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to save log file with the specific name, like cmd.log or cmd.debug.log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -28,6 +28,7 @@ func (m *Migration) Init() error {
if m.Query != nil {
rows, _ := m.Query.ExecuteSelect("SELECT version FROM migration;")
if rows != nil {
defer rows.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure defer will be trigger even if rows is nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested, it won't it will only defer when row != nil proofed by no panick, since if it's nil, calling row.Close() would result in panic.

var (
recipientAccount model.Account
senderAccount model.Account
err error
)

if tx.Height > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if tx.Validate() got error need to UndoApplyUnconfirmed() or not ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check on this one, since mempool is executing validate function on get transaction, I'm not sure if I should keep validation inside ApplyConfirmed or the other way, let me think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right, if validate fail, should not do undo. Updated in newest commit.

@andy-shi88
Copy link
Contributor Author

updated, please check 👍 @capt4ce @astaphobia

@andy-shi88
Copy link
Contributor Author

wip, need to check the validate function

@andy-shi88 andy-shi88 added the WIP label Jul 26, 2019
@andy-shi88 andy-shi88 removed the WIP label Jul 29, 2019
c := rpc_service.NewTransactionServiceClient(conn)

response, err := c.PostTransaction(context.Background(), &rpc_model.PostTransactionRequest{
// TransactionBytes: []byte{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still of any useful? otherwise I think we should remove it, what do you think?

@sukrawidhyawan sukrawidhyawan merged commit 2cd619f into zoobc:develop Jul 29, 2019
@andy-shi88 andy-shi88 removed their assignment Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FEATURE New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tech: Post Transaction RPC endpoint
4 participants