Skip to content

Commit

Permalink
Horizon: remove fields scheduled for removal in 0.17.0 (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekn authored Feb 26, 2019
1 parent 839b7ca commit 575707e
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 32 deletions.
38 changes: 16 additions & 22 deletions protocols/horizon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,11 @@ type Ledger struct {
Payments hal.Link `json:"payments"`
Effects hal.Link `json:"effects"`
} `json:"_links"`
ID string `json:"id"`
PT string `json:"paging_token"`
Hash string `json:"hash"`
PrevHash string `json:"prev_hash,omitempty"`
Sequence int32 `json:"sequence"`
// Deprecated - remove in: horizon-v0.17.0
TransactionCount int32 `json:"transaction_count"`
ID string `json:"id"`
PT string `json:"paging_token"`
Hash string `json:"hash"`
PrevHash string `json:"prev_hash,omitempty"`
Sequence int32 `json:"sequence"`
SuccessfulTransactionCount int32 `json:"successful_transaction_count"`
FailedTransactionCount *int32 `json:"failed_transaction_count"`
OperationCount int32 `json:"operation_count"`
Expand Down Expand Up @@ -247,25 +245,21 @@ type Root struct {
Transactions hal.Link `json:"transactions"`
} `json:"_links"`

HorizonVersion string `json:"horizon_version"`
StellarCoreVersion string `json:"core_version"`
HorizonSequence int32 `json:"history_latest_ledger"`
HistoryElderSequence int32 `json:"history_elder_ledger"`
CoreSequence int32 `json:"core_latest_ledger"`
NetworkPassphrase string `json:"network_passphrase"`
// Deprecated - remove in: horizon-v0.17.0
ProtocolVersion int32 `json:"protocol_version"`
CurrentProtocolVersion int32 `json:"current_protocol_version"`
CoreSupportedProtocolVersion int32 `json:"core_supported_protocol_version"`
HorizonVersion string `json:"horizon_version"`
StellarCoreVersion string `json:"core_version"`
HorizonSequence int32 `json:"history_latest_ledger"`
HistoryElderSequence int32 `json:"history_elder_ledger"`
CoreSequence int32 `json:"core_latest_ledger"`
NetworkPassphrase string `json:"network_passphrase"`
CurrentProtocolVersion int32 `json:"current_protocol_version"`
CoreSupportedProtocolVersion int32 `json:"core_supported_protocol_version"`
}

// Signer represents one of an account's signers.
type Signer struct {
// Deprecated - remove in: horizon-v0.17.0
PublicKey string `json:"public_key"`
Weight int32 `json:"weight"`
Key string `json:"key"`
Type string `json:"type"`
Weight int32 `json:"weight"`
Key string `json:"key"`
Type string `json:"type"`
}

// Trade represents a horizon digested trade
Expand Down
2 changes: 1 addition & 1 deletion services/bifrost/stellar/account_configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (ac *AccountConfigurator) signerExistsOnly(account horizon.Account) bool {
tempSignerFound := false

for _, signer := range account.Signers {
if signer.PublicKey == ac.signerPublicKey {
if signer.Key == ac.signerPublicKey {
if signer.Weight == 1 {
tempSignerFound = true
}
Expand Down
2 changes: 0 additions & 2 deletions services/horizon/internal/actions_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestLedgerActions_Show(t *testing.T) {
if ht.Assert.NoError(err) {
ht.Assert.Equal(int32(2), result.Sequence)
ht.Assert.NotEmpty(result.HeaderXDR)
ht.Assert.Equal(int32(3), result.TransactionCount)
ht.Assert.Equal(int32(3), result.SuccessfulTransactionCount)
ht.Assert.Equal(int32(0), *result.FailedTransactionCount)
}
Expand All @@ -58,7 +57,6 @@ func TestLedgerActions_Show(t *testing.T) {
if ht.Assert.NoError(err) {
ht.Assert.Equal(int32(2), result.Sequence)
ht.Assert.NotEmpty(result.HeaderXDR)
ht.Assert.Equal(int32(3), result.TransactionCount)
ht.Assert.Equal(int32(3), result.SuccessfulTransactionCount)
ht.Assert.Nil(result.FailedTransactionCount)
}
Expand Down
1 change: 0 additions & 1 deletion services/horizon/internal/actions_root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func TestRootAction(t *testing.T) {
ht.Require.NoError(err)
ht.Assert.Equal("test-horizon", actual.HorizonVersion)
ht.Assert.Equal("test-core", actual.StellarCoreVersion)
ht.Assert.Equal(int32(3), actual.ProtocolVersion)
ht.Assert.Equal(int32(4), actual.CoreSupportedProtocolVersion)
ht.Assert.Equal(int32(3), actual.CurrentProtocolVersion)
}
Expand Down
1 change: 0 additions & 1 deletion services/horizon/internal/resourceadapter/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func PopulateLedger(ctx context.Context, dest *Ledger, row history.Ledger) {
dest.Hash = row.LedgerHash
dest.PrevHash = row.PreviousLedgerHash.String
dest.Sequence = row.Sequence
dest.TransactionCount = row.TransactionCount
// Default to `transaction_count`
dest.SuccessfulTransactionCount = row.TransactionCount
if row.SuccessfulTransactionCount != nil {
Expand Down
1 change: 0 additions & 1 deletion services/horizon/internal/resourceadapter/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func PopulateRoot(
dest.HorizonVersion = hVersion
dest.StellarCoreVersion = cVersion
dest.NetworkPassphrase = passphrase
dest.ProtocolVersion = currentProtocolVersion
dest.CurrentProtocolVersion = currentProtocolVersion
dest.CoreSupportedProtocolVersion = coreSupportedProtocolVersion

Expand Down
6 changes: 2 additions & 4 deletions services/horizon/internal/resourceadapter/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import (
// Populate fills out the fields of the signer, using one of an account's
// secondary signers.
func PopulateSigner(ctx context.Context, dest *Signer, row core.Signer) {
dest.PublicKey = row.Publickey
dest.Weight = row.Weight
dest.Key = row.Publickey
dest.Type = MustKeyTypeFromAddress(dest.PublicKey)
dest.Type = MustKeyTypeFromAddress(dest.Key)
}

// PopulateMaster fills out the fields of the signer, using a stellar account to
// provide the data.
func PopulateMasterSigner(dest *Signer, row core.Account) {
dest.PublicKey = row.Accountid
dest.Weight = int32(row.Thresholds[0])
dest.Key = row.Accountid
dest.Type = MustKeyTypeFromAddress(dest.PublicKey)
dest.Type = MustKeyTypeFromAddress(dest.Key)
}

0 comments on commit 575707e

Please sign in to comment.