From bf6521b385ef60102f8f820a149b94c134604a6f Mon Sep 17 00:00:00 2001 From: astaphobia Date: Wed, 26 Feb 2020 16:01:35 +0800 Subject: [PATCH 1/3] no need to validate current block height --- common/transaction/sendMoney.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/transaction/sendMoney.go b/common/transaction/sendMoney.go index 3c2ca882c..d10ff5a1b 100644 --- a/common/transaction/sendMoney.go +++ b/common/transaction/sendMoney.go @@ -292,7 +292,6 @@ Escrow Part func (tx *SendMoney) EscrowValidate(dbTx bool) error { var ( accountBalance model.AccountBalance - block *model.Block err error row *sql.Row ) @@ -310,14 +309,6 @@ func (tx *SendMoney) EscrowValidate(dbTx bool) error { return blocker.NewBlocker(blocker.ValidationErr, "RecipientAddressRequired") } - block, err = util.GetLastBlock(tx.QueryExecutor, tx.BlockQuery) - if err != nil { - return blocker.NewBlocker(blocker.ValidationErr, err.Error()) - } - if uint64(block.GetHeight()) >= tx.Escrow.GetTimeout() { - return blocker.NewBlocker(blocker.ValidationErr, "TransactionExpired") - } - // todo: this is temporary solution, later we should depend on coinbase, so no genesis transaction exclusion in // validation needed if tx.SenderAddress != constant.MainchainGenesisAccountAddress { From d49dd2af93273840979cb021ebdb5f638005e417 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Thu, 27 Feb 2020 15:22:40 +0800 Subject: [PATCH 2/3] set index into some tables for speed up latency get a lot of records --- common/database/migration.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/database/migration.go b/common/database/migration.go index 388a63180..c9182a3ed 100644 --- a/common/database/migration.go +++ b/common/database/migration.go @@ -304,6 +304,15 @@ func (m *Migration) Init() error { PRIMARY KEY("multisig_address", "block_height") ) `, + ` + CREATE INDEX "node_registry_height_idx" ON "node_registry" ("height") + `, + ` + CREATE INDEX "skipped_blocksmith_block_height_idx" ON "skipped_blocksmith" ("block_height") + `, + ` + CREATE INDEX "published_receipt_block_height_idx" ON "published_receipt" ("block_height") + `, } return nil } @@ -341,12 +350,14 @@ func (m *Migration) Apply() error { return err } if m.CurrentVersion != nil { + *m.CurrentVersion++ err = m.Query.ExecuteTransaction(`UPDATE "migration" - SET "version" = ?, "created_date" = datetime('now');`, *m.CurrentVersion+1) + SET "version" = ?, "created_date" = datetime('now');`, m.CurrentVersion) if err != nil { return err } } else { + m.CurrentVersion = &version // should 0 value not nil anymore err = m.Query.ExecuteTransaction(` INSERT INTO "migration" ( "version", @@ -362,8 +373,8 @@ func (m *Migration) Apply() error { } } - m.CurrentVersion = &version err = m.Query.CommitTx() + fmt.Println(*m.CurrentVersion) if err != nil { return err } From 8339c6ef885b230e0ab7f22144ce036e9a59ced9 Mon Sep 17 00:00:00 2001 From: astaphobia Date: Thu, 27 Feb 2020 15:24:44 +0800 Subject: [PATCH 3/3] remove unused a line of codes --- common/database/migration.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/database/migration.go b/common/database/migration.go index c9182a3ed..671dc436f 100644 --- a/common/database/migration.go +++ b/common/database/migration.go @@ -374,7 +374,6 @@ func (m *Migration) Apply() error { } err = m.Query.CommitTx() - fmt.Println(*m.CurrentVersion) if err != nil { return err }