Skip to content

Commit

Permalink
Remove obsolete billing protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
leventeliu committed Mar 7, 2019
1 parent 05b24c4 commit e99f434
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 1,314 deletions.
17 changes: 0 additions & 17 deletions blockproducer/metastate.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,21 +509,6 @@ func (s *metaState) increaseNonce(addr proto.AccountAddress) (err error) {
return
}

func (s *metaState) applyBilling(tx *types.Billing) (err error) {
for i, v := range tx.Receivers {
// Create empty receiver account if not found
s.loadOrStoreAccountObject(*v, &types.Account{Address: *v})

if err = s.increaseAccountCovenantBalance(*v, tx.Fees[i]); err != nil {
return
}
if err = s.increaseAccountStableBalance(*v, tx.Rewards[i]); err != nil {
return
}
}
return
}

func (s *metaState) updateProviderList(tx *types.ProvideService) (err error) {
sender, err := crypto.PubKeyHash(tx.Signee)
if err != nil {
Expand Down Expand Up @@ -1135,8 +1120,6 @@ func (s *metaState) applyTransaction(tx pi.Transaction) (err error) {
err = s.transferAccountToken(t)
}
return
case *types.Billing:
err = s.applyBilling(t)
case *types.BaseAccount:
err = s.storeBaseAccount(t.Address, &t.Account)
case *types.ProvideService:
Expand Down
51 changes: 15 additions & 36 deletions blockproducer/metastate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,12 @@ func TestMetaState(t *testing.T) {
Amount: 0,
},
)
t2 = types.NewBilling(
&types.BillingHeader{
Nonce: 2,
Producer: addr1,
Receivers: []*proto.AccountAddress{&addr2},
Fees: []uint64{1},
Rewards: []uint64{1},
t2 = types.NewTransfer(
&types.TransferHeader{
Sender: addr1,
Receiver: addr2,
Nonce: 2,
Amount: 0,
},
)
)
Expand Down Expand Up @@ -557,53 +556,35 @@ func TestMetaState(t *testing.T) {
Amount: 10,
},
),
types.NewBilling(
&types.BillingHeader{
Nonce: 2,
Producer: addr1,
Receivers: []*proto.AccountAddress{&addr2},
Fees: []uint64{1},
Rewards: []uint64{1},
},
),
types.NewBilling(
&types.BillingHeader{
Nonce: 1,
Producer: addr2,
Receivers: []*proto.AccountAddress{&addr1},
Fees: []uint64{1},
Rewards: []uint64{1},
},
),
types.NewTransfer(
&types.TransferHeader{
Sender: addr2,
Receiver: addr1,
Nonce: 2,
Nonce: 1,
Amount: 1,
},
),
types.NewTransfer(
&types.TransferHeader{
Sender: addr1,
Receiver: addr2,
Nonce: 3,
Nonce: 2,
Amount: 10,
},
),
types.NewTransfer(
&types.TransferHeader{
Sender: addr2,
Receiver: addr1,
Nonce: 3,
Nonce: 2,
Amount: 1,
},
),
types.NewTransfer(
&types.TransferHeader{
Sender: addr2,
Receiver: addr1,
Nonce: 4,
Nonce: 3,
Amount: 1,
},
),
Expand All @@ -612,12 +593,10 @@ func TestMetaState(t *testing.T) {
txs[0].Sign(privKey1)
txs[1].Sign(privKey2)
txs[2].Sign(privKey1)
txs[3].Sign(privKey1)
txs[4].Sign(privKey2)
txs[3].Sign(privKey2)
txs[4].Sign(privKey1)
txs[5].Sign(privKey2)
txs[6].Sign(privKey1)
txs[7].Sign(privKey2)
txs[8].Sign(privKey2)
txs[6].Sign(privKey2)
for _, tx := range txs {
err = ms.apply(tx)
So(err, ShouldBeNil)
Expand All @@ -626,10 +605,10 @@ func TestMetaState(t *testing.T) {
Convey("The state should match the update result", func() {
bl, loaded = ms.loadAccountTokenBalance(addr1, types.Particle)
So(loaded, ShouldBeTrue)
So(bl, ShouldEqual, 84)
So(bl, ShouldEqual, 83)
bl, loaded = ms.loadAccountTokenBalance(addr2, types.Particle)
So(loaded, ShouldBeTrue)
So(bl, ShouldEqual, 118)
So(bl, ShouldEqual, 117)
})
})
Convey("When SQLChain are created", func() {
Expand Down
98 changes: 0 additions & 98 deletions types/billing.go

This file was deleted.

95 changes: 0 additions & 95 deletions types/billing_gen.go

This file was deleted.

Loading

0 comments on commit e99f434

Please sign in to comment.