Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Fixed a bug about store AssetId.
Browse files Browse the repository at this point in the history
  • Loading branch information
gguoss committed Sep 9, 2017
1 parent 4762582 commit 4d144fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
11 changes: 2 additions & 9 deletions blockchain/asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@ package asset

import (
"context"
//"database/sql"
"encoding/json"
// "fmt"
"sync"

"golang.org/x/crypto/sha3"

"github.com/golang/groupcache/lru"
"github.com/golang/groupcache/singleflight"
// "github.com/lib/pq"
dbm "github.com/tendermint/tmlibs/db"

// "github.com/bytom/blockchain/pin"
"github.com/bytom/blockchain/signers"
"github.com/bytom/crypto/ed25519"
"github.com/bytom/crypto/ed25519/chainkd"
// "chain/database/pg"
"github.com/bytom/errors"
"github.com/bytom/protocol"
"github.com/bytom/protocol/bc"
Expand All @@ -32,12 +27,11 @@ var (
ErrBadIdentifier = errors.New("either ID or alias must be specified, and not both")
)

func NewRegistry(db dbm.DB, chain *protocol.Chain/*, pinStore *pin.Store*/) *Registry {
func NewRegistry(db dbm.DB, chain *protocol.Chain) *Registry {
return &Registry{
db: db,
chain: chain,
initialBlockHash: chain.InitialBlockHash,
// pinStore: pinStore,
cache: lru.New(maxAssetCache),
aliasCache: lru.New(maxAssetCache),
}
Expand All @@ -49,7 +43,6 @@ type Registry struct {
chain *protocol.Chain
indexer Saver
initialBlockHash bc.Hash
// pinStore *pin.Store

idGroup singleflight.Group
aliasGroup singleflight.Group
Expand Down Expand Up @@ -135,7 +128,7 @@ func (reg *Registry) Define(ctx context.Context, xpubs []chainkd.XPub, quorum in
asset.Alias = &alias
}

asset_id := []byte(assetSigner.ID)
asset_id := asset.AssetID.Bytes()
ass, err := json.Marshal(asset)
if err != nil {
return nil, errors.Wrap(err, "failed marshal asset")
Expand Down
8 changes: 2 additions & 6 deletions blockchain/asset/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import (

"github.com/bytom/blockchain/signers"
"github.com/bytom/blockchain/txbuilder"
//"chain/database/pg"
chainjson "github.com/bytom/encoding/json"
"github.com/bytom/log"
// "github.com/bytom/errors"
"github.com/bytom/protocol/bc"
"github.com/bytom/protocol/bc/legacy"
)
Expand Down Expand Up @@ -41,12 +39,10 @@ func (a *issueAction) Build(ctx context.Context, builder *txbuilder.TemplateBuil
return txbuilder.MissingFieldsError("asset_id")
return nil
}
log.Printf(ctx, "AssetId:%v\n", a.AssetId)

asset, err := a.assets.findByID(ctx, *a.AssetId)
/* if errors.Root(err) == pg.ErrUserInputNotFound {
err = errors.WithDetailf(err, "missing asset with ID %x", a.AssetId.Bytes())
}
*/ if err != nil {
if err != nil {
return err
}

Expand Down
14 changes: 0 additions & 14 deletions cmd/bytomcli/example/issue.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
package example

import (
//"bytes"
"context"
// "flag"
"fmt"
//"io"
//"net"
//"net/http"
//"os"
//"path/filepath"
//"strings"
//"time"
stdjson "encoding/json"

//"github.com/bytom/blockchain"
"github.com/bytom/blockchain/rpc"
//"github.com/bytom/crypto/ed25519"
//"github.com/bytom/env"
//"github.com/bytom/errors"
//"github.com/bytom/log"
"github.com/bytom/crypto/ed25519/chainkd"
"github.com/bytom/blockchain/query"
"github.com/bytom/blockchain/txbuilder"
Expand Down

0 comments on commit 4d144fc

Please sign in to comment.