Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into 2536-revamp-blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanisorn Thongprapaisaeng committed Aug 25, 2020
2 parents 9cf3865 + 0173329 commit 6f0140c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Emitter & Flusher

- (impv) [\#2549](https://github.com/bandprotocol/bandchain/pull/2549) Implemented `data_source_requests` table
- (feat) [\#2551](https://github.com/bandprotocol/bandchain/pull/2551) fast-sync: add flag enable fast sync and emit all account and validator

### Scan
Expand All @@ -24,7 +25,7 @@
- (impv) [\#2557](https://github.com/bandprotocol/bandchain/pull/2557) Fix and clean up copy button
- (impv) [\#2552](https://github.com/bandprotocol/bandchain/pull/2552) Wire up related data source, handle nullable timestamp
- (impv) [\#2550](https://github.com/bandprotocol/bandchain/pull/2550) Polish request index page
- (bugs) [\#2527](https://github.com/bandprotocol/bandchain/pull/2527) Fix serach bugs on ds & os home page
- (bugs) [\#2527](https://github.com/bandprotocol/bandchain/pull/2527) Fix search bugs on ds & os home page
- (impv) [\#2516](https://github.com/bandprotocol/bandchain/pull/2516) Fix loading width and bg color
- (impv) [\#2499](https://github.com/bandprotocol/bandchain/pull/2499) Implemented Total request chart
- (impv) [\#2455](https://github.com/bandprotocol/bandchain/pull/2455) Implement full copy non evm proof
Expand Down
2 changes: 1 addition & 1 deletion chain/emitter/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (app *App) InitChain(req abci.RequestInitChain) abci.ResponseInitChain {
app.emitSetDataSource(types.DataSourceID(idx+1), ds, nil)
}
for idx, os := range oracleState.OracleScripts {
app.emitNewOracleScript(types.OracleScriptID(idx+1), os, nil)
app.emitSetOracleScript(types.OracleScriptID(idx+1), os, nil)
}
app.FlushMessages()
return res
Expand Down
15 changes: 1 addition & 14 deletions chain/emitter/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,6 @@ func (app *App) emitSetDataSource(id types.DataSourceID, ds types.DataSource, tx
})
}

func (app *App) emitNewOracleScript(id types.OracleScriptID, os types.OracleScript, txHash []byte) {
app.Write("NEW_ORACLE_SCRIPT", JsDict{
"id": id,
"name": os.Name,
"description": os.Description,
"owner": os.Owner.String(),
"schema": os.Schema,
"codehash": os.Filename,
"source_code_url": os.SourceCodeURL,
"tx_hash": txHash,
})
}

func (app *App) emitSetOracleScript(id types.OracleScriptID, os types.OracleScript, txHash []byte) {
app.Write("SET_ORACLE_SCRIPT", JsDict{
"id": id,
Expand Down Expand Up @@ -135,7 +122,7 @@ func (app *App) handleMsgCreateOracleScript(
) {
id := types.OracleScriptID(atoi(evMap[types.EventTypeCreateOracleScript+"."+types.AttributeKeyID][0]))
os := app.BandApp.OracleKeeper.MustGetOracleScript(app.DeliverContext, id)
app.emitNewOracleScript(id, os, txHash)
app.emitSetOracleScript(id, os, txHash)
extra["id"] = id
}

Expand Down
7 changes: 7 additions & 0 deletions flusher/flusher/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ def Column(*args, **kwargs):
Column("timestamp", CustomDateTime, primary_key=True),
)

data_source_requests = sa.Table(
"data_source_requests",
metadata,
Column("data_source_id", sa.Integer, sa.ForeignKey("data_sources.id"), primary_key=True),
Column("count", sa.Integer),
)

oracle_script_requests = sa.Table(
"oracle_script_requests",
metadata,
Expand Down
25 changes: 19 additions & 6 deletions flusher/flusher/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
reporters,
related_data_source_oracle_scripts,
historical_oracle_statuses,
data_source_requests,
oracle_script_requests,
request_count_per_days,
)
Expand Down Expand Up @@ -90,10 +91,11 @@ def handle_set_data_source(self, msg):
.values(**msg)
.on_conflict_do_update(constraint="data_sources_pkey", set_=msg)
)

def handle_new_oracle_script(self, msg):
self.handle_set_oracle_script(msg)
self.handle_new_oracle_script_request({"oracle_script_id": msg["id"], "count": 0})
self.conn.execute(
insert(data_source_requests)
.values({"data_source_id": msg["id"], "count": 0})
.on_conflict_do_nothing(constraint="data_source_requests_pkey")
)

def handle_set_oracle_script(self, msg):
if msg["tx_hash"] is not None:
Expand All @@ -106,6 +108,11 @@ def handle_set_oracle_script(self, msg):
.values(**msg)
.on_conflict_do_update(constraint="oracle_scripts_pkey", set_=msg)
)
self.conn.execute(
insert(oracle_script_requests)
.values({"oracle_script_id": msg["id"], "count": 0})
.on_conflict_do_nothing(constraint="oracle_script_requests_pkey")
)

def handle_new_request(self, msg):
msg["transaction_id"] = self.get_transaction_id(msg["tx_hash"])
Expand Down Expand Up @@ -138,6 +145,7 @@ def handle_new_raw_request(self, msg):
}
)
self.conn.execute(raw_requests.insert(), msg)
self.handle_set_data_source_request({"data_source_id": msg["data_source_id"]})

def handle_new_val_request(self, msg):
msg["validator_id"] = self.get_validator_id(msg["validator"])
Expand Down Expand Up @@ -309,8 +317,13 @@ def handle_set_historical_validator_status(self, msg):
.on_conflict_do_update(constraint="historical_oracle_statuses_pkey", set_=msg)
)

def handle_new_oracle_script_request(self, msg):
self.conn.execute(oracle_script_requests.insert(), msg)
def handle_set_data_source_request(self, msg):
condition = True
for col in data_source_requests.primary_key.columns.values():
condition = (col == msg[col.name]) & condition
self.conn.execute(
data_source_requests.update(condition).values(count=data_source_requests.c.count + 1)
)

def handle_set_oracle_script_request(self, msg):
condition = True
Expand Down
2 changes: 1 addition & 1 deletion scan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@glennsl/bs-jest": "^0.5.1",
"bs-platform": "^7.0.1",
"bsb-js": "^1.1.7",
"css-loader": "^4.2.1",
"css-loader": "^4.2.2",
"html-webpack-plugin": "^4.3.0",
"parcel-bundler": "^1.12.4",
"style-loader": "^1.2.1",
Expand Down
9 changes: 4 additions & 5 deletions scan/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3339,16 +3339,15 @@ css-declaration-sorter@^4.0.1:
postcss "^7.0.1"
timsort "^0.3.0"

css-loader@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-4.2.1.tgz#9f48fd7eae1219d629a3f085ba9a9102ca1141a7"
integrity sha512-MoqmF1if7Z0pZIEXA4ZF9PgtCXxWbfzfJM+3p+OYfhcrwcqhaCRb74DSnfzRl7e024xEiCRn5hCvfUbTf2sgFA==
css-loader@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-4.2.2.tgz#b668b3488d566dc22ebcf9425c5f254a05808c89"
integrity sha512-omVGsTkZPVwVRpckeUnLshPp12KsmMSLqYxs12+RzM9jRR5Y+Idn/tBffjXRvOE+qW7if24cuceFJqYR5FmGBg==
dependencies:
camelcase "^6.0.0"
cssesc "^3.0.0"
icss-utils "^4.1.1"
loader-utils "^2.0.0"
normalize-path "^3.0.0"
postcss "^7.0.32"
postcss-modules-extract-imports "^2.0.0"
postcss-modules-local-by-default "^3.0.3"
Expand Down

0 comments on commit 6f0140c

Please sign in to comment.