How to find current a0 parameter in Cardano node - cardano

Is their any way to get current value of a0 parameter from node.
The parameters are not found in configuration file. These are not passed as parameter when the node is started.

You can get the protocol parameters using cardano-cli:
$ cardano-cli query protocol-parameters --mary-era --mainnet
{
"poolDeposit": 500000000,
"protocolVersion": {
"minor": 0,
"major": 4
},
"minUTxOValue": 1000000,
"decentralisationParam": 0.12,
"maxTxSize": 16384,
"minPoolCost": 340000000,
"minFeeA": 44,
"maxBlockBodySize": 65536,
"minFeeB": 155381,
"eMax": 18,
"extraEntropy": {
"tag": "NeutralNonce"
},
"maxBlockHeaderSize": 1100,
"keyDeposit": 2000000,
"nOpt": 500,
"rho": 3.0e-3,
"tau": 0.2,
"a0": 0.3
}
a0 is the last key in the above output.

Using the Blockfrost API you can get parameters at the time of each epoch including the a0 parameter:
https://cardano-mainnet.blockfrost.io/api/v0/epochs/{number}/parameters
API docs:
https://docs.blockfrost.io/#tag/Cardano-Epochs/paths/~1epochs~1%7Bnumber%7D~1parameters/get

Related

How to create a schedule in pagerduty using restApi and python

When through the documentation of pagerduty was but still not able to understand what parameters to send in the request body and also facing trouble in understanding how to make the api request.If any one can share the sample code on making a pagerduty schedule that would help me alot.
Below is the sample code to create schedules in PagerDuty.
Each list can have multiple items (to add more users / layers)
import requests
url = "https://api.pagerduty.com/schedules?overflow=false"
payload={
"schedule": {
"schedule_layers": [
{
"start": "<dateTime>", # Start Time of layer | "start": "2021-01-01T00:00:00+05:30",
"users": [
{
"user": {
"id": "<string>", # ID of user to add in layer
"summary": "<string>",
"type": "<string>", # "type": "user"
"self": "<url>",
"html_url": "<url>"
}
}
],
"rotation_virtual_start": "<dateTime>", # Start of layer | "rotation_virtual_start": "2021-01-01T00:00:00+05:30",
"rotation_turn_length_seconds": "<integer>", # Layer rotation, for multiple user switching | "rotation_turn_length_seconds": <seconds>,
"id": "<string>", # Auto-generated. Only needed if you want update and existing Schedule Layer
"end": "<dateTime>", # End Time of layer | "end": "2021-01-01T00:00:00+05:30",
"restrictions": [
{
"type": "<string>", # To restrict shift to certain timings Weekly daily etc | "type": "daily_restriction",
"duration_seconds": "<integer>", # Duration of layer | "duration_seconds": "300"
"start_time_of_day": "<partial-time>", #Start time of layer | "start_time_of_day": "00:00:00",
"start_day_of_week": "<integer>"
}
],
"name": "<string>", # Name to give Layer
}
]
"time_zone": "<activesupport-time-zone>", # Timezone to set for layer and its timings | "time_zone": "Asia/Kolkata",
"type": "schedule",
"name": "<string>", # Name to give Schedule
"description": "<string>",# Description to give Schedule
"id": "<string>", # Auto-generated. Only needed if you want update and existing Schedule Layer
}
}
headers = {
'Authorization': 'Token token=<Your token here>',
'Accept': 'application/vnd.pagerduty+json;version=2',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)
Best way to do this is to get the postman collection for PagerDuty and edit the request as per your liking. Once you get a successful response, convert that into code using the inbuilt feature of postman.
Using PagerDuty API for scheduling is not easy. Creating new schedule is okaish, but if you decide to update schedule - it is definitely not trivial. You'll probably occur bunch of limitation: number of restriction per layer, must reuse current layers, etc.
As option you can use a python library pdscheduling https://github.com/skrypka/pdscheduling

Facebook Marketing API (#2654) Account Request Limits Reached, Sub Error Code:1870024

We've been using Facebook Marketing API v4.0. For an account, I keep getting error below. We cannot find any info about this sub error on Facebook docs. Our client deleted some Custom Audiences in their account but nothing changed.
{"error":
{"message":"(#2654) Account Request Limits Reached: You've reached the total number of times
you can create a Custom Audience through one or more ad accounts in this business.",
"type":"OAuthException",
"code":2654,
"error_subcode":1870024,
"fbtrace_id":"AmN2PwJB8utcYZCXu2y-9TF"}
}
You can check in the Changelog of the v4.0 API under Breaking Changes
- Ads Management here:
Updated the the rate limit for several areas under Marketing API. This includes:
custom_audience - Per each ad account in a one-hour time period:
Standard Tier Apps: Minimum of 190000 + 40 * Number of Active custom audiences. Maximum of 700000.
Dev Tier Apps: Minimum of 5000 + 40 * Number of Active custom audiences. Maximum of 700000.
You can also check the Business Use Case Rate Limits in the header of the response X-Business-Use-Case-Usage as described here, like:
x-business-use-case-usage: {
"{business-object-id}": [
{
"type": "{rate-limit-type}", //Type of BUC rate limit logic being applied.
"call_count": 100, //Percentage of calls made.
"total_cputime": 25, //Percentage of the total CPU time that has been used.
"total_time": 25, //Percentage of the total time that has been used.
"estimated_time_to_regain_access": 19 //Time in minutes to regain access.
}
],
"66782684": [
{
"type": "ads_management",
"call_count": 95,
"total_cputime": 20,
"total_time": 20,
"estimated_time_to_regain_access": 0
}
],
"10153848260347724": [
{
"type": "ads_management",
"call_count": 97,
"total_cputime": 23,
"total_time": 23,
"estimated_time_to_regain_access": 0
}
],
...
}
Hope this help

How use values mode in Orion?

Reading FIWARE-NGSI v2 Specification (http://telefonicaid.github.io/fiware-orion/api/v2/latest/)
In section Simplified Entity Representation
I couldn't test values mode as recomend. My test fail:
values mode. This mode represents the entity as an array of attribute
values. Information about id and type is left out. See example below.
The order of the attributes in the array is specified by the attrs URI
param (e.g. attrs=branch,colour,engine). If attrs is not used, the
order is arbitrary.
[ 'Ford', 'black', 78.3 ]
Where and how I referenced an entityID?
POST /v2/entities/Room1?options=values&attrs=branch,colour,engine
payload:
[ 'Ford', 'black', 78.3 ]
Answer:
{
"error": "MethodNotAllowed",
"description": "method not allowed"
}
POST /v2/entities?options=values
payload:
[ 'Ford', 'black', 78.3 ]
Answer:
{
"error": "ParseError",
"description": "Errors found in incoming JSON buffer"
}
Version:
GET /version
{
"orion": {
"version": "1.10.0-next",
"uptime": "0 d, 0 h, 1 m, 34 s",
"git_hash": "0f92803495a8b6c145547e19f35e8f633dec92e0",
"compile_time": "Fri Feb 2 09:45:41 UTC 2018",
"compiled_by": "root",
"compiled_in": "77ff7f334a88",
"release_date": "Fri Feb 2 09:45:41 UTC 2018",
"doc": "https://fiware-orion.readthedocs.org/en/master/"
}
}
"options=values" is a representation format for querying data not for posting new entity data for obvious reasons, when you are creating new entities you have to specify the entity id and the entity type and with the values representation format you can't ...

Extract value from cloudant IBM Bluemix NoSQL Database

How to Extract value from Cloudant IBM Bluemix NoSQL Database stored in JSON format?
I tried this code
def readDataFrameFromCloudant(host,user,pw,database):
cloudantdata=spark.read.format("com.cloudant.spark"). \
option("cloudant.host",host). \
option("cloudant.username", user). \
option("cloudant.password", pw). \
load(database)
cloudantdata.createOrReplaceTempView("washing")
spark.sql("SELECT * from washing").show()
return cloudantdata
hostname = ""
user = ""
pw = ""
database = "database"
cloudantdata=readDataFrameFromCloudant(hostname, user, pw, database)
It is stored in this format
{
"_id": "31c24a382f3e4d333421fc89ada5361e",
"_rev": "1-8ba1be454fed5b48fa493e9fe97bedae",
"d": {
"count": 9,
"hardness": 72,
"temperature": 85,
"flowrate": 11,
"fluidlevel": "acceptable",
"ts": 1502677759234
}
}
I want this result
Expected
Actual Outcome
Create a dummy dataset for reproducing the issue:
cloudantdata = spark.read.json(sc.parallelize(["""
{
"_id": "31c24a382f3e4d333421fc89ada5361e",
"_rev": "1-8ba1be454fed5b48fa493e9fe97bedae",
"d": {
"count": 9,
"hardness": 72,
"temperature": 85,
"flowrate": 11,
"fluidlevel": "acceptable",
"ts": 1502677759234
}
}
"""]))
cloudantdata.take(1)
Returns:
[Row(_id='31c24a382f3e4d333421fc89ada5361e', _rev='1-8ba1be454fed5b48fa493e9fe97bedae', d=Row(count=9, flowrate=11, fluidlevel='acceptable', hardness=72, temperature=85, ts=1502677759234))]
Now flatten:
flat_df = cloudantdata.select("_id", "_rev", "d.*")
flat_df.take(1)
Returns:
[Row(_id='31c24a382f3e4d333421fc89ada5361e', _rev='1-8ba1be454fed5b48fa493e9fe97bedae', count=9, flowrate=11, fluidlevel='acceptable', hardness=72, temperature=85, ts=1502677759234)]
I tested this code with an IBM Data Science Experience notebook using Python 3.5 (Experimental) with Spark 2.0
This answer is based on: https://stackoverflow.com/a/45694796/1033422

How can I switch on decreasing ttl on OpenFlow switches?

I use Mininet with a custom topology and the RYU-REST controller "ofctl-rest.py". After installing some flowentries in the switches, sending some packets over the network and capturing traffic I recognize that the switches do not decrease the ttl - field in the ip - layer. I figure out that i have to tell the switches to decrease the ttl field (this is possible since OpenFlow - version 1.1). To do so I try the line "type": "DEC_NW_TTL", but it does not work. My compleate command look like this:
curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 3600,
"hard_timeout": 3600,
"priority": 0,
"flags": 1,
"match":{
"in_port": 1
},
"actions":[
{
"type":"OUTPUT",
"port": 4,
"type":"DEC_NW_TTL"
}
]
}' http://localhost:8080/stats/flowentry/add
What do I wrong? How do I have to modify the comand to let the switch reduce ttl? Please help me.
Thank you in advance.
I think you have to specify more than one action. Also you should change the actions' order. First, you need to decrement the TTL and afterwards send it the packet out. Sending the packet first and decrementing afterwards doesn't work.
I would try it this way:
curl -X POST -d '{
"dpid": 1,
"cookie": 1,
"cookie_mask": 1,
"table_id": 0,
"idle_timeout": 3600,
"hard_timeout": 3600,
"priority": 0,
"flags": 1,
"match":{
"in_port": 1
},
"actions":[
{
"type":"DEC_NW_TTL"
},
{
"type":"OUTPUT",
"port": 4
}
]
}' http://localhost:8080/stats/flowentry/add
The answer by Abbadon should work. You should put each action within a pair of brackets. However, the order of different actions in the post request doesn't matter. OpenFlow has its default order for different types of actions.
copy TTL inwards: apply copy TTL inward actions to the packet
pop: apply all tag pop actions to the packet
push-MPLS: apply MPLS tag push action to the packet
push-PBB: apply PBB tag push action to the packet
push-VLAN: apply VLAN tag push action to the packet
copy TTL outwards: apply copy TTL outwards action to the packet
decrement TTL: apply decrement TTL action to the packet
set: apply all set-field actions to the packet
qos: apply all QoS actions, such as set queue to the packet
group: if a group action is specified, apply the actions of the relevant group bucket(s) in the
order specified by this list
output: if no group action is specified, forward the packet on the port specified by the output
action