Skip to content

Commit

Permalink
refactor node id, remove cluster node concept, phantom payment test
Browse files Browse the repository at this point in the history
  • Loading branch information
johncantrell97 committed Oct 4, 2022
1 parent 45b6785 commit 7fc870e
Show file tree
Hide file tree
Showing 20 changed files with 281 additions and 663 deletions.
95 changes: 0 additions & 95 deletions entity/src/cluster_node.rs

This file was deleted.

1 change: 0 additions & 1 deletion entity/src/lib.rs
Expand Up @@ -5,7 +5,6 @@ pub use sea_orm;
pub mod prelude;

pub mod access_token;
pub mod cluster_node;
pub mod keychain;
pub mod kv_store;
pub mod macaroon;
Expand Down
10 changes: 0 additions & 10 deletions entity/src/node.rs
Expand Up @@ -54,7 +54,6 @@ pub struct Model {
pub network: String,
pub listen_addr: String,
pub listen_port: i32,
pub pubkey: String,
pub created_at: i64,
pub updated_at: i64,
pub status: i16,
Expand Down Expand Up @@ -86,7 +85,6 @@ pub enum Column {
Network,
ListenAddr,
ListenPort,
Pubkey,
CreatedAt,
UpdatedAt,
Status,
Expand Down Expand Up @@ -118,7 +116,6 @@ impl ColumnTrait for Column {
Self::Network => ColumnType::String(None).def(),
Self::ListenAddr => ColumnType::String(None).def(),
Self::ListenPort => ColumnType::Integer.def(),
Self::Pubkey => ColumnType::String(None).def().unique(),
Self::CreatedAt => ColumnType::BigInteger.def(),
Self::UpdatedAt => ColumnType::BigInteger.def(),
Self::Status => ColumnType::SmallInteger.def(),
Expand All @@ -133,13 +130,6 @@ impl RelationTrait for Relation {
}

impl ActiveModelBehavior for ActiveModel {
fn new() -> Self {
Self {
id: ActiveValue::Set(Uuid::new_v4().to_string()),
..<Self as ActiveModelTrait>::default()
}
}

fn before_save(mut self, insert: bool) -> Result<Self, DbErr> {
let now: i64 = seconds_since_epoch();
self.updated_at = ActiveValue::Set(now);
Expand Down
6 changes: 6 additions & 0 deletions entity/src/payment.rs
Expand Up @@ -21,6 +21,8 @@ pub struct Model {
pub origin: String,
pub created_at: i64,
pub updated_at: i64,
pub created_by_node_id: String,
pub received_by_node_id: Option<String>,
pub amt_msat: Option<i64>,
pub fee_paid_msat: Option<i64>,
pub preimage: Option<String>,
Expand All @@ -33,6 +35,8 @@ pub struct Model {
pub enum Column {
Id,
NodeId,
CreatedByNodeId,
ReceivedByNodeId,
PaymentHash,
Preimage,
Secret,
Expand Down Expand Up @@ -67,11 +71,13 @@ impl ColumnTrait for Column {
match self {
Self::Id => ColumnType::String(None).def(),
Self::NodeId => ColumnType::String(None).def(),
Self::CreatedByNodeId => ColumnType::String(None).def(),
Self::PaymentHash => ColumnType::String(None).def(),
Self::Status => ColumnType::String(None).def(),
Self::Origin => ColumnType::String(None).def(),
Self::CreatedAt => ColumnType::BigInteger.def(),
Self::UpdatedAt => ColumnType::BigInteger.def(),
Self::ReceivedByNodeId => ColumnType::String(None).def().null(),
Self::AmtMsat => ColumnType::BigInteger.def().null(),
Self::FeePaidMsat => ColumnType::BigInteger.def().null(),
Self::Preimage => ColumnType::String(None).def().null(),
Expand Down
2 changes: 0 additions & 2 deletions migration/src/lib.rs
Expand Up @@ -12,7 +12,6 @@ mod m20220428_000004_create_keychains_table;
mod m20220616_000001_create_peers_table;
mod m20220701_000001_create_peer_addresses_table;
mod m20220808_000001_create_users_table;
mod m20221003_000001_create_cluster_nodes_table;

pub struct Migrator;

Expand All @@ -33,7 +32,6 @@ impl MigratorTrait for Migrator {
Box::new(m20220616_000001_create_peers_table::Migration),
Box::new(m20220701_000001_create_peer_addresses_table::Migration),
Box::new(m20220808_000001_create_users_table::Migration),
Box::new(m20221003_000001_create_cluster_nodes_table::Migration),
]
}
}
4 changes: 1 addition & 3 deletions migration/src/m20220421_000001_create_nodes_table.rs
Expand Up @@ -27,7 +27,6 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Node::Network).string().not_null())
.col(ColumnDef::new(Node::ListenAddr).string().not_null())
.col(ColumnDef::new(Node::ListenPort).integer().not_null())
.col(ColumnDef::new(Node::Pubkey).string().not_null())
.col(ColumnDef::new(Node::CreatedAt).big_integer().not_null())
.col(ColumnDef::new(Node::UpdatedAt).big_integer().not_null())
.col(ColumnDef::new(Node::Status).small_integer().not_null())
Expand All @@ -45,15 +44,14 @@ impl MigrationTrait for Migration {

#[derive(Iden)]
enum Node {
Table,
Id,
Table,
Role,
Username,
Alias,
Network,
ListenAddr,
ListenPort,
Pubkey,
CreatedAt,
UpdatedAt,
Status,
Expand Down
5 changes: 4 additions & 1 deletion migration/src/m20220424_000003_create_payments_table.rs
Expand Up @@ -24,6 +24,8 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Payment::CreatedAt).big_integer().not_null())
.col(ColumnDef::new(Payment::UpdatedAt).big_integer().not_null())
.col(ColumnDef::new(Payment::NodeId).string().not_null())
.col(ColumnDef::new(Payment::ReceivedByNodeId).string())
.col(ColumnDef::new(Payment::CreatedByNodeId).string().not_null())
.col(ColumnDef::new(Payment::PaymentHash).string().not_null())
.col(ColumnDef::new(Payment::Preimage).string())
.col(ColumnDef::new(Payment::Secret).string())
Expand All @@ -44,7 +46,6 @@ impl MigrationTrait for Migration {
.name("idx-nodeid-paymenthash")
.col(Payment::NodeId)
.col(Payment::PaymentHash)
.unique()
.to_owned(),
)
.await
Expand All @@ -62,6 +63,8 @@ enum Payment {
Table,
Id,
NodeId,
ReceivedByNodeId,
CreatedByNodeId,
PaymentHash,
Preimage,
Secret,
Expand Down
76 changes: 0 additions & 76 deletions migration/src/m20221003_000001_create_cluster_nodes_table.rs

This file was deleted.

13 changes: 10 additions & 3 deletions proto/sensei.proto
Expand Up @@ -30,6 +30,7 @@ service Node {
rpc Keysend (KeysendRequest) returns (KeysendResponse);
rpc CreateInvoice (CreateInvoiceRequest) returns (CreateInvoiceResponse);
rpc CreatePhantomInvoice (CreatePhantomInvoiceRequest) returns (CreatePhantomInvoiceResponse);
rpc GetPhantomRouteHints (GetPhantomRouteHintsRequest) returns (GetPhantomRouteHintsResponse);
rpc LabelPayment (LabelPaymentRequest) returns (LabelPaymentResponse);
rpc DeletePayment (DeletePaymentRequest) returns (DeletePaymentResponse);
rpc ConnectPeer (ConnectPeerRequest) returns (ConnectPeerResponse);
Expand All @@ -45,9 +46,6 @@ service Node {
rpc ListKnownPeers (ListKnownPeersRequest) returns (ListKnownPeersResponse);
rpc AddKnownPeer (AddKnownPeerRequest) returns (AddKnownPeerResponse);
rpc RemoveKnownPeer (RemoveKnownPeerRequest) returns (RemoveKnownPeerResponse);
rpc ListClusterNodes (ListClusterNodesRequest) returns (ListClusterNodesResponse);
rpc AddClusterNode (AddClusterNodeRequest) returns (AddClusterNodeResponse);
rpc RemoveClusterNode (RemoveClusterNodeRequest) returns (RemoveClusterNodeResponse);
}

message ListNode {
Expand Down Expand Up @@ -340,11 +338,17 @@ message CreateInvoiceResponse {
message CreatePhantomInvoiceRequest {
uint64 amt_msat = 1;
string description = 2;
repeated string phantom_route_hints_hex = 3;
}
message CreatePhantomInvoiceResponse {
string invoice = 1;
}

message GetPhantomRouteHintsRequest {}
message GetPhantomRouteHintsResponse {
string phantom_route_hints_hex = 1;
}

message ConnectPeerRequest {
string node_connection_string = 1;
}
Expand Down Expand Up @@ -389,6 +393,9 @@ message Payment {
string origin = 7;
optional string label = 8;
optional string invoice = 9;
string created_by_node_id = 10;
optional string received_by_node_id = 11;
string node_id = 12;
}

message PaymentsFilter {
Expand Down

0 comments on commit 7fc870e

Please sign in to comment.