How to create a private bitcoin network using bitcore? - bitcoin

I'm trying to create a private bitcoin network using bitcore. But bitcore sync's data either with bitcoin livenet or testnet. I couldn;t find any bitcore documentation which will allow me to create a network from scratch.
I followed the instruction from below link
https://bitcore.io/guides/full-node
{
"network": "livenet" or "testnet" || what do i have to put for private network?
"port": 3001,
"https": true
}

I think you need to add your custom info in the bitcore-node.json which is created in your node directory
{
"network": "livenet", // your coins network name
"port": 3001, // your coins port
"services": [
"bitcoind", // required services
"web"
],
"servicesConfig": {
"bitcoind": {
"datadir": "/home/user/.bitcoin", //your coins directory
"exec": "/home/user/bitcoin/src/bitcoind" //your coins executable
}
}
}
So changing
"network": "livenet"
to whatever yours is called should do the job. Now you should be able to run your custom node with a different network.

Related

Azure IotHub download edge device configuration

I am looking for an endpoint in Azure IotHub to download the full configuration of an edge device.
{
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"modules": {...
"runtime": {...
"schemaVersion": "1.0",
"systemModules": {
"edgeAgent": {...
"edgeHub": {...
}
},
"$edgeHub": {
"properties.desired": {...
}
}
}
There is an endpoint to apply the configuration, but I just cannot find a way to access the configuration with code :-)
Can someone point me to the right direction?
Thanks
One option to query the local configuration is:
az iot hub module-twin show -n <name-of-your-hub> -d <edge-device-name> -m '$edgeAgent'
If you want to query a current status you can add --query 'properties.reported.modules'
In addition when you have the module ids you can query the module twin as well using:
az iot hub module-twin show --hub-name <name-of-your-hub> --device-id <edge-device-name> --module-id <module-name>
Hopefully it answers your question

Running multiple apps in a server hiding ports

Im developing two different chatbots and I have them on a Google Platform VM. I want to know how to access to them like this:
-> https://example.com/chatbot1
-> https://example.com/chatbot2
Instead of having:
-> https://example.com:5001
-> https://example.com:5002
I want to do that so I can run multiple chatbots on the same VM and I dont expose the ports. After doing this the idea is to insert the chatbot on a 3rd user web like this:
<script>
WebChat.default.init({
selector: "#webchat",
initPayload: "XXX",
interval: 1000,
customData: {"userId": "123"},
socketUrl: "http://example.com/chatbot1",
socketPath: "/socket.io/",
title: "XXX",
subtitle: "XXX",
inputTextFieldHint: "XXX",
connectingText: "XXX",
hideWhenNotConnected: true,
fullScreenMode: false,
showFullScreenButton: false,
profileAvatar: "xxx.jpg",
params: {
images: {
dims: {
width: 250,
height: 200,
}
},
storage: "XXX",
},
})
</script>
Both need to run through HTTPS. Do I need Apache or something similar? If this is the case, how can I configure it? I dont know if it is relevant but I only have access to the VM through SSH.
It sounds like you might want to use Apache's name-based virtual hosts (see the example under Running different sites on different ports).

iotedge: How to requeue message that could not be processed

There are publisher and consumer custom modules that are running on an Edge IoT device. The publisher module keeps producing messages at constant rate no matter consumer module processes it or not. The consumer module POSTs the message to external service and given that there is no Internet connection, the consumer module would like to requeue the messsage so that is not lost and tried again.
I do not prefer to write an infinite loop to keep retrying; also if the module is restarted the message would be lost. So i prefer to requeue the message to edgeHub/RocksDB.
Where do I find documentation on available responses that can be provided for IoTHubMessageDispositionResult? what is the response to be sent if message needs to be requeued?
if message.processed():
return IoTHubMessageDispositionResult.ACCEPTED
else:
return IoTHubMessageDispositionResult.??
You don't have to implement your own requeuing of messages. IotEdge provides offline functionality as described in this blog post and on this documentation page.
The edgeHub will locally store messages on the edgeDevice if there is no connection to the IotHub. It will automatically start sending those messages (in the correct order) once the connection is established again.
You can configure how long edgeHub will buffer messages like this:
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.0",
"routes": {},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
}
}
}
The 7200 seconds (2 hours) is also the default if you don't configure anything.
By default, the messages will be written to a folder within the edgeHub docker container. If you want to store them somewhere else you can do so with this configuration:
"edgeHub": {
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions": {
"HostConfig": {
"Binds": ["<HostStoragePath>:<ModuleStoragePath>"],
"PortBindings": {
"8883/tcp": [{"HostPort":"8883"}],
"443/tcp": [{"HostPort":"443"}],
"5671/tcp": [{"HostPort":"5671"}]
}
}
}
},
"env": {
"storageFolder": {
"value": "<ModuleStoragePath>"
}
},
"status": "running",
"restartPolicy": "always"
}
Replace HostStoragePath and ModuleStoragePath with the wanted values. Example:
"createOptions": {
"HostConfig": {
"Binds": [
"/etc/iotedge/storage/:/iotedge/storage/"
],
...
}
}
},
"env": {
"storageFolder": {
"value": "/iotedge/storage/"
},
...
Please note that you probably have to manually give the iotEdge user (or all users) access to that folder (using chmod).
Update:
If you are just looking for the available values of IoTHubMessageDispositionResult you will find the answer here:
class IoTHubMessageDispositionResult(Enum):
ACCEPTED = 0
REJECTED = 1
ABANDONED = 2
Update 2:
Messages that have been ACCEPTED are removed from the message queue because they have been successfully delivered.
Messages that are ABANDONED are added to the message queue again and the module will try to send it again as defined in the retryPolicy. For more insight on the retryPolicy you can read this thread.
Messages that are REJECTED are not added to the message queue again.

Best way to configure truffle `from` address

I'm setting up my truffle config file and I'm setting the from address from an env variable like this:
module.exports = {
networks: {
local: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
from: process.env.OWNER,
}
}
};
Then I run OWNER=<address> truffle migrate --network local
Any suggestions on a better way to do this, to get truffle to use the first address generated by ganache?
If you omit the from parameter in your truffle.cfg, it will automatically default to the first account returned by web3.eth.getAccounts from the provider you're connected to.
If you want more dynamic control over the account used, you can control this with the deployer.
var SimpleContract = artifacts.require("SimpleContract");
module.exports = function(deployer, network, accounts) {
deployer.deploy(SimpleContract, { from: accounts[1] }); // Deploy contract from the 2nd account in the list
deployer.deploy(SimpleContract, { from: accounts[2] }); // Deploy the same contract again (different address) from the 3rd account.
};
Of course, you don't have to use the account list passed in and you can pull in a list from any other data source you want. You can also use network if you want to have environment specific logic.

SoftLayer API Hardware : Fast Provision of BM Server PresetConfiguration OS

Using the Fast Provision of BM Server REST API :
http://sldn.softlayer.com/blog/bpotter/ordering-bare-metal-servers-using-softlayer-api
SoftLayer_Hardware/getCreateObjectOptions : In the response we will get fixed preset configuration,datacenter,operating system details,etc.,
When I provision using OS Reference code ESXI_5.1_64, I am getting the below mentioned error. In the request I have not mentioned networkComponents details and if i add "networkComponents": [{ "maxSpeed": 100 }], details then also i am getting the below mentioned error message.
{
"error": "VMware ESXi 5.5 cannot be ordered with 100 Mbps Public & Private Network Uplinks"
"code": "SoftLayer_Exception_Public"
}
Also if i use some of the operating system reference codes i am getting the below mentioned error.
{
"error": "Unable to match an OS with reference code: XENSERVER_6.0_64"
"code": "SoftLayer_Exception_NotFound"
}
"operatingSystemReferenceCode": "XENSERVER_6.0_64" "operatingSystemReferenceCode": "REDHAT_6_64"
1. The exception:
{ "error": "VMware ESXi 5.5 cannot be ordered with 100 Mbps Public &
Private Network Uplinks" "code": "SoftLayer_Exception_Public" }
Reason: The VMware OSes cannot be ordered with "100 Mbps Public & Private Network Uplinks" (e.g. "networkComponents": [{ "maxSpeed": 100 }]). VMware OSes must be ordered at least with "1 Gbps Public & Private Network Uplinks". (e.g. "networkComponents": [{ "maxSpeed": 1000}]).
2. The exception:
{ "error": "Unable to match an OS with reference code:
XENSERVER_6.0_64" "code": "SoftLayer_Exception_NotFound" }
Probably you are trying to order a hourly server ("hourlyBillingFlag": true), this can be the reason of the exception, because this OS is only available for Monthly billing fee.
Note: If this is not the reason ("hourlyBillingFlag": true), you can attach the code that you are trying, in order to identify the issue and provide more feedback about it.
How identify the type of billing for the items?
Using SoftLayer_Hardware::getCreateObjectOptions method, you will get a response like this:
38: {
"itemPrice": {
"hourlyRecurringFee": ".024"
"recurringFee": "17"
"item": {
"description": "Windows Server 2012 R2 Standard Edition (64 bit)"
}-
}-
"template": {
"operatingSystemReferenceCode": "WIN_2012-STD-R2_64"
}-
}
"hourlyRecurringFee" means that the item is available per hour and "recurringFee" per month. The "XENSERVER_6.0_64" item is only available for month because it only has "recurringFee" property and not "hourlyRecurringFee"property.
The OS ESXI_5.1_64 is not valid for your configured fixedConfigurationPreset (note based in your comments I assume you are using the S1270_8GB_2X1TBSATA_NORAID you did not copy your code :( ). For that preset the valid OS is ESXI_5.5_64. (VMware ESXi 5.5) So try this code:
{
"parameters": [{
"datacenter": {
"name": "dal01"
},
"hostname": "vijvmware",
"domain": "csc.com",
"hourlyBillingFlag": false,
"fixedConfigurationPreset": {
"keyName": "S1270_8GB_2X1TBSATA_NORAID"
},
"operatingSystemReferenceCode": "ESXI_5.5_64",
"networkComponents": [
{
"maxSpeed": 10
}
]
}]
}
Please keep in mind that the SoftLayer_Hardware::getCreateObjectOptions returns all the options to create bare metal, but not all the convinations of options will work, that´s up to you to create the correct configuration for that you may see the UI (Softlayer´s Portal).