How to get transaction date having it's hash at hand? - avalanche

I'm trying to figure out how to get the time when the transaction was included in block by it's hash on the P-Chain.
I looked into getTx method but the response doesn't include this information:
{
unsignedTx: {
networkID: 5,
blockchainID: '11111111111111111111111111111111LpoYY',
outputs: [],
inputs: [ [Object] ],
memo: '0x44656c656761746564207769746820466967656d6e74277320536c61746520415049',
validator: {
nodeID: 'NodeID-4B4rc5vdD1758JSBYL1xyvE5NHGzz6xzH',
start: 1658162594,
end: 1658252280,
weight: 1000000000
},
stake: [ [Object] ],
rewardsOwner: { addresses: [Array], locktime: 0, threshold: 1 }
},
credentials: [ { signatures: [Array] } ]
}

Related

How to send a query from appsync-simulator to dynamodb-local

I created a table and seed with dynamodb-local
But I can't get the item from the dynamodb-local table with appsync-simulator
{
"data": null,
"errors": [
{
"message": "Cannot return null for non-nullable field Query.getPerson.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"getPerson"
]
}
]
}
Am I misconfiguring serverless.ts?
//dynamodb-local
dynamodb: {
stages: [
"dev",
],
start: {
port: 8000,
inMemory: true,
migrate: true,
seed: true,
},
//seed
seed: {
deb: {
sources: [
{
table: "patients",
sources: ["./src/migrations/patients.json"]
}
]
}
}
},
//appsync-simulator
"appsync-simulator": {
location: ".esbuild",
apiKey: "da2-fakeApiId123456",
watch: false,
dynamoDb: {
endpoint: "http://localhost:8000",
},
},
Modules version
"serverless-appsync-plugin": "^1.13.0",
"serverless-appsync-simulator": "^0.20.0",
"serverless-dynamodb-local": "^0.2.40",
"serverless-offline": "^8.8.0",
"serverless": "^3.0.0",

I Couldn't change HTTP headers in a NextJS project

As explained in the NextJs documentation: https://nextjs.org/docs/api-reference/next.config.js/headers , it is possible to configure the HTTP headers of a page using the code below, however my code is not working.
Next Example:
module.exports = {
async headers() {
return [
{
source: '/about',
headers: [
{
key: 'x-custom-header',
value: 'my custom header value',
},
{
key: 'x-another-custom-header',
value: 'my other custom header value',
},
],
},
]
},
}
My Code:
module.exports = {
async headers() {
return [
{
source: '/about',
headers: [
{
key: 'cache-control',
value: 'max-age=31536000',
},
],
},
]
},
}

Change the default serilization in gremlin server to use GraphSON V1

I'm trying to change the output format of the Gremlin http server to a Non typed JSON object like the one below.
{
"requestId": "320599c8-7d49-4cc6-87a6-42115009f90c",
"status": {
"message": "",
"code": 200,
"attributes": {}
},
"result": {
"data": [
{
"info": [
{
"total_seen": [
2845
],
"first_seen": [
1501568446000
],
"last_seen": [
1580157081000
],
"value": [
"http://test.com"
]
}
]
}
],
"meta": {}
}
}
But the response i get from the server is a typed one
{
"requestId": "e8621470-7ee7-4f6b-a8ea-1d49c85093c8",
"status": {
"message": "",
"code": 200,
"attributes": {
"#type": "g:Map",
"#value": []
}
},
"result": {
"data": {
"#type": "g:List",
"#value": [
{
"#type": "g:Map",
"#value": [
"info",
{
"#type": "g:List",
"#value": [
{
"#type": "g:Map",
"#value": [
"total_seen",
{
"#type": "g:List",
"#value": [
{
"#type": "g:Int32",
"#value": 2797
}
]
},
"first_seen",
{
"#type": "g:List",
"#value": [
{
"#type": "g:Int64",
"#value": 1501568446000
}
]
},
"last_seen",
{
"#type": "g:List",
"#value": [
{
"#type": "g:Int64",
"#value": 1578774368000
}
]
},
"vertex_type",
{
"#type": "g:List",
"#value": [
"url"
]
},
"url_value",
{
"#type": "g:List",
"#value": [
"http://test.com"
]
}
]
}
]
}
]
}
]
},
"meta": {
"#type": "g:Map",
"#value": []
}
}
}
I tried changing the settings in gremlin-server.yaml by commenting GraphSON V2 and V3
# Copyright 2019 JanusGraph Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
host: 127.0.0.1
port: 8182
scriptEvaluationTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
graph: conf/gremlin-server/janusgraph-cassandra-es-server.properties
}
scriptEngines: {
gremlin-groovy: {
plugins: { org.janusgraph.graphdb.tinkerpop.plugin.JanusGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/empty-sample.groovy]}}}}
serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
# - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
# Older serialization versions for backwards compatibility:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
# - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
processors:
- { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
- { className: org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor, config: { cacheExpirationTime: 600000, cacheMaxSize: 1000 }}
metrics: {
consoleReporter: {enabled: true, interval: 180000},
csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
jmxReporter: {enabled: true},
slf4jReporter: {enabled: true, interval: 180000},
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
graphiteReporter: {enabled: false, interval: 180000}}
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
Ii would be greatful if someone can tell me what i'm doing wrong here. Thanks.
The server log output might be showing the error that points you to the problem but my guess is that you're trying to connect with a driver serializer configuration that isn't getting recognized by the server and it therefore defaults to GraphSON 3.0 serialization. That change happened a long time ago, way back on TINKERPOP-1565 for the 3.3.0 release.
When we started pushing GraphSON 3.0 we wanted it to be the default JSON based network serialization format, so we gave it the "application/json" mime type which formerly went to untyped GraphSON 1.0. So, you need a bit of a custom configuration to make the driver and server recognized what you want to have happen:
gremlin> cluster = Cluster.build().serializer(new GraphSONMessageSerializerV1d0()).create()
==>localhost/127.0.0.1:8182
gremlin> client = cluster.connect()
==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient#277b8fa4
gremlin> x = client.submit("[1,2,3]").all().get()
==>result{object=1 class=java.lang.Integer}
==>result{object=2 class=java.lang.Integer}
==>result{object=3 class=java.lang.Integer}
You can see that you have to explicitly build the GraphSONMessageSerializerV1d0 (and in your case you would likely add the JanusGraphIoRegistry manually to that by using the constructor that takes a GraphSONMapper.
All that said, while GraphSON 1.0 isn't going anywhere it's curious that you would need to utilize it directly. Unless you have a really good reason to do so, I'd highly recommend that you stick to GraphSON 3.0. It has the widest support among graph providers is about as fast as Gryo these days for most serialization operations. If you're exclusively on the JVM, I'd even suggest trying GraphBinary rather than going back to GraphSON 1.0.

PartialShardFailureException when trying to filter by GeoDistance (foselasticaBundle Symfony2)

For a few days my elastica query doesn't work anymore. I don't have problem to populate and if i remove the GeoDistance part the request is been executed and i get results. Currently, in the trace, I got the following message:
"message": "1",
"class": "Elastica\\Exception\\PartialShardFailureException",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/Applications/MAMP/htdocs/GTAB/what2days/api/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php",
"line": 150,
"args": []
}
It means nothing to me so I just made a var_export of $shardsStatistics variable and I get that:
array (
'total' => 6,
'successful' => 5,
'failed' => 1,
'failures' =>
array (
0 =>
array (
'index' => '.marvel-2014.09.16',
'shard' => 0,
'status' => 400,
'reason' => 'SearchParseException[[.marvel-2014.09.16][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"online":{"value":1}}}]}},"filter":{"bool":{"must":[{"geo_distance":{"distance":"100mi","location.latlon":{"lat":48.891773,"lon":2.3379156}}}]}}}}}},"size":"100"}]]]; nested: QueryParsingException[[.marvel-2014.09.16] failed to find geo_point field [location.latlon]]; ',
),
),
)
The error finish by " failed to find geo_point field [location.latlon]] ". I don't know why it doesn't work because when i check the _mapping the geo_point exists and i didn't make a mistake with the name of the property.
location: {
properties: {
latitude: {
type: "float",
store: true
},
latlon: {
type: "geo_point",
store: true,
lat_lon: true
},
longitude: {
type: "float",
store: true
}
}
},
And this is the way i set fos_elastica
fos_elastica:
clients:
default: { host: localhost, port: 9200 }
indexes:
search:
finder: ~
types:
mytype:
mappings:
title:
type: string
online:
type: integer
information: ~
location:
type: object
properties:
longitude:
type: float
latlon:
type: geo_point
lat_lon: true
boost: 10
persistence:
driver: orm
model: API\Rest\v1\MyBundle\Entity\MyEntity
provider: ~
listener: ~
finder: ~
repository: API\Rest\v1\MyBundle\Repository\MyRepository
When i make a kopf request with the query value (see following query) retrieved by $query->getQuery() i get a correct result.
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"online": {
"value": 1
}
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"geo_distance": {
"distance": "1mi",
"location.latlon": {
"lat": 48.891773,
"lon": 2.3379156
}
}
}
]
}
}
}
}
}
I don't know what to do. I was on 3.0.*#alpha version and now I'm trying the dev-master. I hope someone will help me find what goes wrong.
When I make a var_export in the method getData from Elastica/Response.php I have the failure I explained earlier and I also have 1 hit (the one Iwant to get).
I finally found the solution.
I had to add an index_name and tell \Elastica\Search to addIndex('new_index') and addType('specific type')
I thought the search will automatically get the correct index because I was using a specific repository but I was wrong.

Sencha Touch belongsTo association using Store on Datalist

I want to get belongsTo record on datalist and show parent record fields.
Ext.define('MyApp.model.Customer', {
extend: 'Ext.data.Model',
config: {
fields: ['Id',
'EMail'],
hasMany: [{
model: 'MyApp.model.OutstandingInvoice',
name: 'OutstandingInvoice',
primaryKey: 'Id',
foreignKey: 'customerId',
foreignStore: 'OutstandingInvoices'
}]
}
});
Ext.define('MyApp.model.OutstandingInvoice', {
extend: 'Ext.data.Model',
config: {
fields: [
'InvoiceDate',
'InvoiceID',
'customerId'
],
belongsTo: [{
model: 'MyApp.model.Customer',
name: 'Customer',
primaryKey: 'Id',
foreignKey: 'customerId',
foreignStore: 'Customers'
}]
}
});
Ext.define('MyApp.store.OutstandingInvoices', {
extend: 'Ext.data.Store',
config: {
model: 'MyApp.model.OutstandingInvoice',
storeId: 'OutstandingInvoiceStore',
proxy: {
useDefaultXhrHeader: false,
type: 'ajax',
url : 'http://localhost/getOutstandingInvoices',
reader: {
type: 'json'
}
},
autoLoad: false
}
});
Ext.define('MyApp.store.Customers', {
extend: 'Ext.data.Store',
config: {
model: 'MyApp.model.Customer',
storeId: 'CustomerStore',
proxy: {
useDefaultXhrHeader: false,
type: 'ajax',
url : 'http://localhost/getCustJList',
reader: {
type: 'json'
}
},
autoLoad: false,
sorters: [{
property : 'FName',
direction: 'ASC'
}]
}
});
Ext.define('MyApp.view.OutstandingInvoices', {
extend: 'Ext.Panel',
xtype: 'outstandingInvoicesXType',
config: {
cls : 'invoiceSummaryCls',
scrollable: 'vertical',
items: [
{
xtype: 'titlebar',
docked: 'top',
title: 'Outstanding Invoices'
},
{
xtype : 'list',
scrollable: false,
store: 'OutstandingInvoiceStore',
cls : 'p10',
itemTpl: [
'<div>Invoice # {InvoiceID}</div>',
'<div>{InvoiceDate}</div>',
'<div>{Customer.Email}</div>', // I want to show Customer name here as its belongsTo Customer
],
listeners: {
itemtap:function (list, index, targe, rec, e, eOpts) {
console.log(rec)
}
}
}
]
}
});
I want to show Customer name in datalist but having issue with association or Xtemplate
I am getting this error
Uncaught Error: [ERROR][Ext.XTemplate#apply] Cannot read property 'Email' of undefined
Please help me out in this.
I'd recommend reading this article, its quite lengthy but the final List section is similar to your example.
I think the key point is you're not going to need separate stores. Sencha is going to create those automatically off the back of the associations. Make sure you move the proxies onto the models and set autoLoad: true

Resources