api updated
This commit is contained in:
parent
1019ebb535
commit
00916c0658
101
server.ts
101
server.ts
@ -56,7 +56,7 @@ BlockchainOutput
|
|||||||
import { universalGetLatestBlockDetails } from "./server/socket";
|
import { universalGetLatestBlockDetails } from "./server/socket";
|
||||||
import { dbConfig } from "./server/ormconfig";
|
import { dbConfig } from "./server/ormconfig";
|
||||||
import { config } from "dotenv";
|
import { config } from "dotenv";
|
||||||
import {latestBlockDetails} from './server/utils';
|
import {latestBlockDetails, Details} from './server/utils';
|
||||||
config({ path: resolve(__dirname, "../.env") });
|
config({ path: resolve(__dirname, "../.env") });
|
||||||
|
|
||||||
// const connectionManager = getConnectionManager();
|
// const connectionManager = getConnectionManager();
|
||||||
@ -144,13 +144,31 @@ try {
|
|||||||
{
|
{
|
||||||
let height = req.query.height;
|
let height = req.query.height;
|
||||||
if(height) {
|
if(height) {
|
||||||
let apiresponse = await request('http://116.203.116.37:3413/v1/blocks/'+height);
|
let heighthash = await Details(height);
|
||||||
result = "Value soon";
|
if(heighthash[0].hash)
|
||||||
|
result = heighthash[0].hash;
|
||||||
|
else
|
||||||
|
result = 'Invalid height';
|
||||||
|
} else if(height <0) {
|
||||||
|
result = '"height" parameter missing or invalid';
|
||||||
} else {
|
} else {
|
||||||
result = '"height" parameter missing or invalid';
|
result = '"height" parameter missing or invalid';
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 21000000;
|
}
|
||||||
|
else if(option == "getblockheight")
|
||||||
|
{
|
||||||
|
let hash = req.query.hash;
|
||||||
|
if(hash) {
|
||||||
|
let heighthash = await Details(hash);
|
||||||
|
if(heighthash[0].height)
|
||||||
|
result = heighthash[0].height;
|
||||||
|
else
|
||||||
|
result = 'Invalid hash';
|
||||||
|
} else {
|
||||||
|
result = '"hash" parameter missing or invalid';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(option == "getblockheight")
|
else if(option == "getblockheight")
|
||||||
result = "";
|
result = "";
|
||||||
@ -158,59 +176,60 @@ try {
|
|||||||
result = 60;
|
result = 60;
|
||||||
else if(option == "info")
|
else if(option == "info")
|
||||||
{
|
{
|
||||||
result = { "Name": "Epic Cash",
|
result = {
|
||||||
"Symbol": "EPIC",
|
"Name": "Epic Cash",
|
||||||
"TotalSupply": 21000000,
|
"Symbol": "EPIC",
|
||||||
"CurrentSupply": blockDetails.coin_existence,
|
"TotalSupply": 21000000,
|
||||||
"FoundationContribution" : blockDetails.foundationReward,
|
"CurrentSupply": blockDetails.coin_existence,
|
||||||
"CurrentBlockReward": blockDetails.userReward,
|
"MinerCurrentBlockReward": blockDetails.userReward,
|
||||||
"Algorithms": "Cuckoo, RandomX, ProgPow",
|
"Algorithms": "Cuckoo, RandomX, ProgPow",
|
||||||
"Target_Difficulty": {
|
"Target_Difficulty": {
|
||||||
"Cuckoo": blockDetails.targetdifficultycuckaroo + blockDetails.targetdifficultycuckatoo,
|
"Cuckoo": blockDetails.targetdifficultycuckaroo + blockDetails.targetdifficultycuckatoo,
|
||||||
"RandomX": blockDetails.targetdifficultyrandomx,
|
"RandomX": blockDetails.targetdifficultyrandomx,
|
||||||
"ProgPow": blockDetails.targetdifficultyprogpow
|
"ProgPow": blockDetails.targetdifficultyprogpow
|
||||||
},
|
},
|
||||||
"Total_Difficulty": {
|
"Total_Difficulty": {
|
||||||
"Cuckoo": blockDetails.TotalCuckoo,
|
"Cuckoo": blockDetails.TotalCuckoo,
|
||||||
"RandomX": blockDetails.TotalDifficultyRandomx,
|
"RandomX": blockDetails.TotalDifficultyRandomx,
|
||||||
"ProgPow": blockDetails.TotalDifficultyProgpow
|
"ProgPow": blockDetails.TotalDifficultyProgpow
|
||||||
},
|
},
|
||||||
"BlockHeight": blockDetails.block_height,
|
"BlockHeight": blockDetails.block_height,
|
||||||
"Blockchain": "MimbleWimble",
|
"Blockchain": "MimbleWimble",
|
||||||
"Homepage": "https://epic.tech",
|
"Homepage": "https://epic.tech",
|
||||||
"Explorer": "https://explorer.epic.tech",
|
"Explorer": "https://explorer.epic.tech",
|
||||||
"API": "https://explorer.epic.tech/api",
|
"API": "https://explorer.epic.tech/api",
|
||||||
"Logo": "https://explorer.epic.tech/assets/img/logo.png",
|
"Logo": "https://explorer.epic.tech/assets/img/logo.png",
|
||||||
"ICO": "NO",
|
"ICO": "NO",
|
||||||
"Premine": "NO",
|
"Premine": "NO",
|
||||||
"Mainnet": "YES",
|
"Mainnet": "YES",
|
||||||
"Genesis": "09-03-2019, 02:09:00 UTC",
|
"Genesis": "09-03-2019, 02:09:00 UTC",
|
||||||
"BlockInterval": 60,
|
"BlockInterval": 60,
|
||||||
"GIT": "https://gitlab.com/epiccash",
|
"GIT": "https://gitlab.com/epiccash",
|
||||||
"Whitepaper":"https://epic.tech/whitepaper",
|
"Whitepaper":"https://epic.tech/whitepaper",
|
||||||
"Colors": { "off-white": "#f3f4f2", "off-black": "#222223", "gold" :"#bf9b30" }
|
"Colors": { "off-white": "#f3f4f2", "off-black": "#222223", "gold" :"#bf9b30" }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result= "Invalid Option";
|
result= "Invalid Option";
|
||||||
|
|
||||||
var type = typeof result;
|
var type = typeof result;
|
||||||
console.log("Type of the result is", type);
|
|
||||||
if (type == "object") {
|
if (type == "object") {
|
||||||
res.status(200).json({...result});
|
res.status(200).json({...result});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.status(200).send(result);
|
res.status(200).json(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let result= 5;
|
//let result= 5;
|
||||||
|
//window.redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(err){
|
catch(err){
|
||||||
res.status(200).send("Internal Server Error");
|
res.status(500).send("Internal Server Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -307,4 +307,33 @@ let currentReward = 16;
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function Details (height) {
|
||||||
|
if(height){
|
||||||
|
|
||||||
|
const BlockchainLatestBlockQuery2 = await getConnection(Global.network)
|
||||||
|
.query(
|
||||||
|
"Select hash, height from blockchain_block Where height =" +height.replace(/[a-z]/gi, '')+" OR hash ='"+height+"'",
|
||||||
|
)
|
||||||
|
.catch(err_msg => {
|
||||||
|
return(err_msg);
|
||||||
|
});
|
||||||
|
return BlockchainLatestBlockQuery2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function GetBlocktime(height){
|
||||||
|
if(height){
|
||||||
|
const BlockchainLatestBlockQuery3 = await getConnection(Global.network)
|
||||||
|
.query(
|
||||||
|
"SELECT height, EXTRACT(EPOCH FROM (timestamp - LAG(timestamp) OVER (ORDER BY timestamp))) AS alter FROM blockchain_block where height="+height,
|
||||||
|
)
|
||||||
|
.catch(err_msg => {
|
||||||
|
return(err_msg);
|
||||||
|
});
|
||||||
|
return BlockchainLatestBlockQuery3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {latestBlockDetails};
|
export {latestBlockDetails};
|
||||||
|
export {Details};
|
0
src/app/view/api-view/api-view.component.css
Normal file
0
src/app/view/api-view/api-view.component.css
Normal file
1
src/app/view/api-view/api-view.component.html
Normal file
1
src/app/view/api-view/api-view.component.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<p>api-view works!</p>
|
25
src/app/view/api-view/api-view.component.spec.ts
Normal file
25
src/app/view/api-view/api-view.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ApiViewComponent } from './api-view.component';
|
||||||
|
|
||||||
|
describe('ApiViewComponent', () => {
|
||||||
|
let component: ApiViewComponent;
|
||||||
|
let fixture: ComponentFixture<ApiViewComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ApiViewComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ApiViewComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
15
src/app/view/api-view/api-view.component.ts
Normal file
15
src/app/view/api-view/api-view.component.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-api-view',
|
||||||
|
templateUrl: './api-view.component.html',
|
||||||
|
styleUrls: ['./api-view.component.css']
|
||||||
|
})
|
||||||
|
export class ApiViewComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
|
|||||||
import { Routes, RouterModule } from '@angular/router';
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
import { HomeLayoutComponent } from '../shared/components/layouts/home-layout/home-layout.component';
|
import { HomeLayoutComponent } from '../shared/components/layouts/home-layout/home-layout.component';
|
||||||
import { SiteLayoutComponent } from '../shared/components/layouts/site-layout/site-layout.component';
|
import { SiteLayoutComponent } from '../shared/components/layouts/site-layout/site-layout.component';
|
||||||
|
import { ApiViewComponent } from '../view/api-view/api-view.component';
|
||||||
const viewRoutes: Routes = [
|
const viewRoutes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@ -35,6 +35,10 @@ const siteRoutes: Routes = [
|
|||||||
title: 'Epic Explorer',
|
title: 'Epic Explorer',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'api-view',
|
||||||
|
component: ApiViewComponent
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
|
@ -9,10 +9,11 @@ import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
|
|||||||
import { TransServiceService } from '../shared/services/trans-service.service';
|
import { TransServiceService } from '../shared/services/trans-service.service';
|
||||||
import { ChartService} from '../shared/services/chart.service';
|
import { ChartService} from '../shared/services/chart.service';
|
||||||
import { CustomLoader } from '../app.module';
|
import { CustomLoader } from '../app.module';
|
||||||
|
import { ApiViewComponent } from './api-view/api-view.component';
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [],
|
declarations: [ApiViewComponent],
|
||||||
imports: [CommonModule, ViewRoutingModule, SharedModule,
|
imports: [CommonModule, ViewRoutingModule, SharedModule,
|
||||||
TranslateModule.forChild({
|
TranslateModule.forChild({
|
||||||
loader: {provide: TranslateLoader, useClass: CustomLoader, deps : [HttpClient]},
|
loader: {provide: TranslateLoader, useClass: CustomLoader, deps : [HttpClient]},
|
||||||
|
@ -190,7 +190,7 @@ a:focus {
|
|||||||
.headerbg {
|
.headerbg {
|
||||||
background: url(/assets/img/body_bg.png);
|
background: url(/assets/img/body_bg.png);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
background-position-y: -22%;}
|
||||||
.body_bg {
|
.body_bg {
|
||||||
background: url(/assets/img/body_bg.png);
|
background: url(/assets/img/body_bg.png);
|
||||||
background-position-y: -22%;
|
background-position-y: -22%;
|
||||||
@ -567,7 +567,7 @@ body.dark_theme {
|
|||||||
}
|
}
|
||||||
.dark_theme .body_bg {
|
.dark_theme .body_bg {
|
||||||
background: url(/assets/img/dark_bg1.png);
|
background: url(/assets/img/dark_bg1.png);
|
||||||
background-position-y: -22%;
|
/* background-position-y: -22%; */
|
||||||
}
|
}
|
||||||
.dark_theme .logo_txt,
|
.dark_theme .logo_txt,
|
||||||
.dark_theme .ip_filter a {
|
.dark_theme .ip_filter a {
|
||||||
|
Loading…
Reference in New Issue
Block a user