Exemplo n.º 1
0
/* u2_ds_mine(): 
**
**   Register and/or save core.
*/
u2_noun                                                           //  transfer
u2_ds_mine(u2_wire wir_r,
           u2_noun clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_noun bas_r = u2_wire_bas_r(wir_r);

  if ( u2_no == u2_dust(cor) ) {
    return cor;
  } else {
    u2_noun pay = u2_t(cor);
    u2_noun bat = u2_h(cor);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat);
    u2_noun xip, bat_xip;
    u2_noun gop;

    if ( u2_none == pug ) {
      pug = u2_nul;
    }
    if ( u2_none == (xip = _ds_scan(pug, cor)) ) {
      gop = u2_rc(bas_r, (xip = _ds_chip(wir_r, clu, cor)), u2_rx(bas_r, pug));

      if ( u2_none == gop ) {
        return cor;
      } else {
        bat_xip = u2_h(u2_t(xip));

        // {c3_c* xip_c=u2_ho_cstring(xip); printf("%s\n", xip_c); free(xip_c);}
        gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop);
        u2_rz(bas_r, gop);
      }
    }
    else bat_xip = u2_h(u2_t(xip));

    if ( bat_xip != bat ) {
      u2_noun cyr = u2_rc(wir_r, u2_rx(wir_r, pay), bat_xip);

      if ( u2_none == cyr ) {
        return cor;
      }
      else {
        u2_rz(wir_r, cor);
        return cyr;
      }
    }
    else return cor;
  }
}
Exemplo n.º 2
0
/* u2_ds_find(): find chip by core, or none.
*/
u2_weak                                                           //  senior
u2_ds_find(u2_wire wir_r,
           u2_noun cor)                                           //  retain
{
  if ( u2_no == u2_dust(cor) ) {
    return u2_none;
  } else {
    u2_rail bas_r = u2_wire_bas_r(wir_r);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, u2_h(cor));

    if ( u2_none == pug ) {
      return u2_none;
    }
    else return _ds_scan(pug, cor);
  }
}
Exemplo n.º 3
0
Arquivo: dash.c Projeto: MacTop/urbit
/* u2_ds_find(): find chip by core, or none.
*/
u2_weak                                                           //  senior
u2_ds_find(u2_wire wir_r,
           u2_noun cor)                                           //  retain
{
  if ( u2_no == u2_dust(cor) ) {
    return u2_none;
  } else {
    u2_rail bas_r = u2_wire_bas_r(wir_r);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, u2_h(cor));
    u2_noun out;

    if ( u2_none == pug ) {
      out = u2_none;
    }
    else out = _ds_scan(pug, cor);

#if 0
    if ( (u2_none == out) && (u2_none != pug) ) {
      fprintf(stderr, "half match\r\n");
    }
#endif
    return out;
  }
}
Exemplo n.º 4
0
Arquivo: dash.c Projeto: MacTop/urbit
/* u2_ds_mine():
**
**   Register and/or save core.
*/
u2_noun                                                           //  transfer
u2_ds_mine(u2_wire wir_r,
           u2_noun clu,                                           //  retain
           u2_noun cor)                                           //  transfer
{
  u2_noun bas_r = u2_wire_bas_r(wir_r);

  if ( u2_no == u2_dust(cor) ) {
    return cor;
  } else {
    u2_noun pay = u2_t(cor);
    u2_noun bat = u2_h(cor);
    u2_noun pug = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat);
    u2_noun xip, bat_xip;
    u2_noun gop;

    if ( u2_none == pug ) {
      pug = u2_nul;
    }
    if ( u2_none == (xip = _ds_scan(pug, cor)) ) {
      gop = u2_rc(bas_r, (xip = _ds_chip(wir_r, clu, cor)), u2_rx(bas_r, pug));

      if ( u2_none == gop ) {
        return cor;
      } else {
        bat_xip = u2_h(u2_t(xip));

#if 0
        {
          c3_c* xip_c = u2_ho_cstring(xip);

          fprintf(stderr, "!%s - lent %d\r\n", xip_c, u2_ckb_lent(gop));
          free(xip_c);
        }
#endif
        gop = u2_cs_save(bas_r, u2_wire_des_r(wir_r), 0, bat_xip, gop);
        {
          u2_noun poo = u2_cs_find(bas_r, u2_wire_des_r(wir_r), 0, bat_xip);

          {
            _ds_scan(poo, cor);
          }
        }
        u2_rz(bas_r, gop);

      }
    }
    else {
      bat_xip = u2_h(u2_t(xip));
    }

    if ( bat_xip != bat ) {
      u2_noun cyr = u2_rc(wir_r, bat_xip, u2_rx(wir_r, pay));

      if ( u2_none == cyr ) {
        return cor;
      }
      else {
        u2_rz(wir_r, cor);
        return cyr;
      }
    }
    else return cor;
  }
}