| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 607bcf5 commit 324ee20
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -719,7 +719,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error) | |||
| 719 | 719 | AdvancePayment: tx.AdvancePayment, | |
| 720 | 720 | } | |
| 721 | 721 | // generate genesis block | |
| 722 | - gb, err := s.generateGenesisBlock(*dbID, tx.ResourceMeta) | ||
| 722 | + gb, err := s.generateGenesisBlock(dbID, tx.ResourceMeta) | ||
| 723 | 723 | if err != nil { | |
| 724 | 724 | log.WithFields(log.Fields{ | |
| 725 | 725 | "dbID": dbID, | |
@@ -739,7 +739,7 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error) | |||
| 739 | 739 | ||
| 740 | 740 | // create sqlchain | |
| 741 | 741 | sp := &types.SQLChainProfile{ | |
| 742 | - ID: *dbID, | ||
| 742 | + ID: dbID, | ||
| 743 | 743 | Address: dbAddr, | |
| 744 | 744 | Period: sqlchainPeriod, | |
| 745 | 745 | GasPrice: tx.GasPrice, | |
@@ -750,16 +750,16 @@ func (s *metaState) matchProvidersWithUser(tx *types.CreateDatabase) (err error) | |||
| 750 | 750 | Miners: miners[:], | |
| 751 | 751 | } | |
| 752 | 752 | ||
| 753 | - if _, loaded := s.loadSQLChainObject(*dbID); loaded { | ||
| 754 | - err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", string(*dbID)) | ||
| 753 | + if _, loaded := s.loadSQLChainObject(dbID); loaded { | ||
| 754 | + err = errors.Wrapf(ErrDatabaseExists, "database exists: %s", dbID) | ||
| 755 | 755 | return | |
| 756 | 756 | } | |
| 757 | 757 | s.dirty.accounts[dbAddr] = &types.Account{Address: dbAddr} | |
| 758 | - s.dirty.databases[*dbID] = sp | ||
| 758 | + s.dirty.databases[dbID] = sp | ||
| 759 | 759 | for _, miner := range tx.ResourceMeta.TargetMiners { | |
| 760 | 760 | s.deleteProviderObject(miner) | |
| 761 | 761 | } | |
| 762 | - log.Infof("success create sqlchain with database ID: %s", string(*dbID)) | ||
| 762 | + log.Infof("success create sqlchain with database ID: %s", dbID) | ||
| 763 | 763 | return | |
| 764 | 764 | } | |
| 765 | 765 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -897,7 +897,7 @@ func TestMetaState(t *testing.T) { | |||
| 897 | 897 | uint64(conf.GConf.UpdatePeriod) * uint64(len(cd2.ResourceMeta.TargetMiners)) | |
| 898 | 898 | So(b1-b2, ShouldEqual, cd1.AdvancePayment+minAdvancePayment) | |
| 899 | 899 | dbID := proto.FromAccountAndNonce(cd1.Owner, uint32(cd1.Nonce)) | |
| 900 | - co, loaded = ms.loadSQLChainObject(*dbID) | ||
| 900 | + co, loaded = ms.loadSQLChainObject(dbID) | ||
| 901 | 901 | So(loaded, ShouldBeTrue) | |
| 902 | 902 | dbAccount, err := dbID.AccountAddress() | |
| 903 | 903 | So(err, ShouldBeNil) | |
@@ -961,7 +961,7 @@ func TestMetaState(t *testing.T) { | |||
| 961 | 961 | err = ms.apply(&up) | |
| 962 | 962 | So(errors.Cause(err), ShouldEqual, ErrAccountPermissionDeny) | |
| 963 | 963 | ||
| 964 | - co, loaded = ms.loadSQLChainObject(*dbID) | ||
| 964 | + co, loaded = ms.loadSQLChainObject(dbID) | ||
| 965 | 965 | for _, user := range co.Users { | |
| 966 | 966 | if user.Address == addr1 { | |
| 967 | 967 | So(user.Permission, ShouldEqual, types.Read) | |
@@ -1032,7 +1032,7 @@ func TestMetaState(t *testing.T) { | |||
| 1032 | 1032 | So(err, ShouldBeNil) | |
| 1033 | 1033 | ms.commit() | |
| 1034 | 1034 | ||
| 1035 | - co, loaded = ms.loadSQLChainObject(*dbID) | ||
| 1035 | + co, loaded = ms.loadSQLChainObject(dbID) | ||
| 1036 | 1036 | for _, miner := range co.Miners { | |
| 1037 | 1037 | if miner.Address == addr1 { | |
| 1038 | 1038 | So(miner.EncryptionKey, ShouldEqual, encryptKey) | |
@@ -1093,7 +1093,7 @@ func TestMetaState(t *testing.T) { | |||
| 1093 | 1093 | So(err, ShouldBeNil) | |
| 1094 | 1094 | err = ms.apply(ub2) | |
| 1095 | 1095 | ms.commit() | |
| 1096 | - sqlchain, loaded := ms.loadSQLChainObject(*dbID) | ||
| 1096 | + sqlchain, loaded := ms.loadSQLChainObject(dbID) | ||
| 1097 | 1097 | So(loaded, ShouldBeTrue) | |
| 1098 | 1098 | So(len(sqlchain.Miners), ShouldEqual, 1) | |
| 1099 | 1099 | So(sqlchain.Miners[0].PendingIncome, ShouldEqual, 125) | |
@@ -1140,7 +1140,7 @@ func TestMetaState(t *testing.T) { | |||
| 1140 | 1140 | So(err, ShouldBeNil) | |
| 1141 | 1141 | err = ms.apply(ub3) | |
| 1142 | 1142 | So(err, ShouldBeNil) | |
| 1143 | - sqlchain, loaded = ms.loadSQLChainObject(*dbID) | ||
| 1143 | + sqlchain, loaded = ms.loadSQLChainObject(dbID) | ||
| 1144 | 1144 | So(loaded, ShouldBeTrue) | |
| 1145 | 1145 | So(len(sqlchain.Miners), ShouldEqual, 1) | |
| 1146 | 1146 | So(sqlchain.Miners[0].PendingIncome, ShouldEqual, 115) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,7 +225,7 @@ func Create( | |||
| 225 | 225 | return | |
| 226 | 226 | } | |
| 227 | 227 | ||
| 228 | - dbID = *proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce)) | ||
| 228 | + dbID = proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce)) | ||
| 229 | 229 | dsn = fmt.Sprintf("cql://%s", string(dbID)) | |
| 230 | 230 | return | |
| 231 | 231 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -181,7 +181,7 @@ func Create(meta ResourceMeta) (dsn string, err error) { | |||
| 181 | 181 | } | |
| 182 | 182 | ||
| 183 | 183 | cfg := NewConfig() | |
| 184 | - cfg.DatabaseID = string(*proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce))) | ||
| 184 | + cfg.DatabaseID = string(proto.FromAccountAndNonce(clientAddr, uint32(nonceResp.Nonce))) | ||
| 185 | 185 | dsn = cfg.FormatDSN() | |
| 186 | 186 | ||
| 187 | 187 | return | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,7 +73,7 @@ func TestCreate(t *testing.T) { | |||
| 73 | 73 | var addr proto.AccountAddress | |
| 74 | 74 | addr, err = crypto.PubKeyHash(priv.PubKey()) | |
| 75 | 75 | So(err, ShouldBeNil) | |
| 76 | - var dbid = string(*proto.FromAccountAndNonce(addr, uint32(stubNextNonce))) | ||
| 76 | + var dbid = string(proto.FromAccountAndNonce(addr, uint32(stubNextNonce))) | ||
| 77 | 77 | ||
| 78 | 78 | recoveredCfg, err := ParseDSN(dsn) | |
| 79 | 79 | So(err, ShouldBeNil) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,9 +176,8 @@ func (d *DatabaseID) AccountAddress() (a AccountAddress, err error) { | |||
| 176 | 176 | } | |
| 177 | 177 | ||
| 178 | 178 | // FromAccountAndNonce generates databaseID from Account and its nonce. | |
| 179 | - func FromAccountAndNonce(accountAddress AccountAddress, nonce uint32) *DatabaseID { | ||
| 179 | + func FromAccountAndNonce(accountAddress AccountAddress, nonce uint32) DatabaseID { | ||
| 180 | 180 | addrAndNonce := fmt.Sprintf("%s%d", accountAddress.String(), nonce) | |
| 181 | 181 | rawID := hash.THashH([]byte(addrAndNonce)) | |
| 182 | - d := DatabaseID(rawID.String()) | ||
| 183 | - return &d | ||
| 182 | + return DatabaseID(rawID.String()) | ||
| 184 | 183 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -100,7 +100,7 @@ func TestFromAccountAndNonce(t *testing.T) { | |||
| 100 | 100 | So(err, ShouldBeNil) | |
| 101 | 101 | a := AccountAddress(*h) | |
| 102 | 102 | dbID := FromAccountAndNonce(a, target[i].nonce) | |
| 103 | - So(string(*dbID), ShouldResemble, target[i].result) | ||
| 103 | + So(string(dbID), ShouldResemble, target[i].result) | ||
| 104 | 104 | } | |
| 105 | 105 | }) | |
| 106 | 106 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,8 +89,8 @@ func (tb *Billing) GetAccountNonce() pi.AccountNonce { | |||
| 89 | 89 | } | |
| 90 | 90 | ||
| 91 | 91 | // GetDatabaseID gets the database ID. | |
| 92 | - func (tb *Billing) GetDatabaseID() *proto.DatabaseID { | ||
| 93 | - return &tb.BillingRequest.Header.DatabaseID | ||
| 92 | + func (tb *Billing) GetDatabaseID() proto.DatabaseID { | ||
| 93 | + return tb.BillingRequest.Header.DatabaseID | ||
| 94 | 94 | } | |
| 95 | 95 | ||
| 96 | 96 | func init() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -129,8 +129,8 @@ func TestBilling_PackAndSignTx(t *testing.T) { | |||
| 129 | 129 | ||
| 130 | 130 | tb.GetAccountNonce() | |
| 131 | 131 | ||
| 132 | - if tb.GetDatabaseID() == nil { | ||
| 133 | - t.Fatal("get nil DatabaseID") | ||
| 132 | + if len(tb.GetDatabaseID()) == 0 { | ||
| 133 | + t.Fatal("get empty DatabaseID") | ||
| 134 | 134 | } | |
| 135 | 135 | ||
| 136 | 136 | tb.Signature = nil | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,7 +73,7 @@ func generateRandomAccountAddresses(n int) (s []proto.AccountAddress) { | |||
| 73 | 73 | ||
| 74 | 74 | func generateRandomProfile() *SQLChainProfile { | |
| 75 | 75 | return &SQLChainProfile{ | |
| 76 | - ID: *generateRandomDatabaseID(), | ||
| 76 | + ID: generateRandomDatabaseID(), | ||
| 77 | 77 | Owner: proto.AccountAddress(generateRandomHash()), | |
| 78 | 78 | Users: generateRandomSQLChainUsers(rand.Intn(10) + 1), | |
| 79 | 79 | } | |
@@ -106,9 +106,8 @@ func generateRandomHash() hash.Hash { | |||
| 106 | 106 | ||
| 107 | 107 | } | |
| 108 | 108 | ||
| 109 | - func generateRandomDatabaseID() *proto.DatabaseID { | ||
| 110 | - id := proto.DatabaseID(randStringBytes(uuidLen)) | ||
| 111 | - return &id | ||
| 109 | + func generateRandomDatabaseID() proto.DatabaseID { | ||
| 110 | + return proto.DatabaseID(randStringBytes(uuidLen)) | ||
| 112 | 111 | ||
| 113 | 112 | } | |
| 114 | 113 | ||
@@ -172,7 +171,7 @@ func generateRandomBlock(parent hash.Hash, isGenesis bool) (b *BPBlock, err erro | |||
| 172 | 171 | ||
| 173 | 172 | func generateRandomBillingRequestHeader() *BillingRequestHeader { | |
| 174 | 173 | return &BillingRequestHeader{ | |
| 175 | - DatabaseID: *generateRandomDatabaseID(), | ||
| 174 | + DatabaseID: generateRandomDatabaseID(), | ||
| 176 | 175 | LowBlock: generateRandomHash(), | |
| 177 | 176 | LowHeight: rand.Int31(), | |
| 178 | 177 | HighBlock: generateRandomHash(), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments