DERO-HE STARGATE Testnet Release14
This commit is contained in:
parent
884f1efb2b
commit
03c6c16f69
@ -20,4 +20,4 @@ import "github.com/blang/semver"
|
|||||||
|
|
||||||
// right now it has to be manually changed
|
// right now it has to be manually changed
|
||||||
// do we need to include git commitsha??
|
// do we need to include git commitsha??
|
||||||
var Version = semver.MustParse("3.2.13-1.DEROHE.STARGATE+27022021")
|
var Version = semver.MustParse("3.2.14-1.DEROHE.STARGATE+28022021")
|
||||||
|
@ -127,8 +127,8 @@ func Initialize() {
|
|||||||
// used to recover in case of panics
|
// used to recover in case of panics
|
||||||
func Recover() {
|
func Recover() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
rlog.Warnf("Recovered while handling connection, Stack trace below", r)
|
rlog.Warnf("Recovered, error %s", r)
|
||||||
rlog.Warnf("Stack trace \n%s", debug.Stack())
|
rlog.Warnf("Stack trace \n%s\n", debug.Stack())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package walletapi
|
|||||||
// the objective of this file is to implememt a pool which sends and retries transactions until they are accepted by the chain
|
// the objective of this file is to implememt a pool which sends and retries transactions until they are accepted by the chain
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "runtime/debug"
|
|
||||||
|
|
||||||
//import "encoding/binary"
|
//import "encoding/binary"
|
||||||
//import "encoding/hex"
|
//import "encoding/hex"
|
||||||
@ -36,7 +35,7 @@ import "github.com/deroproject/derohe/cryptography/crypto"
|
|||||||
//import "github.com/deroproject/derohe/crypto/ringct"
|
//import "github.com/deroproject/derohe/crypto/ringct"
|
||||||
//import "github.com/deroproject/derohe/transaction"
|
//import "github.com/deroproject/derohe/transaction"
|
||||||
|
|
||||||
//import "github.com/deroproject/derohe/globals"
|
import "github.com/deroproject/derohe/globals"
|
||||||
//import "github.com/deroproject/derohe/address"
|
//import "github.com/deroproject/derohe/address"
|
||||||
import "github.com/deroproject/derohe/rpc"
|
import "github.com/deroproject/derohe/rpc"
|
||||||
|
|
||||||
@ -187,12 +186,7 @@ func (w *Wallet_Memory) processPool(checkonly bool) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer globals.Recover()
|
||||||
if r := recover(); r != nil {
|
|
||||||
rlog.Warnf("Stack trace \n%s", debug.Stack())
|
|
||||||
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if !w.GetMode() { // if wallet is in offline mode , we cannot do anything
|
if !w.GetMode() { // if wallet is in offline mode , we cannot do anything
|
||||||
return fmt.Errorf("wallet is in offline mode")
|
return fmt.Errorf("wallet is in offline mode")
|
||||||
@ -226,8 +220,10 @@ func (w *Wallet_Memory) processPool(checkonly bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tx_result.Txs_as_hex[0] == "" {
|
if tx_result.Txs_as_hex[0] == "" {
|
||||||
try.Status = "Lost (not in mempool/chain, Waiting for more"
|
try.Status = "Lost (not in mempool/chain), Waiting for more blocks to retry"
|
||||||
if try.Height > info.StableHeight { // we have attempted, lets wait some blocks, this needs to be optimized, for instant transfer
|
if try.Height < (info.StableHeight + 1) { // we have attempted, lets wait some blocks, this needs to be optimized, for instant transfer
|
||||||
|
// we need to send this tx again now
|
||||||
|
}else{
|
||||||
continue // try other txs
|
continue // try other txs
|
||||||
}
|
}
|
||||||
} else if tx_result.Txs[0].In_pool {
|
} else if tx_result.Txs[0].In_pool {
|
||||||
@ -237,15 +233,16 @@ func (w *Wallet_Memory) processPool(checkonly bool) error {
|
|||||||
try.Status = fmt.Sprintf("Mined in %s (%d confirmations)", tx_result.Txs[0].ValidBlock, info.TopoHeight-tx_result.Txs[0].Block_Height)
|
try.Status = fmt.Sprintf("Mined in %s (%d confirmations)", tx_result.Txs[0].ValidBlock, info.TopoHeight-tx_result.Txs[0].Block_Height)
|
||||||
if try.Height < (info.StableHeight + 1) { // successful confirmation
|
if try.Height < (info.StableHeight + 1) { // successful confirmation
|
||||||
w.account.PoolHistory = append(w.account.PoolHistory, w.account.Pool[i])
|
w.account.PoolHistory = append(w.account.PoolHistory, w.account.Pool[i])
|
||||||
rlog.Infof("tx %s confirmed successfully at stableheight %d height %d trigger_height %d\n", try.TXID.String(), info.StableHeight, try.Height, w.account.Pool[i].Trigger_Height)
|
rlog.Infof("tx %s confirmed successfully at stableheight %d height %d trigger_height %d\n", try.TXID.String(), info.StableHeight, try.Height, w.account.Pool[i].Trigger_Height)
|
||||||
w.account.Pool = append(w.account.Pool[:i], w.account.Pool[i+1:]...)
|
w.account.Pool = append(w.account.Pool[:i], w.account.Pool[i+1:]...)
|
||||||
i-- // so another element at same place gets used
|
i-- // so another element at same place gets used
|
||||||
|
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
try.Status = fmt.Sprintf("Mined in sideblock (%d confirmations, waiting for more)", info.Height-try.Height)
|
try.Status = fmt.Sprintf("Mined in sideblock (%d confirmations, waiting for more blocks)", info.Height-try.Height)
|
||||||
if try.Height < info.StableHeight { // we have attempted, lets wait some blocks, this needs to be optimized, for instant transfer
|
if try.Height < (info.StableHeight + 1) { // we have attempted, lets wait some blocks, this needs to be optimized, for instant transfer
|
||||||
|
// we need to send this tx again now
|
||||||
|
}else{
|
||||||
continue // try other txs
|
continue // try other txs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,20 +253,21 @@ func (w *Wallet_Memory) processPool(checkonly bool) error {
|
|||||||
|
|
||||||
// we are here means we have to dispatch tx first time or again or whatever the case
|
// we are here means we have to dispatch tx first time or again or whatever the case
|
||||||
rlog.Debugf("%d tries, sending\n", len(w.account.Pool[i].Tries))
|
rlog.Debugf("%d tries, sending\n", len(w.account.Pool[i].Tries))
|
||||||
|
if len(w.account.Pool[i].Tries) >= 1 {
|
||||||
|
rlog.Debugf("tries status %+v\n", w.account.Pool[i].Tries) // for debug
|
||||||
|
}
|
||||||
|
|
||||||
tx, err := w.TransferPayload0(w.account.Pool[i].Transfers, w.account.Pool[i].Transfer_Everything, w.account.Pool[i].SCDATA, false)
|
tx, err := w.TransferPayload0(w.account.Pool[i].Transfers, w.account.Pool[i].Transfer_Everything, w.account.Pool[i].SCDATA, false)
|
||||||
//tx, err := w.Transfer_Simplified(w.account.Pool[i].Addr, w.account.Pool[i].Amount, w.account.Pool[i].Data)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rlog.Errorf("err building tx %s\n", err)
|
rlog.Errorf("err building tx %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
w.account.Pool[i].Tries = append(w.account.Pool[i].Tries, Try{int64(tx.Height), tx.GetHash(), "Dispatched to mempool"})
|
||||||
if err = w.SendTransaction(tx); err != nil {
|
if err = w.SendTransaction(tx); err != nil {
|
||||||
rlog.Errorf("err sending tx %s\n", err)
|
rlog.Errorf("err sending tx %s\n", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
rlog.Infof("dispatched tx %s at height %d trigger_height %d\n", tx.GetHash().String(), tx.Height, w.account.Pool[i].Trigger_Height)
|
rlog.Infof("dispatched tx %s at height %d trigger_height %d\n", tx.GetHash().String(), tx.Height, w.account.Pool[i].Trigger_Height)
|
||||||
w.account.Pool[i].Tries = append(w.account.Pool[i].Tries, Try{int64(tx.Height), tx.GetHash(), "Dispatched to mempool"})
|
|
||||||
break // we can only send one tx per height
|
break // we can only send one tx per height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,6 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, transfer_all
|
|||||||
defer w.transfer_mutex.Unlock()
|
defer w.transfer_mutex.Unlock()
|
||||||
ringsize := uint64(w.account.Ringsize) // use wallet mixin, if mixin not provided
|
ringsize := uint64(w.account.Ringsize) // use wallet mixin, if mixin not provided
|
||||||
|
|
||||||
bits_needed := make([]int, ringsize, ringsize)
|
|
||||||
|
|
||||||
// if wallet is online,take the fees from the network itself
|
// if wallet is online,take the fees from the network itself
|
||||||
// otherwise use whatever user has provided
|
// otherwise use whatever user has provided
|
||||||
//if w.GetMode() {
|
//if w.GetMode() {
|
||||||
@ -186,6 +184,9 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, transfer_all
|
|||||||
ringsize = 2 // only for easier testing
|
ringsize = 2 // only for easier testing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bits_needed := make([]int, ringsize, ringsize)
|
||||||
|
|
||||||
|
|
||||||
bits_needed[0], self_e, err = w.GetEncryptedBalanceAtTopoHeight(transfers[t].SCID, -1, w.GetAddress().String())
|
bits_needed[0], self_e, err = w.GetEncryptedBalanceAtTopoHeight(transfers[t].SCID, -1, w.GetAddress().String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("self unregistered err %s\n", err)
|
fmt.Printf("self unregistered err %s\n", err)
|
||||||
@ -217,13 +218,13 @@ func (w *Wallet_Memory) TransferPayload0(transfers []rpc.Transfer, transfer_all
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
receiver_without_payment_id := addr.BaseAddress()
|
receiver_without_payment_id := addr.BaseAddress()
|
||||||
for i, k := range w.random_ring_members(transfers[t].SCID) {
|
for _, k := range w.random_ring_members(transfers[t].SCID) {
|
||||||
if len(ring_members_keys)+2 < int(ringsize) && k != receiver_without_payment_id.String() && k != w.GetAddress().String() {
|
if len(ring_members_keys)+2 < int(ringsize) && k != receiver_without_payment_id.String() && k != w.GetAddress().String() {
|
||||||
|
|
||||||
// fmt.Printf("%s receiver %s sender %s\n", k, receiver_without_payment_id.String(), w.GetAddress().String())
|
// fmt.Printf("%s receiver %s sender %s\n", k, receiver_without_payment_id.String(), w.GetAddress().String())
|
||||||
var ebal *crypto.ElGamal
|
var ebal *crypto.ElGamal
|
||||||
var addr *rpc.Address
|
var addr *rpc.Address
|
||||||
bits_needed[i+2], ebal, err = w.GetEncryptedBalanceAtTopoHeight(transfers[t].SCID, -1, k)
|
bits_needed[len(ring_members_keys)], ebal, err = w.GetEncryptedBalanceAtTopoHeight(transfers[t].SCID, -1, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf(" unregistered %s\n", k)
|
fmt.Printf(" unregistered %s\n", k)
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user