mirror of
https://github.com/status-im/snt-gas-relay.git
synced 2025-01-27 14:44:47 +00:00
Changes for heartbeat
This commit is contained in:
parent
9df77d5b30
commit
e77846b429
@ -25,6 +25,10 @@ class ContractSettings {
|
||||
}
|
||||
}
|
||||
|
||||
getTokens(){
|
||||
return this.tokens;
|
||||
}
|
||||
|
||||
getToken(token){
|
||||
return this.tokens[token];
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const ContractSettings = require('./contract-settings');
|
||||
const MessageProcessor = require('./message-processor');
|
||||
|
||||
|
||||
// TODO A node should call an API (probably from a status node) to register itself as a
|
||||
// IDEA: A node should call an API (probably from a status node) to register itself as a
|
||||
// token gas relayer.
|
||||
|
||||
console.info("Starting...");
|
||||
@ -64,14 +64,15 @@ events.on('setup:complete', (settings) => {
|
||||
|
||||
|
||||
if(config.heartbeat.enabled){
|
||||
|
||||
let heartbeatSymKeyId;
|
||||
web3.shh.addSymKey(config.heartbeat.symKey)
|
||||
.then(heartbeatSymKeyId => {
|
||||
|
||||
// TODO: define minPriceAccepted
|
||||
let heartbeatPayload = {
|
||||
'minPriceAccepted': 0
|
||||
}
|
||||
for(let tokenAddress in settings.getTokens()){
|
||||
|
||||
let heartbeatPayload = settings.getToken(tokenAddress);
|
||||
heartbeatPayload.address = tokenAddress;
|
||||
|
||||
setInterval(() => {
|
||||
web3.shh.post({
|
||||
@ -80,11 +81,12 @@ events.on('setup:complete', (settings) => {
|
||||
ttl: config.node.whisper.ttl,
|
||||
powTarget:config.node.whisper.minPow,
|
||||
powTime: config.node.whisper.powTime,
|
||||
// TODO: topic must be a combination of heartbeat + token
|
||||
topic: web3.utils.toHex("relay-heartbeat").slice(0, 10),
|
||||
topic: web3.utils.toHex("relay-heartbeat-" + heartbeatPayload.symbol).slice(0, 10),
|
||||
payload: web3.utils.toHex(JSON.stringify(heartbeatPayload))
|
||||
}).catch(console.error);
|
||||
}, 1000);
|
||||
}, 60000);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user