Skip to content

Commit

Permalink
Merge pull request #146 from 4Ykw/hive-engine
Browse files Browse the repository at this point in the history
Hive engine - Add NATed-ports customization feature for witness management
  • Loading branch information
bt-cryptomancer authored Jun 11, 2022
2 parents 5432f8c + 49d7714 commit 0f24ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ACTIVE_SIGNING_KEY=5K...
ACCOUNT=acc...
NODE_IP=...
# If your public ports are different from your node config.js ports (requires NAT/port forwarding)
#RPCNODEPORT=15000
#P2PPORT=15001
12 changes: 8 additions & 4 deletions witness_action.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const {
rpcNodePort, p2pPort, streamNodes, chainId,
} = config;

// For external NATed-ports customization
const extRPCNodePort = Number(String(process.env.RPCNODEPORT)) || rpcNodePort;
const extP2PPort = Number(String(process.env.P2PPORT)) || p2pPort;

function broadcastWitnessAction(contractAction, contractPayload) {
const client = new dhive.Client(streamNodes[0]);
const transaction = {
Expand Down Expand Up @@ -46,8 +50,8 @@ program
.command('register')
.action(() => broadcastWitnessAction('register', {
IP: ip,
RPCPort: rpcNodePort,
P2PPort: p2pPort,
RPCPort: extRPCNodePort,
P2PPort: extP2PPort,
signingKey: publicSigningKey,
enabled: true,
}));
Expand All @@ -56,8 +60,8 @@ program
.command('unregister')
.action(() => broadcastWitnessAction('register', {
IP: ip,
RPCPort: rpcNodePort,
P2PPort: p2pPort,
RPCPort: extRPCNodePort,
P2PPort: extP2PPort,
signingKey: publicSigningKey,
enabled: false,
}));
Expand Down

0 comments on commit 0f24ae2

Please sign in to comment.