forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor * No more decorators, but rather types.AntiHandler * No more handlers, but rather types.MsgHandler * Ability to pass "stores" in NewXYZHandler() * Coins live in types, and Accounts have coins * Coinstore -> bank
- Loading branch information
Showing
28 changed files
with
696 additions
and
715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
* global state dumper. | ||
for developer to list accounts, etc. | ||
e.g. what does the world look like? | ||
cmd cli. | ||
|
||
* something that can list transactions ... | ||
make all decorators actually use the logger | ||
so you can see all the txs and see what's going on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package app | ||
|
||
type Router interface { | ||
AddRoute(r string, h Handler) | ||
Route(path string) (h Handler) | ||
} | ||
|
||
type route struct { | ||
r string | ||
h Handler | ||
} | ||
|
||
type router struct { | ||
routes []route | ||
} | ||
|
||
func NewRouter() router { | ||
return router{ | ||
routes: make([]route), | ||
} | ||
} | ||
|
||
var isAlpha = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString | ||
|
||
func (rtr router) AddRoute(r string, h Handler) { | ||
if !isAlpha(r) { | ||
panic("route expressions can only contain alphanumeric characters") | ||
} | ||
rtr.routes = append(rtr.routes, route{r, h}) | ||
} | ||
|
||
// TODO handle expressive matches. | ||
func (rtr router) Route(path string) (h Handler) { | ||
for _, route := range rtr.routes { | ||
if route.r == path { | ||
return route.h | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.