universome / aladdin

A betting arbitrage bot
3 stars 0 forks source link

betway: unwrap None #145

Closed loyd closed 7 years ago

loyd commented 7 years ago
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', ../src/libcore/option.rs:317
stack backtrace:
   1:     0x7fc475e92a23 - std::sys::backtrace::tracing::imp::write::h4b09e6e8c01db097
   2:     0x7fc475e9702d - std::panicking::default_hook::{{closure}}::h1d3243f546573ff4
   3:     0x7fc475e962ba - std::panicking::default_hook::h96c288d728df3ebf
   4:     0x7fc475e968b8 - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   5:     0x7fc475e96752 - std::panicking::begin_panic::hfbeda5aad583dc32
   6:     0x7fc475e96690 - std::panicking::begin_panic_fmt::h4fe9fb9d5109c4bf
   7:     0x7fc475e96611 - rust_begin_unwind
   8:     0x7fc475ed294f - core::panicking::panic_fmt::h4395919ece15c671
   9:     0x7fc475ed287b - core::panicking::panic::hc74ff52ed78364e1
  10:     0x7fc47552be76 - <core::option::Option<T>>::unwrap::h76419f1a5ac86c62
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/macros.rs:21
  11:     0x7fc475a7d71d - <aladdin::gamblers::betway::BetWay as aladdin::gamblers::Gambler>::place_bet::h10690dc6449e21db
                        at /home/workspace/aladdin/src/gamblers/betway.rs:196
  12:     0x7fc475ad8ccb - aladdin::arbitrer::bookie::Bookie::place_bet::ha3d7af832a7248ae
                        at /home/workspace/aladdin/src/arbitrer/bookie.rs:188
  13:     0x7fc475ae4288 - aladdin::arbitrer::place_bet::hefedbcf066e3e804
                        at /home/workspace/aladdin/src/arbitrer/mod.rs:403
  14:     0x7fc475b01d5a - aladdin::arbitrer::place_bets::{{closure}}::hec60666d28857fe7
                        at /home/workspace/aladdin/src/arbitrer/mod.rs:304
  15:     0x7fc47599ab57 - <std::panic::AssertUnwindSafe<F> as core::ops::FnOnce<()>>::call_once::h46d91606372ff8e1
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panic.rs:255
  16:     0x7fc475579165 - std::panicking::try::do_call::h9d014ef3dfe5ec44
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:326
  17:     0x7fc475e9eaf6 - __rust_maybe_catch_panic
  18:     0x7fc475578803 - std::panicking::try::hb4588e3d50c30ab0
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:302
  19:     0x7fc47557483b - std::panic::catch_unwind::he01cb8a4ec156d88
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panic.rs:311
  20:     0x7fc475afae28 - std::thread::Builder::spawn::{{closure}}::hc5fd0ea0c526a33a
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/thread/mod.rs:277
  21:     0x7fc47561422c - <F as alloc::boxed::FnBox<A>>::call_box::hb7415c26417cdc3c

Сводится к этой строчке:

        let outcome = market.outcomes.iter().find(|o| o.get_title() == outcome.0).unwrap();
loyd commented 7 years ago

Хм. Вообще это вполне могло быть, если параллельно пришло удаление этого маркета (тогда почему упало не строчкой выше, не исход же там обновили?). Я думаю, что мы должны писать place_bet ожидая, что может прийти оффер, которого уже нет в таблицах.