"strings"
"time"
- "github.com/vapor/crypto/sha3pool"
- dbm "github.com/vapor/database/leveldb"
- "github.com/vapor/errors"
+ "github.com/bytom/vapor/crypto/sha3pool"
+ dbm "github.com/bytom/vapor/database/leveldb"
+ "github.com/bytom/vapor/errors"
)
const tokenSize = 32
hashedSecret := make([]byte, tokenSize)
sha3pool.Sum256(hashedSecret, secret)
-
token := &Token{
ID: id,
Token: fmt.Sprintf("%s:%x", id, hashedSecret),
if err != nil {
return nil, err
}
- cs.DB.Set(key, value)
+ cs.DB.Set(key, value)
return token, nil
}
return errors.WithDetailf(ErrBadID, "invalid id %q", id)
}
- var value []byte
- token := &Token{}
-
- if value = cs.DB.Get([]byte(id)); value == nil {
+ value := cs.DB.Get([]byte(id))
+ if value == nil {
return errors.WithDetailf(ErrNoMatchID, "check id %q nonexisting", id)
}
+
+ token := &Token{}
if err := json.Unmarshal(value, token); err != nil {
return err
}