From d127b993726707005ee1d93f42a7ec652f81ce32 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiil.ru> Date: Fri, 21 Dec 2018 10:45:29 +0100 Subject: [PATCH] Added a method for default exchange --- src/opensesim/world/GodWorld.java | 19 ++++++++++++++++--- src/opensesim/world/RealWorld.java | 5 +++++ src/opensesim/world/World.java | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/opensesim/world/GodWorld.java b/src/opensesim/world/GodWorld.java index 50fb052..10d8a86 100644 --- a/src/opensesim/world/GodWorld.java +++ b/src/opensesim/world/GodWorld.java @@ -211,12 +211,27 @@ public class GodWorld implements GetJson, World { return a; } - HashMap exchanges = new HashMap<>(); + // -------------------------------------------------------------------- + // Exchanges in our world + // -------------------------------------------------------------------- + + private final HashMap exchanges = new HashMap<>(); + private Exchange default_exchange = null; public void createExchange(JSONObject cfg) { Exchange ex = new Exchange(this.getWorld(), cfg); exchanges.put(ex.getSymbol(), ex); + if (default_exchange == null) { + default_exchange = ex; + } } + + public Exchange getDefaultExchange(){ + return default_exchange; + } + + + @Override public Collection getExchangeCollection() { @@ -366,8 +381,6 @@ public class GodWorld implements GetJson, World { // -------------------------------------------------------------------- // Stuff belonging to accounts // -------------------------------------------------------------------- - - // -------------------------------------------------------------------- // Pseudo random generator stuff // -------------------------------------------------------------------- diff --git a/src/opensesim/world/RealWorld.java b/src/opensesim/world/RealWorld.java index d996662..4355b7d 100644 --- a/src/opensesim/world/RealWorld.java +++ b/src/opensesim/world/RealWorld.java @@ -75,4 +75,9 @@ public class RealWorld implements World { return godworld.currentTimeMillis(); } + @Override + public Exchange getDefaultExchange() { + return godworld.getDefaultExchange(); + } + } diff --git a/src/opensesim/world/World.java b/src/opensesim/world/World.java index 920525d..0b056b2 100644 --- a/src/opensesim/world/World.java +++ b/src/opensesim/world/World.java @@ -40,6 +40,8 @@ public interface World { public AbstractAsset getAssetBySymbol(String symbol); Collection getExchangeCollection(); + + public Exchange getDefaultExchange(); Collection getTradersCollection();