diff --git a/neo3fura_http/lib/cli/src.go b/neo3fura_http/lib/cli/src.go index 516ac73..6218fb4 100644 --- a/neo3fura_http/lib/cli/src.go +++ b/neo3fura_http/lib/cli/src.go @@ -6,13 +6,16 @@ import ( "encoding/hex" "encoding/json" "fmt" + "github.com/go-redis/redis/v8" "github.com/joeqian10/neo3-gogogo/rpc" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" + log2 "neo3fura_http/lib/log" + "neo3fura_http/lib/type/consts" "neo3fura_http/lib/type/h160" "neo3fura_http/var/stderr" ) @@ -135,11 +138,11 @@ func (me *T) QueryAll(args struct { Skip int64 }, ret *json.RawMessage) ([]map[string]interface{}, int64, error) { - //if args.Limit == 0 { - // args.Limit = limit2.DefaultLimit - //} else if args.Limit > limit2.MaxLimit { - // args.Limit = limit2.MaxLimit - //} + if args.Limit == 0 { + args.Limit = consts.DefaultLimit + } else if args.Limit > consts.MaxLimit { + args.Limit = consts.MaxLimit + } var results []map[string]interface{} convert := make([]map[string]interface{}, 0) @@ -337,17 +340,17 @@ func (me *T) QueryAggregate(args struct { Query []string }, ret *json.RawMessage) ([]map[string]interface{}, error) { - //for _, v := range args.Pipeline { - // limit := v["$limit"] - // if limit != nil { - // if limit.(int64) == 0 { - // v["$limit"] = limit2.DefaultLimit - // } - // if limit.(int64) > limit2.MaxLimit { - // v["$limit"] = limit2.MaxLimit - // } - // } - //} + for _, v := range args.Pipeline { + limit := v["$limit"] + if limit != nil { + if limit.(int64) == 0 { + v["$limit"] = consts.DefaultLimit + } + if limit.(int64) > consts.MaxLimit { + v["$limit"] = consts.MaxLimit + } + } + } var results []map[string]interface{} convert := make([]map[string]interface{}, 0) diff --git a/neo3fura_http/lib/type/consts/src.go b/neo3fura_http/lib/type/consts/src.go index 3a50f3c..febe087 100644 --- a/neo3fura_http/lib/type/consts/src.go +++ b/neo3fura_http/lib/type/consts/src.go @@ -1,9 +1,11 @@ package consts const ( - ShortForm = "2006-01-02" - BNEO_Main = "0x48c40d4666f93408be1bef038b6722404d9a4c2a" - BNEO_Test = "0x85deac50febfd93988d3f391dea54e8289e43e9e" - NEO = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5" - GAS = "0xd2a4cff31913016155e38e474a2c06d08be276cf" + ShortForm = "2006-01-02" + BNEO_Main = "0x48c40d4666f93408be1bef038b6722404d9a4c2a" + BNEO_Test = "0x85deac50febfd93988d3f391dea54e8289e43e9e" + NEO = "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5" + GAS = "0xd2a4cff31913016155e38e474a2c06d08be276cf" + DefaultLimit = 20 + MaxLimit = 100 )