return n, nil
}
-/*
-func tagsToNullString(tags map[string]interface{}) (*stdsql.NullString, error) {
- var tagsJSON []byte
- if len(tags) != 0 {
- var err error
- tagsJSON, err = json.Marshal(tags)
- if err != nil {
- return nil, errors.Wrap(err)
+
+func (m *Manager) QueryAll(ctx context.Context) (interface{}, error){
+ ret := make([]interface{},0)
+
+ iter := m.db.Iterator()
+ for iter.Next() {
+ value := string(iter.Value())
+ if value[:3] == "acc"{
+ continue
}
+ ret = append(ret,value)
+ //log.Printf(ctx,"%s\t", value)
}
- return &stdsql.NullString{String: string(tagsJSON), Valid: len(tagsJSON) > 0}, nil
-}
-*/
+
+ return ret,nil
+}
\ No newline at end of file
"github.com/bytom/protocol"
"github.com/bytom/protocol/bc"
"github.com/bytom/protocol/vm/vmutil"
+ //"github.com/bytom/log"
)
const maxAssetCache = 1000
}
+func (reg *Registry) QueryAll(ctx context.Context) (interface{}, error){
+ ret := make([]interface{},0)
+
+ iter := reg.db.Iterator()
+ for iter.Next() {
+ value := string(iter.Value())
+ ret = append(ret,value)
+ //log.Printf(ctx,"%s\t", value)
+ }
+
+ return ret,nil
+}
+
// insertAsset adds the asset to the database. If the asset has a client token,
// and there already exists an asset with that client token, insertAsset will
// lookup and return the existing asset instead.
"github.com/bytom/blockchain/query/filter"
"github.com/bytom/errors"
"github.com/bytom/net/http/httpjson"
+ //"github.com/bytom/log"
)
const (
defGenericPageSize = 100
)
-// listAccounts is an http handler for listing accounts matching
-// an index or an ad-hoc filter.
+
//
// POST /list-accounts
-func (bcr *BlockchainReactor) listAccounts(ctx context.Context, in requestQuery) (page, error) {
- limit := in.PageSize
- if limit == 0 {
- limit = defGenericPageSize
- }
- after := in.After
-/*
- // Use the filter engine for querying account tags.
- accounts, after, err := bcr.indexer.Accounts(ctx, in.Filter, in.FilterParams, after, limit)
- if err != nil {
- return page{}, errors.Wrap(err, "running acc query")
- }
-*/
- // Pull in the accounts by the IDs
- out := in
- out.After = after
- return page{
-// Items: httpjson.Array(accounts),
-// LastPage: len(accounts) < limit,
- Next: out,
- }, nil
+func (bcr *BlockchainReactor) listAccounts(ctx context.Context, in requestQuery) interface{} {
+
+ response,_ := bcr.accounts.QueryAll(ctx)
+
+ return response
+
}
-// listAssets is an http handler for listing assets matching
-// an index or an ad-hoc filter.
+
//
// POST /list-assets
-func (bcr *BlockchainReactor) listAssets(ctx context.Context, in requestQuery) (page, error) {
- limit := in.PageSize
- if limit == 0 {
- limit = defGenericPageSize
- }
- after := in.After
+func (bcr *BlockchainReactor) listAssets(ctx context.Context, in requestQuery) interface{} {
-/* // Use the query engine for querying asset tags.
- assets, after, err := bcr.indexer.Assets(ctx, in.Filter, in.FilterParams, after, limit)
- if err != nil {
- return page{}, errors.Wrap(err, "running asset query")
- }
-*/
- out := in
- out.After = after
- return page{
-// Items: httpjson.Array(assets),
-// LastPage: len(assets) < limit,
- Next: out,
- }, nil
+ response,_ := bcr.assets.QueryAll(ctx)
+
+ return response
}
// POST /list-balances
Aliases []string `json:"aliases,omitempty"`
}
var in requestQuery
- after := in.After
- out := in
- out.After = after
- client.Call(context.Background(), "/list-accounts", &[]requestQuery{in}, nil)
+
+
+ responses := make([]interface{}, 1)
+
+ client.Call(context.Background(), "/list-accounts", in, &responses)
+ for i,item := range responses{
+ fmt.Println(i,"-----",item)
+ }
}
func listAssets(client *rpc.Client, args []string) {
Aliases []string `json:"aliases,omitempty"`
}
var in requestQuery
- after := in.After
- out := in
- out.After = after
- client.Call(context.Background(), "/list-assets", &[]requestQuery{in}, nil)
+ responses := make([]interface{}, 1)
+
+ client.Call(context.Background(), "/list-assets", in, &responses)
+ for i,item := range responses{
+ fmt.Println(i,"-----",item)
+ }
+
}
func listTxFeeds(client *rpc.Client, args []string) {