decred.org/dcrdex@v1.0.3/client/asset/dcr/spv_mixing.go (about) 1 package dcr 2 3 import ( 4 "context" 5 6 "decred.org/dcrwallet/v4/wallet/udb" 7 "github.com/decred/dcrd/dcrutil/v4" 8 ) 9 10 // must be sorted large to small 11 var splitPoints = [...]dcrutil.Amount{ 12 1 << 36, // 687.19476736 13 1 << 34, // 171.79869184 14 1 << 32, // 042.94967296 15 1 << 30, // 010.73741824 16 1 << 28, // 002.68435456 17 1 << 26, // 000.67108864 18 1 << 24, // 000.16777216 19 1 << 22, // 000.04194304 20 1 << 20, // 000.01048576 21 1 << 18, // 000.00262144 22 } 23 24 var splitPointMap = map[int64]struct{}{} 25 26 func init() { 27 for _, amt := range splitPoints { 28 splitPointMap[int64(amt)] = struct{}{} 29 } 30 } 31 32 const ( 33 smalletCSPPSplitPoint = 1 << 18 // 262144 34 mixedAccountName = "mixed" 35 mixedAccountBranch = udb.InternalBranch 36 tradingAccountName = "dextrading" 37 ) 38 39 func (w *spvWallet) mix(ctx context.Context) { 40 mixedAccount, err := w.AccountNumber(ctx, mixedAccountName) 41 if err != nil { 42 w.log.Errorf("unable to look up mixed account: %v", err) 43 return 44 } 45 46 // unmixed account is the default account 47 unmixedAccount := uint32(defaultAcct) 48 49 w.log.Debug("Starting new cspp peer-to-peer funds mixing cycle") 50 51 // Don't perform any actions while transactions are not synced 52 // through the tip block. 53 synced, _ := w.spv.Synced(ctx) 54 if !synced { 55 w.log.Tracef("Skipping account mixing: transactions are not synced") 56 return 57 } 58 59 if err = w.MixAccount(ctx, unmixedAccount, mixedAccount, mixedAccountBranch); err != nil { 60 w.log.Errorf("Error mixing account: %v", err) 61 } 62 }