Categorygithub.com/NpoolPlatform/fox-proxy
module
0.0.0-20250114072644-aba06e49924f
Repository: https://github.com/npoolplatform/fox-proxy.git
Documentation: pkg.go.dev

# README

Npool go service app template

Test

目录


功能

sync

  • 创建钱包
  • 查询余额

async

  • 转账
  • 上报币种

设计

Transaction:

FieldTypeUniqueOptionalNillableDefaultUpdateDefaultImmutableStructTagValidators
idstringtruefalsefalsetruefalsefalsejson:"id,omitempty"0
nonceuint64falsefalsefalsetruefalsefalsejson:"nonce,omitempty"0
coin_typeint8falsefalsefalsetruefalsefalsejson:"coin_type,omitempty"0
transaction_idstringfalsefalsefalsetruefalsefalsejson:"transaction_id,omitempty"1
fromstringfalsefalsefalsetruefalsefalsejson:"from,omitempty"1
tostringfalsefalsefalsetruefalsefalsejson:"to,omitempty"1
valuefloat64falsefalsefalsetruefalsefalsejson:"value,omitempty"0
statetransaction.Statefalsefalsefalsefalsefalsefalsejson:"state,omitempty"0
payoutstringfalsefalsefalsefalsefalsefalsejson:"payout,omitempty"0
create_atuint32falsefalsefalsetruefalsefalsejson:"create_at,omitempty"0
update_atuint32falsefalsefalsetruetruefalsejson:"update_at,omitempty"0
delete_atuint32falsefalsefalsetruefalsefalsejson:"delete_at,omitempty"0

state字段说明:

valuedefinedesc
0TransactionStateUnKnow未知
30TransactionStatePrepare准备状态,需要从私钥中获取如ViewKey信息等,不是所有币种都需要
1TransactionStateWait等待,交易创建时的初始状态
2TransactionStateSign签名
20TransactionStateBroadcast广播
3TransactionStateSync等待上链
4TransactionStateDone交易成功
5TransactionStateFail交易失败

命令

  • make init 初始化仓库,创建go.mod
  • make verify 验证开发环境与构建环境,检查code conduct
  • make verify-build 编译目标
  • make test 单元测试
  • make generate-docker-images 生成docker镜像
  • make service-sample 单独编译服务
  • make service-sample-image 单独生成服务镜像
  • make deploy-to-k8s-cluster 部署到k8s集群

步骤

最佳实践

  • 每个服务只提供单一可执行文件,有利于docker镜像打包与k8s部署管理
  • 每个服务提供http调试接口,通过curl获取调试信息
  • 集群内服务间direct call调用通过服务发现获取目标地址进行调用
  • 集群内服务间event call调用通过rabbitmq解耦

关于mysql

  • 创建app后,从app.Mysql()获取本地mysql client
  • 文档参考

优化

对离线钱包的操作抽象接口,从服务中剥离出来

# Packages

No description provided by the author
No description provided by the author
No description provided by the author