处理外部提交过来的 Http 请求,后端由 Wallet 对象进行处理。

// all components requiring access to wallet must use , this struct to communicate
// this structure must be update while mutex
type RPCServer struct {
    address          string
    srv              *http.Server
    mux              *http.ServeMux
    mr               *jsonrpc.MethodRepository
    Exit_Event       chan bool // wallet is shutting down and we must quit ASAP
    Exit_In_Progress bool

    w *Wallet // reference to the wallet which is open
    sync.RWMutex
}

架构设计:

路由层(外层请求过来,不同请求该怎么处理,由它路由)

Handle 层(通过路由过来的请求,由它处理)

业务层(提供 Wallet 对象,由它实现封装,它与钱包或者其它系统模块交互)

服务用的是 http.Server,启动、运行实现起来都比较简单。

results matching ""

    No results matching ""