Skip to content

Commit decd559

Browse files
Change program dependencies to common location
1 parent 9f9b764 commit decd559

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

fvm/derived/derived_block_data.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ type DerivedTransactionCommitter interface {
3737
Commit() error
3838
}
3939

40-
// ProgramDependencies are the programs' addresses used by this program.
41-
type ProgramDependencies map[common.AddressLocation]struct{}
40+
// ProgramDependencies are the programs' locations used by this program.
41+
type ProgramDependencies map[common.Location]struct{}
4242

43-
// AddDependency adds the address as a dependency.
44-
func (d ProgramDependencies) AddDependency(location common.AddressLocation) {
43+
// AddDependency adds the location as a dependency.
44+
func (d ProgramDependencies) AddDependency(location common.Location) {
4545
d[location] = struct{}{}
4646
}
4747

fvm/environment/derived_data_invalidator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestDerivedDataProgramInvalidator(t *testing.T) {
3232
programALoc := common.AddressLocation{Address: cAddressA, Name: "A"}
3333
programA := &derived.Program{
3434
Program: nil,
35-
Dependencies: map[common.AddressLocation]struct{}{
35+
Dependencies: map[common.Location]struct{}{
3636
programALoc: {},
3737
},
3838
}
@@ -42,7 +42,7 @@ func TestDerivedDataProgramInvalidator(t *testing.T) {
4242
programBLoc := common.AddressLocation{Address: cAddressB, Name: "B"}
4343
programB := &derived.Program{
4444
Program: nil,
45-
Dependencies: map[common.AddressLocation]struct{}{
45+
Dependencies: map[common.Location]struct{}{
4646
programALoc: {},
4747
programBLoc: {},
4848
},
@@ -53,7 +53,7 @@ func TestDerivedDataProgramInvalidator(t *testing.T) {
5353
programDLoc := common.AddressLocation{Address: cAddressD, Name: "D"}
5454
programD := &derived.Program{
5555
Program: nil,
56-
Dependencies: map[common.AddressLocation]struct{}{
56+
Dependencies: map[common.Location]struct{}{
5757
programDLoc: {},
5858
},
5959
}
@@ -63,7 +63,7 @@ func TestDerivedDataProgramInvalidator(t *testing.T) {
6363
programCLoc := common.AddressLocation{Address: cAddressC, Name: "C"}
6464
programC := &derived.Program{
6565
Program: nil,
66-
Dependencies: map[common.AddressLocation]struct{}{
66+
Dependencies: map[common.Location]struct{}{
6767
// C indirectly depends on A trough B
6868
programALoc: {},
6969
programBLoc: {},

fvm/environment/programs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (loader *programLoader) loadWithDependencyTracking(
277277
// (because A also depends on everything B depends on)
278278
// - set(A): pop A, getting all the collected dependencies for A
279279
type dependencyTracker struct {
280-
location common.AddressLocation
280+
location common.Location
281281
dependencies derived.ProgramDependencies
282282
}
283283

@@ -295,7 +295,7 @@ func newDependencyStack() *dependencyStack {
295295

296296
// push a new location to track dependencies for.
297297
// it is assumed that the dependencies will be loaded before the program is set and pop is called.
298-
func (s *dependencyStack) push(loc common.AddressLocation) {
298+
func (s *dependencyStack) push(loc common.Location) {
299299
dependencies := make(derived.ProgramDependencies, 1)
300300

301301
// A program is listed as its own dependency.
@@ -320,9 +320,9 @@ func (s *dependencyStack) addDependencies(dependencies derived.ProgramDependenci
320320
}
321321

322322
// pop the last dependencies on the stack and return them.
323-
func (s *dependencyStack) pop() (common.AddressLocation, derived.ProgramDependencies, error) {
323+
func (s *dependencyStack) pop() (common.Location, derived.ProgramDependencies, error) {
324324
if len(s.trackers) == 0 {
325-
return common.AddressLocation{},
325+
return nil,
326326
nil,
327327
fmt.Errorf("cannot pop the programs dependency stack, because it is empty")
328328
}

0 commit comments

Comments
 (0)