Skip to content

Commit

Permalink
Replace 'SnapshotManager' to 'SnapshotApplier'.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeskov committed Jun 29, 2023
1 parent 48ea9a6 commit 54b556e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
16 changes: 0 additions & 16 deletions pkg/state/snapshot_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ import (
"github.com/wavesplatform/gowaves/pkg/ride/serialization"
)

type SnapshotApplier interface {
ApplyWavesBalance(snapshot WavesBalanceSnapshot) error
ApplyLeaseBalance(snapshot LeaseBalanceSnapshot) error
ApplyAssetBalance(snapshot AssetBalanceSnapshot) error
ApplyAlias(snapshot AliasSnapshot) error
ApplyStaticAssetInfo(snapshot StaticAssetInfoSnapshot) error
ApplyAssetDescription(snapshot AssetDescriptionSnapshot) error
ApplyAssetVolume(snapshot AssetVolumeSnapshot) error
ApplyAssetScript(snapshot AssetScriptSnapshot) error
ApplySponsorship(snapshot SponsorshipSnapshot) error
ApplyAccountScript(snapshot AccountScriptSnapshot) error
ApplyFilledVolumeAndFee(snapshot FilledVolumeFeeSnapshot) error
ApplyDataEntries(snapshot DataEntriesSnapshot) error
ApplyLeaseState(snapshot LeaseStateSnapshot) error
}

type blockSnapshotsApplier struct {
info blockSnapshotsApplierInfo
stor snapshotApplierStorages
Expand Down
34 changes: 19 additions & 15 deletions pkg/state/snapshot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,53 @@ import (

type TransactionSnapshot []AtomicSnapshot

type AtomicSnapshot interface{ Apply(SnapshotManager) error }
type AtomicSnapshot interface{ Apply(SnapshotApplier) error }

type WavesBalanceSnapshot struct {
Address proto.WavesAddress
Balance uint64
}

func (s WavesBalanceSnapshot) Apply(m SnapshotManager) error { return m.ApplyWavesBalance(s) }
func (s WavesBalanceSnapshot) Apply(a SnapshotApplier) error { return a.ApplyWavesBalance(s) }

type AssetBalanceSnapshot struct {
Address proto.WavesAddress
AssetID crypto.Digest
Balance uint64
}

func (s AssetBalanceSnapshot) Apply(m SnapshotManager) error { return m.ApplyAssetBalance(s) }
func (s AssetBalanceSnapshot) Apply(a SnapshotApplier) error { return a.ApplyAssetBalance(s) }

type DataEntriesSnapshot struct { // AccountData in pb
Address proto.WavesAddress
DataEntries []proto.DataEntry
}

func (s DataEntriesSnapshot) Apply(m SnapshotManager) error { return m.ApplyDataEntries(s) }
func (s DataEntriesSnapshot) Apply(a SnapshotApplier) error { return a.ApplyDataEntries(s) }

type AccountScriptSnapshot struct {
SenderPublicKey crypto.PublicKey
Script proto.Script
VerifierComplexity uint64
}

func (s AccountScriptSnapshot) Apply(m SnapshotManager) error { return m.ApplyAccountScript(s) }
func (s AccountScriptSnapshot) Apply(a SnapshotApplier) error { return a.ApplyAccountScript(s) }

type AssetScriptSnapshot struct {
AssetID crypto.Digest
Script proto.Script
Complexity uint64
}

func (s AssetScriptSnapshot) Apply(m SnapshotManager) error { return m.ApplyAssetScript(s) }
func (s AssetScriptSnapshot) Apply(a SnapshotApplier) error { return a.ApplyAssetScript(s) }

type LeaseBalanceSnapshot struct {
Address proto.WavesAddress
LeaseIn uint64
LeaseOut uint64
}

func (s LeaseBalanceSnapshot) Apply(m SnapshotManager) error { return m.ApplyLeaseBalance(s) }
func (s LeaseBalanceSnapshot) Apply(a SnapshotApplier) error { return a.ApplyLeaseBalance(s) }

type LeaseStateStatus struct {
Value LeaseStatus // can be only LeaseActive or LeaseCanceled
Expand All @@ -73,21 +73,21 @@ type LeaseStateSnapshot struct {
Height proto.Height
}

func (s LeaseStateSnapshot) Apply(m SnapshotManager) error { return m.ApplyLeaseState(s) }
func (s LeaseStateSnapshot) Apply(a SnapshotApplier) error { return a.ApplyLeaseState(s) }

type SponsorshipSnapshot struct {
AssetID crypto.Digest
MinSponsoredFee uint64
}

func (s SponsorshipSnapshot) Apply(m SnapshotManager) error { return m.ApplySponsorship(s) }
func (s SponsorshipSnapshot) Apply(a SnapshotApplier) error { return a.ApplySponsorship(s) }

type AliasSnapshot struct {
Address proto.WavesAddress
Alias proto.Alias
}

func (s AliasSnapshot) Apply(m SnapshotManager) error { return m.ApplyAlias(s) }
func (s AliasSnapshot) Apply(a SnapshotApplier) error { return a.ApplyAlias(s) }

// FilledVolumeFeeSnapshot Filled Volume and Fee
type FilledVolumeFeeSnapshot struct { // OrderFill
Expand All @@ -96,7 +96,7 @@ type FilledVolumeFeeSnapshot struct { // OrderFill
FilledFee uint64
}

func (s FilledVolumeFeeSnapshot) Apply(m SnapshotManager) error { return m.ApplyFilledVolumeAndFee(s) }
func (s FilledVolumeFeeSnapshot) Apply(a SnapshotApplier) error { return a.ApplyFilledVolumeAndFee(s) }

type StaticAssetInfoSnapshot struct {
AssetID crypto.Digest
Expand All @@ -106,15 +106,15 @@ type StaticAssetInfoSnapshot struct {
IsNFT bool
}

func (s StaticAssetInfoSnapshot) Apply(m SnapshotManager) error { return m.ApplyStaticAssetInfo(s) }
func (s StaticAssetInfoSnapshot) Apply(a SnapshotApplier) error { return a.ApplyStaticAssetInfo(s) }

type AssetVolumeSnapshot struct { // AssetVolume in pb
AssetID crypto.Digest
TotalQuantity big.Int // volume in protobuf
IsReissuable bool
}

func (s AssetVolumeSnapshot) Apply(m SnapshotManager) error { return m.ApplyAssetVolume(s) }
func (s AssetVolumeSnapshot) Apply(a SnapshotApplier) error { return a.ApplyAssetVolume(s) }

type AssetDescriptionSnapshot struct { // AssetNameAndDescription in pb
AssetID crypto.Digest
Expand All @@ -123,9 +123,13 @@ type AssetDescriptionSnapshot struct { // AssetNameAndDescription in pb
ChangeHeight proto.Height // last_updated in pb
}

func (s AssetDescriptionSnapshot) Apply(m SnapshotManager) error { return m.ApplyAssetDescription(s) }
func (s AssetDescriptionSnapshot) Apply(a SnapshotApplier) error { return a.ApplyAssetDescription(s) }

type SnapshotManager interface {
// SnapshotManager is an alias for SnapshotApplier.
// Deprecated: Exists only for compatibility. Will be removed later.
type SnapshotManager = SnapshotApplier

type SnapshotApplier interface {
ApplyWavesBalance(snapshot WavesBalanceSnapshot) error
ApplyLeaseBalance(snapshot LeaseBalanceSnapshot) error
ApplyAssetBalance(snapshot AssetBalanceSnapshot) error
Expand Down

0 comments on commit 54b556e

Please sign in to comment.