|
|
|
@ -37,6 +37,7 @@ type Service struct { |
|
|
|
|
GetAccountBalance func(common.Address) (*big.Int, error) |
|
|
|
|
CreateTransactionForPlayMethod func(string, int64) error |
|
|
|
|
CreateTransactionForPayoutMethod func(common.Address, int, string) error |
|
|
|
|
CreateTransactionForEndMethod func(common.Address) error |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// New returns new client support service.
|
|
|
|
@ -46,7 +47,8 @@ func New( |
|
|
|
|
CreateTransactionForPickWinner func() error, |
|
|
|
|
CallFaucetContract func(common.Address) common.Hash, GetAccountBalance func(common.Address) (*big.Int, error), |
|
|
|
|
CreateTransactionForPlayMethod func(string, int64) error, |
|
|
|
|
CreateTransactionForPayoutMethod func(common.Address, int, string) error) *Service { |
|
|
|
|
CreateTransactionForPayoutMethod func(common.Address, int, string) error, |
|
|
|
|
CreateTransactionForEndMethod func(common.Address) error) *Service { |
|
|
|
|
return &Service{ |
|
|
|
|
CreateTransactionForEnterMethod: CreateTransactionForEnterMethod, |
|
|
|
|
GetResult: GetResult, |
|
|
|
@ -55,6 +57,7 @@ func New( |
|
|
|
|
GetAccountBalance: GetAccountBalance, |
|
|
|
|
CreateTransactionForPlayMethod: CreateTransactionForPlayMethod, |
|
|
|
|
CreateTransactionForPayoutMethod: CreateTransactionForPayoutMethod, |
|
|
|
|
CreateTransactionForEndMethod: CreateTransactionForEndMethod, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -106,6 +109,10 @@ func (s *Service) Run() *http.Server { |
|
|
|
|
// Set up router for payout.
|
|
|
|
|
s.router.Path("/payout").Queries("address", "{[0-9A-Fa-fx]*?}", "level", "{[0-9]*?}", "sequence", "{[A-Za-z]*?}").HandlerFunc(s.Payout).Methods("GET") |
|
|
|
|
s.router.Path("/payout").HandlerFunc(s.Payout) |
|
|
|
|
|
|
|
|
|
// Set up router for endgame.
|
|
|
|
|
s.router.Path("/end").Queries("address", "{[0-9A-Fa-fx]*?}").HandlerFunc(s.End).Methods("GET") |
|
|
|
|
s.router.Path("/end").HandlerFunc(s.End) |
|
|
|
|
// Do serving now.
|
|
|
|
|
utils.GetLogInstance().Info("Listening on ", "port: ", Port) |
|
|
|
|
server := &http.Server{Addr: addr, Handler: s.router} |
|
|
|
|