Git Product home page Git Product logo

Comments (11)

yihau avatar yihau commented on July 19, 2024

I don't get it. could you explain it more?

the context is used for making http request.
https://github.com/portto/solana-go-sdk/blob/main/rpc/client.go#L63

your sending tokens behavior will be packed in a tx and then you send it.

from solana-go-sdk.

scottywm avatar scottywm commented on July 19, 2024

An empty context is used when sending the tokens in this line of code

txhash, err := c.SendTransaction(context.Background(), tx)

I'm asking if I could give the context a timeout like so.

ctx, cancel := context.WithTimeout(context.Background(), 5)

And then insert this context into the transaction like so

txhash, err := c.SendTransaction(ctx, tx)

Would this work?

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

It will be a very very short time if you only give 5 here. iirc WithTimeout default is nano second
maybe try to use some thing like

context.WithTimeout(context.Background(), 1*time.Second)

from solana-go-sdk.

scottywm avatar scottywm commented on July 19, 2024

Ok so if I do it like this will it terminate the transaction after 5 seconds?

context.WithTimeout(context.Background(), 5*time.Second)

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

to be more precisely, the transaction will fail by

  1. the sending process over 5 secs
    or
  2. your transaction don't pass the preflight check

from solana-go-sdk.

scottywm avatar scottywm commented on July 19, 2024

So how can I put a timeout on this transaction so the transaction will fail after say 3, 4 or even 5 seconds?

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

Your transaction will execute by validators after you send it. You can only wait for the result.
This thing I don't think can fulfill in SDK level, even program level.

from solana-go-sdk.

scottywm avatar scottywm commented on July 19, 2024

Ok.
So then how can I put a timeout on this transaction?

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

As I said, the timeout is only for http request and I don't think you can put a timeout for a transaction in SDK level even program level.

from solana-go-sdk.

scottywm avatar scottywm commented on July 19, 2024

So if the solana Blockchain goes down while a transaction is being processed, what happens?

from solana-go-sdk.

yihau avatar yihau commented on July 19, 2024

It may succeed or not. There are too many factors need to be considered in your question. If you have more questions about Solana, you can join Solana's Discord.

I'm going to close this issue.
Feel free to open another issue for questions related to this SDK.

from solana-go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.