コード例 #1
0
ファイル: JDBCCoreNode.java プロジェクト: eamonnmag/Peergos
  @Override
  public boolean followRequest(UserPublicKey owner, byte[] encryptedPermission) {
    byte[] dummy = null;
    FollowRequestData selector = new FollowRequestData(owner, dummy);
    RowData[] requests = selector.select();
    if (requests != null && requests.length > CoreNode.MAX_PENDING_FOLLOWERS) return false;
    // ToDo add a crypto currency transaction to prevent spam

    FollowRequestData request = new FollowRequestData(owner, encryptedPermission);
    return request.insert();
  }
コード例 #2
0
ファイル: JDBCCoreNode.java プロジェクト: eamonnmag/Peergos
  @Override
  public byte[] getFollowRequests(UserPublicKey owner) {
    byte[] dummy = null;
    FollowRequestData request = new FollowRequestData(owner, dummy);
    RowData[] requests = request.select();
    if (requests == null) return new byte[4];

    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    DataOutput dout = new DataOutputStream(bout);
    try {
      dout.writeInt(requests.length);
      for (RowData req : requests) Serialize.serialize(req.data, dout);
      return bout.toByteArray();
    } catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }