Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.

Commit 1bac358

Browse files
authored
Merge pull request #9 from Dev43/develop
Update dependencies, remove chunker/batcher
2 parents 1ea69c7 + 4b07531 commit 1bac358

File tree

10 files changed

+7
-620
lines changed

10 files changed

+7
-620
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
language: go
22

3-
go: "1.12"
3+
go: "1.14"

README.md

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -104,86 +104,6 @@ To create a new transaction, you will need to interact with the `transactor` pac
104104
fmt.Println(finalTx.Hash())
105105
```
106106

107-
### Batching, chunking and recombining
108-
109-
Arweave currently has a 3MB transaction limit. To let you be able to upload more than 3MB of data, this library lets you chunk your data into multiples chunks, and upload these chunks to the weave. These chunks are all backlinked to their previous chunk (except the first one) so all you need to use to retrieve all the chunks is the last chunk's address (the "tip" of this linked list).
110-
111-
So far the library has been tested with Tarred and Gzipped files (it's a good idea to compress your files, you'll be paying less fees to the network!)
112-
113-
#### Creating chunks
114-
115-
To create chunks, use the `chunker` package. Currently the chunker takes 500KB chunks, encodes it to the same encoding as the Arweave (Raw Base64 URL encoding) and adds it to a transaction.
116-
117-
```golang
118-
f, err := os.Open("example.tar.gz")
119-
if err != nil {
120-
//...
121-
}
122-
info, err := f.Stat()
123-
if err != nil {
124-
//...
125-
}
126-
chunker, err := chunker.NewChunker(f, info.Size())
127-
if err != nil {
128-
//...
129-
}
130-
chunks, err := chunker.ChunkAll()
131-
if err != nil {
132-
//...
133-
}
134-
```
135-
136-
#### Sending a batch of transactions
137-
138-
To directly do both the chunking and the batch sending of transaction, you can use the `batchchunker` package. The package needs to wait for a single transaction to be mined before sending a new one. This will take a significant amount of time as the Arweave has a ~2 minute block time.
139-
140-
```golang
141-
f, err := os.Open("example.tar.gz")
142-
if err != nil {
143-
//...
144-
}
145-
info, err := f.Stat()
146-
if err != nil {
147-
//...
148-
}
149-
150-
// creates a new batch
151-
newB := batchchunker.NewBatch(ar, w, f, info.Size())
152-
153-
// sends all the transactions
154-
list, err := newB.SendBatchTransaction()
155-
if err != nil {
156-
//...
157-
}
158-
```
159-
160-
#### Recombining
161-
162-
Recombining all the chunks needs to be done from the tip of the batch chain (the last transaction sent). The function will grab all the chunks and recombine it into an io.Writer.
163-
164-
```golang
165-
// in this example, we will save the data as a file
166-
f, err := os.Create("example.tar.gz")
167-
if err != nil {
168-
//...
169-
}
170-
// create a new combiner
171-
newBCombiner := combiner.NewBatchCombiner(ar.Client)
172-
173-
// grab all the chunks starting from chunk at this address
174-
liveChunks, err := newBCombiner.GetAllChunks("fBwTnPGNSAtHTNr6pGvqiYpLmBvTjjJOu3kBxuuit1c")
175-
if err != nil {
176-
//...
177-
}
178-
// recombine all the chunks into our file
179-
err = combiner.Recombine(liveChunks, f)
180-
if err != nil {
181-
//...
182-
}
183-
```
184-
185-
If you actually run the last example, it will retrieve a folder with the Bitcoin, Ethereum and Arweave whitepaper
186-
187107

188108
If you enjoy the library, please consider donating:
189109

batchchunker/batchchunker.go

Lines changed: 0 additions & 102 deletions
This file was deleted.

chunker/chunker.go

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)