protected static function loadDefault(Iface $stockpile, $name, $dsn)
 {
     $db = Connection::instance($dsn);
     if (!$db instanceof \Gaia\DB\ExtendedIface) {
         $db = new \Gaia\DB($db);
     }
     if ($db->isa('mysql')) {
         $classname = 'Gaia\\Stockpile\\Storage\\MySQL\\' . $name;
     } elseif ($db->isa('sqlite')) {
         $classname = 'Gaia\\Stockpile\\Storage\\SQLite\\' . $name;
     } else {
         throw new Exception('invalid db driver', $db);
     }
     $table = $stockpile->app() . '_stockpile_' . constant($classname . '::TABLE');
     $object = new $classname($db, $table, $stockpile->user());
     if (!\Gaia\Stockpile\Storage::isAutoSchemaEnabled()) {
         return $object;
     }
     $cache = new Store\Gate(new Store\Apc());
     $key = 'stockpile/storage/__create/' . md5($dsn . '/' . Connection::version() . '/' . $table . '/' . $classname);
     if ($cache->get($key)) {
         return $object;
     }
     if (!$cache->add($key, 1, 60)) {
         return $object;
     }
     $object->create();
     return $object;
 }
 /**
  * pass in two accounts, always.
  */
 public function __construct(Iface $core, Iface $other)
 {
     parent::__construct($core);
     if (Transaction::atStart()) {
         throw $this->handle(new Exception('need transaction to transfer'));
     }
     if ($core->app() == $other->app() && $core->user() == $other->user()) {
         throw $this->handle(new Exception('need two different parties to trade'));
     }
     if ($core->coreType() == $this->coreType()) {
         throw $this->handle(new Exception('core must not be a transfer'));
     }
     if ($other->coreType() == $this->coreType()) {
         throw $this->handle(new Exception('other must not be a transfer'));
     }
     if ($core->coreType() != $other->coreType() && $core->coreType() != 'serial-tally' && $other->coreType() != 'serial-tally') {
         throw $this->handle(new Exception('both must be of same coretype in a transfer'));
     }
     $this->other = $other;
 }