Skip to content

Commit

Permalink
feat: add remove_node and add_node RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Aug 20, 2020
1 parent 6cfced3 commit d943de2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/ckb/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,17 @@ def set_network_active(state)
rpc.set_network_active(state)
end

# @param peer_id [String]
# @param address [String]
# @return nil
def add_node(peer_id:, address:)
rpc.add_node(peer_id, address)
end

def remove_node(peer_id)
rpc.remove_node(peer_id)
end

def inspect
"\#<API@#{rpc.uri}>"
end
Expand Down
10 changes: 10 additions & 0 deletions spec/ckb/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,14 @@
result = api.set_network_active(true)
expect(result).to be_nil
end

it "add_node should return nil" do
result = api.add_node(peer_id: "QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS", address: "/ip4/192.168.2.100/tcp/8114")
expect(result).to be_nil
end

it "remove_node should return nil" do
result = api.remove_node("QmUsZHPbjjzU627UZFt4k8j6ycEcNvXRnVGxCPKqwbAfQS")
expect(result).to be_nil
end
end

0 comments on commit d943de2

Please sign in to comment.