github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/radar/orgchain/routing_main_tx.go (about) 1 package orgchain 2 3 import ( 4 "fmt" 5 6 maintypes "github.com/sixexorg/magnetic-ring/core/mainchain/types" 7 orgtypes "github.com/sixexorg/magnetic-ring/core/orgchain/types" 8 "github.com/sixexorg/magnetic-ring/errors" 9 ) 10 11 func (this *Radar) RoutingMainTx(tx *maintypes.Transaction) *ResultOp { 12 fmt.Println("♻️ Recycling the main chain transaction to the circle") 13 re := &ResultOp{} 14 15 16 fmt.Printf("tx.txdata.leagueId=%s,this.leagueId=%s\n",tx.TxData.LeagueId.ToString(),this.leagueId.ToString()) 17 18 if !containMainType(tx.TxType) && tx.TxData.LeagueId != this.leagueId { 19 errch := make(chan error, 1) 20 errch <- errors.ERR_RADAR_TX_USELESS 21 close(errch) 22 re.Err = errch 23 return re 24 } 25 switch tx.TxType { 26 case maintypes.ConsensusLeague: 27 mcc, err := this.AffectConsensusLeague(tx) 28 if err != nil { 29 errch := make(chan error, 1) 30 errch <- err 31 close(errch) 32 re.Err = errch 33 34 } else { 35 mccch := make(chan *MainChainCfm, 1) 36 mccch <- mcc 37 close(mccch) 38 re.MCC = mccch 39 } 40 return re 41 case maintypes.LockLeague: 42 mcc, err := this.AffectLockLeague(tx) 43 if err != nil { 44 errch := make(chan error, 1) 45 errch <- err 46 close(errch) 47 re.Err = errch 48 49 } else { 50 mccch := make(chan *MainChainCfm, 1) 51 mccch <- mcc 52 close(mccch) 53 re.MCC = mccch 54 } 55 return re 56 case maintypes.JoinLeague: 57 fmt.Printf("🎒 🎒 🎒 🎒 🎒 🎒 🎒 🎒 🎒 🎒 --->txhash=%s\n",tx.TransactionHash) 58 orgtx, err := this.AffectJoinLeague(tx) 59 if err != nil { 60 errch := make(chan error, 1) 61 errch <- err 62 close(errch) 63 re.Err = errch 64 } else { 65 txcch := make(chan *orgtypes.Transaction, 1) 66 txcch <- orgtx 67 close(txcch) 68 re.ORGTX = txcch 69 } 70 return re 71 72 case maintypes.ApplyPass://TODO 73 74 75 76 case maintypes.EnergyToLeague: 77 orgtx, err := this.AffectEnergyToLeague(tx) 78 if err != nil { 79 errch := make(chan error, 1) 80 errch <- err 81 close(errch) 82 re.Err = errch 83 84 } else { 85 txcch := make(chan *orgtypes.Transaction, 1) 86 txcch <- orgtx 87 close(txcch) 88 re.ORGTX = txcch 89 } 90 return re 91 case maintypes.RaiseUT: 92 orgtx, err := this.AffectRaiseUT(tx) 93 if err != nil { 94 errch := make(chan error, 1) 95 errch <- err 96 close(errch) 97 re.Err = errch 98 99 } else { 100 txcch := make(chan *orgtypes.Transaction, 1) 101 txcch <- orgtx 102 close(txcch) 103 re.ORGTX = txcch 104 } 105 return re 106 } 107 return re 108 }