|
|
@ -37,6 +37,7 @@ type Service struct { |
|
|
|
GetAccountBalance func(common.Address) (*big.Int, error) |
|
|
|
GetAccountBalance func(common.Address) (*big.Int, error) |
|
|
|
CreateTransactionForPlayMethod func(string, int64) error |
|
|
|
CreateTransactionForPlayMethod func(string, int64) error |
|
|
|
CreateTransactionForPayoutMethod func(common.Address, int, string) error |
|
|
|
CreateTransactionForPayoutMethod func(common.Address, int, string) error |
|
|
|
|
|
|
|
CreateTransactionForEndMethod func(common.Address) error |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// New returns new client support service.
|
|
|
|
// New returns new client support service.
|
|
|
@ -46,7 +47,8 @@ func New( |
|
|
|
CreateTransactionForPickWinner func() error, |
|
|
|
CreateTransactionForPickWinner func() error, |
|
|
|
CallFaucetContract func(common.Address) common.Hash, GetAccountBalance func(common.Address) (*big.Int, error), |
|
|
|
CallFaucetContract func(common.Address) common.Hash, GetAccountBalance func(common.Address) (*big.Int, error), |
|
|
|
CreateTransactionForPlayMethod func(string, int64) 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{ |
|
|
|
return &Service{ |
|
|
|
CreateTransactionForEnterMethod: CreateTransactionForEnterMethod, |
|
|
|
CreateTransactionForEnterMethod: CreateTransactionForEnterMethod, |
|
|
|
GetResult: GetResult, |
|
|
|
GetResult: GetResult, |
|
|
@ -55,6 +57,7 @@ func New( |
|
|
|
GetAccountBalance: GetAccountBalance, |
|
|
|
GetAccountBalance: GetAccountBalance, |
|
|
|
CreateTransactionForPlayMethod: CreateTransactionForPlayMethod, |
|
|
|
CreateTransactionForPlayMethod: CreateTransactionForPlayMethod, |
|
|
|
CreateTransactionForPayoutMethod: CreateTransactionForPayoutMethod, |
|
|
|
CreateTransactionForPayoutMethod: CreateTransactionForPayoutMethod, |
|
|
|
|
|
|
|
CreateTransactionForEndMethod: CreateTransactionForEndMethod, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -106,6 +109,10 @@ func (s *Service) Run() *http.Server { |
|
|
|
// Set up router for payout.
|
|
|
|
// 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").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) |
|
|
|
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.
|
|
|
|
// Do serving now.
|
|
|
|
utils.GetLogInstance().Info("Listening on ", "port: ", Port) |
|
|
|
utils.GetLogInstance().Info("Listening on ", "port: ", Port) |
|
|
|
server := &http.Server{Addr: addr, Handler: s.router} |
|
|
|
server := &http.Server{Addr: addr, Handler: s.router} |
|
|
|