Coder Social home page Coder Social logo

goar's People

Contributors

johnbailon avatar kevin-zhangzh avatar max-levitskiy avatar omahs avatar outprog avatar saklani avatar wujunze avatar xiaojay avatar zyjblockchain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

goar's Issues

Suddenly getting "get block hash list failed" errors

I am using goar as well as arsyncer. Arsyncer has always worked just fine both locally and in my hosted environment, and goar has been working fine locally just fine as well.
Starting sometime in the past few days I'm suddenly getting an error:
pNode.GetBlockHashList() module=syncer err="get block hash list failed"
I'm getting this when running Arsyncer, or Goar, and both locally and in cloud. I created fresh new Ubuntu 22.04 instances to test it on also and tried that with versions of go 1.15 through 1.20.

I'm opening this ticket to find out if this is somehow just isolated to my code or if something has changed with the way blocks are pulled from peers.

Support context.Context

I wish I could use this library but because it does not support go's context.Context I can't reliably use it. This library obviously performs operations over a network and it is common practice to use a context so that network operations can be cancelled by the context, either by manual cancellation or deadline. The go http package supports contexts with functions like http.NewRequestWithContext.

Even if I use contexts and goroutines to disregard the response of a *goar.Client when a context times out for example, there is no way to stop the execution of a function. If I were to be downloading content from arweave, it would continue downloading despite the context cancelling, and the program continuing running.

The only workaround I can see is manually setting a timeout on the http client, but this is bad practice and not predictable.

create arweave wallet account using go lang.

Is it possible to create arweave wallet account ?. Below is the scenario.

User can provide seed phrase if exists or create a new seed phrase to create new arweave wallet account.

License

Dear author,
Thank you for this great work! I'm wondering if you could indicate the license under which the code in this repository is distributed. This will greatly improve the possibilities of using your work. Thanks a lot!

请问有个btcsuite的问题,麻烦帮忙看下怎么处理

go get 的时候提示找不到 base58 这个包,请问如何处理?

$ go get github.com/everFinance/goar
github.com/everFinance/goar imports
	github.com/everFinance/goar/utils imports
	github.com/btcsuite/btcutil/base58: cannot find module providing package github.com/btcsuite/btcutil/base58

Sending data more than one chunks fail.

sample 1), data is less than one chunk, will success

func TestWallet_SendDataSpeedUp01(t *testing.T) {
// arNode := "https://arweave.net"
// w, err := NewWalletFromPath("./example/testKey.json", arNode) // your wallet private key
// assert.NoError(t, err)

//data := []byte("aaa this is a goar test small size file data") // small file
data := make([]byte, 255*1024)
for i := 0; i < len(data); i++ {
	data[i] = byte('b' + i)
}
tags := []types.Tag{
	{Name: "GOAR", Value: "SMDT"},
}
id, err := testWallet.SendDataSpeedUp(data, tags, 50)
assert.NoError(t, err)
t.Logf("tx hash: %s", id)

}

==========================

sample 2) data size 10 chunks. return with the following error:
Unable to upload Transaction: 400, , Transaction verification failed.

func TestWallet_SendDataSpeedUp01(t *testing.T) {
// arNode := "https://arweave.net"
// w, err := NewWalletFromPath("./example/testKey.json", arNode) // your wallet private key
// assert.NoError(t, err)

//data := []byte("aaa this is a goar test small size file data") // small file
data := make([]byte, 255*1024*10)
for i := 0; i < len(data); i++ {
	data[i] = byte('b' + i)
}
tags := []types.Tag{
	{Name: "GOAR", Value: "SMDT"},
}
id, err := testWallet.SendDataSpeedUp(data, tags, 50)
assert.NoError(t, err)
t.Logf("tx hash: %s", id)

}

Bad request

Hello, trying to upload a file and I seem to be hitting this error:

$ go run main.go
Tx data size: 0.004551MB 
uplaodTx; body: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Bad Request</pre>
</body>
</html>
, status: 400, txId: -lmcTK9yzneKUOt4_xqC3vxEH50DhhaWzYBTDDOFpCM 
0.000000% completes, 0/1 
2021/10/14 17:33:22 -lmcTK9yzneKUOt4_xqC3vxEH50DhhaWzYBTDDOFpCM

Code:

package main

import (
	"fmt"
	"io/ioutil"
	"log"

	"github.com/everFinance/goar"
	"github.com/everFinance/goar/types"
	"github.com/everFinance/goar/utils"
)

const ARWEAVE_NODE = "https://arweave.net"

func main () {
	data, err := ioutil.ReadFile("./test.png")
	if err != nil {
		panic(err)
	}
	tx, err := UploadToArweave("./arweave-key.json",data)
	if err != nil {
		panic(err)
	}
	log.Println(tx)
}

func UploadToArweave(walletPath string, data []byte) (string, error) {
	// Load wallet
	w, err := goar.NewWalletFromPath(walletPath, ARWEAVE_NODE)
	if err != nil {
		return "", err
	}
	log.Println(w.Address)

	// Get anchor
	anchor, err := w.Client.GetTransactionAnchor()
	if err != nil {
		return "", err
	}
	// Get reward
	reward, err := w.Client.GetTransactionPrice(data, nil)
	if err != nil {
		return "", err
	}

	// Craft tx
	speedFactor := int64(50)
	tx := &types.Transaction{
		Format:   2,
		Target:   "",
		Quantity: "0",
		Tags: utils.TagsEncode([]types.Tag{
			types.Tag{
				Name:  "Content-Type",
				Value: "image/png",
			},
		}),
		Data:     utils.Base64Encode(data),
		DataSize: fmt.Sprintf("%d", len(data)),
		Reward:   fmt.Sprintf("%d", reward*(100+speedFactor)/100),
		LastTx:   anchor,
	}
	if err = utils.SignTransaction(tx, w.PrvKey); err != nil {
		return "", err
	}

	// Upload
	uploader, err := goar.CreateUploader(w.Client, tx, nil)
	if err != nil {
		return "", err
	}
	err = uploader.Once()
	if err != nil {
		return "", err
	}

	return tx.ID, nil
}

What could be wrong here?

Can goar support uploading file with streaming style?

Current API only support uploading bytes([]byte). It is obviously not good for upload big files(e.g., video files) at same time.
Shall we consider arweave API like S3?
PutObject(reader io.Reader, objectSize int64, opt PubObjectOption) (PutObjectResult, err error)

Thanks a lot

send to bundler request failed; http code: 402

Hello, I am trying to use the bundler to upload files but every time I attempt to submit a bundle I receive this error:

send to bundler request failed; http code: 402

this is my flow for finalizing:

	_, err := bm.Wallet.Client.BatchSendItemToBundler(bm.BundleItems)
	if err != nil {
		return err
	}

	bd, err := utils.NewBundle(bm.BundleItems...)
	if err != nil {
		return err
	}

	_, err = bm.Wallet.SendBundleTx(bd.BundleBinary, nil)
	if err != nil {
		return err
	}

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.