Skip to content

Commit

Permalink
feat: upload file with muti token, and bt protocol (#269)
Browse files Browse the repository at this point in the history
* feat: muti token upload_shard

* feat: vault implementation upgrade

* feat: mod code incompent

* chore: modify test vault logic contract address

* chore: vault incopenment

* chore: vault incopenment, add muti func

* chore: mod cheque of muti

* chore: mod tokon string to common.address

* chore: test

* chore: test

* chore: debug muti token

* chore: debug cash cheque

* chore: debug price contract

* chore: add token-type for more cmd

* feat: add support tokens

* feat: add support tokens

* chore: add ChequeStatsAllCmd

* feat: mod receive_history_stats_all send-history-stats-all

* test: other token upload ok

* chore: vault logic contract address

* test: chequeRecordRet add token

* test: send_history_list + send_history_peer

* test: LastCheques of one token

* test: cheque recievelist

* test: receive_history_list receive_history_peer receive_total_count

* test: cash_list

* test: receive_list_all send_list_all

* test: cashout event

* test: muti token vault deposit

* feat: add bittorrent cmd (#265)

* feat: rm the QUIC dependence of go-libp2p-quic-transport temporarily

* feat: update golang version

* build: golang1.18 require a new format when there is a build in the first line

* feat: add bittorrent cmd

* feat[bittorrent]: add metainfo cmd

* feat[bittorrent]: add scrape and bencode cmds

* feat[bittorrent]: add download cmd

* feat: add some human-readable statistics

* feat: rm the file after download completed

* feat[bittorrent]: add bt serve cmd

* fix: getting metainfo support magnet

* ci: update go mod

* test: fix cmd test

* fix[bittorrent]: update the description of serveing

* test: balance of bttc, and transfer

* feat[bittorrent]: listen port from 30000 to 31000 (#267)

* feat: add adds pin (#268)

* feat[bittorrent]: listen port from 30000 to 31000

* fix: add adds pin

* test: unit test

* test: receive_list_all update sort

* test: mod token type

Co-authored-by: fish <920886811@163.com>
Co-authored-by: steve <stevzhang01@gmail.com>
Co-authored-by: Shawn-Huang-Tron <107823650+Shawn-Huang-Tron@users.noreply.github.com>
  • Loading branch information
4 people authored and daniel-tron committed Dec 13, 2022
1 parent 0a04db0 commit 9b8d24f
Show file tree
Hide file tree
Showing 117 changed files with 4,430 additions and 859 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ cmd/.DS_Store
cmd/btfs/s
cmd/btfs/btfs
.DS_Store

cmd/btfs/btfs.upgrade
cmd/btfs/ttt
cmd/btfs/tt
cmd/btfs/t
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16
FROM golang:1.18
MAINTAINER TRON-US <support@tron.network>

# Install deps
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.testing
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15
FROM golang:1.18
MAINTAINER TRON-US <support@tron.network>

# Install deps
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.unit_testing
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.15
FROM golang:1.18
MAINTAINER TRON-US <support@tron.network>

# Dockerfile.unit_testing will build an image to run the go unit tests.
Expand Down
11 changes: 6 additions & 5 deletions accounting/accounting.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package accounting
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum/common"
"math/big"
"sync"
"time"
Expand All @@ -20,7 +21,7 @@ import (
var log = logging.Logger("accounting")

// PayFunc is the function used for async monetary settlement
type PayFunc func(context.Context, string, *big.Int, string)
type PayFunc func(context.Context, string, *big.Int, string, common.Address)

// accountingPeer holds all in-memory accounting information for one peer.
type accountingPeer struct {
Expand Down Expand Up @@ -70,10 +71,10 @@ func (a *Accounting) Close() error {
}

// Settle to a peer. The lock on the accountingPeer must be held when called.
func (a *Accounting) Settle(toPeer string, paymentAmount *big.Int, contractId string) error {
func (a *Accounting) Settle(toPeer string, paymentAmount *big.Int, contractId string, token common.Address) error {
if paymentAmount.Cmp(a.minimumPayment) >= 0 {
a.wg.Add(1)
go a.payFunction(context.Background(), toPeer, paymentAmount, contractId)
go a.payFunction(context.Background(), toPeer, paymentAmount, contractId, token)
}

return nil
Expand All @@ -97,7 +98,7 @@ func (a *Accounting) getAccountingPeer(peer string) *accountingPeer {
}

// NotifyPaymentSent is triggered by async monetary settlement to update our balance and remove it's price from the shadow reserve
func (a *Accounting) NotifyPaymentSent(peer string, amount *big.Int, receivedError error) {
func (a *Accounting) NotifyPaymentSent(peer string, amount *big.Int, receivedError error, token common.Address) {
defer a.wg.Done()
accountingPeer := a.getAccountingPeer(peer)

Expand All @@ -114,7 +115,7 @@ func (a *Accounting) NotifyPaymentSent(peer string, amount *big.Int, receivedErr
}

// NotifyPayment is called by Settlement when we receive a payment.
func (a *Accounting) NotifyPaymentReceived(peer string, amount *big.Int) error {
func (a *Accounting) NotifyPaymentReceived(peer string, amount *big.Int, token common.Address) error {
accountingPeer := a.getAccountingPeer(peer)

accountingPeer.lock.Lock()
Expand Down
3 changes: 2 additions & 1 deletion assets/bindata_dep.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//+build never,!never
//go:build never && !never
// +build never,!never

package assets

Expand Down
Loading

0 comments on commit 9b8d24f

Please sign in to comment.