Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: refactor eth block confirm * refactor: refactor ckbHandler block confirm * fix: fix eth init right bound of getLogs * fix: fix code merge * fix: add limit to confirm * fix: fix bug * chore: close typeorm log * fix: fix eth getLogs bound * fix: fix updateCkbBurnConfirmStatus * fix: fix watchNewBlock miss await bug Co-authored-by: wangbing <wangbing@cryptape.com>
- Loading branch information
1 parent
10cdd02
commit d6f248c
Showing
13 changed files
with
522 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Column, PrimaryGeneratedColumn, Entity, Index } from 'typeorm'; | ||
|
||
@Entity() | ||
export class KV { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Index({ unique: true }) | ||
@Column() | ||
key: string; | ||
|
||
@Column() | ||
value: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './ckb'; | ||
export * from './eth'; | ||
export * from './tron'; | ||
export * from './btc'; | ||
export * from './eos'; | ||
export * from './kv'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Connection, Repository } from 'typeorm'; | ||
import { KV } from './entity/kv'; | ||
|
||
export class KVDb { | ||
private kvDb: Repository<KV>; | ||
constructor(private connection: Connection) { | ||
this.kvDb = connection.getRepository(KV); | ||
} | ||
async get(key: string): Promise<string | undefined> { | ||
const records = await this.kvDb.find({ | ||
where: { | ||
key, | ||
}, | ||
take: 1, | ||
}); | ||
if (!records || records.length === 0) { | ||
return undefined; | ||
} | ||
return records[0].value; | ||
} | ||
|
||
async set(key: string, value: string) { | ||
return this.connection | ||
.createQueryBuilder() | ||
.insert() | ||
.into(KV) | ||
.values({ key: key, value: value }) | ||
.orUpdate({ conflict_target: ['key'], overwrite: ['value'] }) | ||
.execute(); | ||
} | ||
} |
Oops, something went wrong.