Skip to content

Commit

Permalink
Merge pull request #164 from bancorprotocol/quickfix
Browse files Browse the repository at this point in the history
Update network.py
  • Loading branch information
mikewcasale authored Sep 19, 2022
2 parents cbe434d + ebafe6b commit d2d880b
Show file tree
Hide file tree
Showing 2 changed files with 219 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bancor_research/bancor_simulator/v3/spec/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,22 @@ def copy_state(self, copy_type: str, state: State = None, timestamp: int = 0):
ts = s.timestamp
else:
ts = timestamp
s.timestamp = timestamp
self._backup_states[f"{copy_type}_{ts}"] = s.copy()
return s

def update_state(self, state: State):
def update_state(self, state: State, timestamp: int = 0):
"""
Updates the global state at the end of each action.
"""
self.global_state = self.copy_state("end", state)
self.global_state = self.copy_state("end", state, timestamp)

def next_transaction(self, state: State):
def next_transaction(self, state: State, timestamp: int = 0):
"""
Increments a new id and state for each action
"""
if self.log_state:
self.update_state(state)
self.update_state(state, timestamp)
self.transaction_id += 1

def get_state(
Expand Down Expand Up @@ -431,6 +432,7 @@ def whitelist_token(self, tkn_name: str, timestamp: int = 0):
state = self.get_state(copy_type="initial", timestamp=timestamp)
tkn_name = tkn_name.lower()
state.price_feeds[tkn_name] = state.price_feeds["bnt"].values

state.create_whitelisted_tkn(tkn_name)
handle_whitelisting_tokens(state)

Expand Down
Loading

0 comments on commit d2d880b

Please sign in to comment.