SECDataBase
This package uses leveldb to store and handle data from SEC blockchain, this repository includes operations to four databases:
- Token Block Chain Database
- Token Tx Database
- Transaction Block Chain Database
- Transaction Tx Database
- Account Database
- Product Database
The databases contain following methods:
TokenBlockChainDB
Kind: global class
-
TokenBlockChainDB
- new TokenBlockChainDB(config)
-
.writeTokenBlockToDB(tokenData, callback) ⇒
None
-
.isTokenBlockChainDBEmpty(callback) ⇒
None
-
.getTokenBlockChainDB(callback) ⇒
None
-
.getTokenBlockFromDB(blockHashArray, callback) ⇒
None
-
.getTokenChain(minBlockNumber, maxBlockNumber, callback) ⇒
None
-
.delBlocksFromHeight(blockHeight, callback) ⇒
None
-
.addUpdateBlock(pos, blockArray, callback) ⇒
None
-
.findTxForUser(userAddress, callback) ⇒
None
-
.findTx(userAddress, callback) ⇒
None
TxBlockChainDB
Kind: global class
-
TxBlockChainDB
- new TxBlockChainDB(config)
-
.writeTxBlockToDB(txData, callback) ⇒
None
-
.isTxBlockChainDBEmpty(callback) ⇒
None
-
.getTxBlockChainDB(callback) ⇒
None
-
.getTxBlockFromDB(blockHashArray, callback) ⇒
None
-
.getTxChain(minBlockNumber, maxBlockNumber, callback) ⇒
None
-
.delBlocksFromHeight(blockHeight, callback) ⇒
None
-
.addUpdateBlock(pos, blockArray, callback) ⇒
None
-
.findTxForUser(userAddress, callback) ⇒
None
AccountDB
Kind: global class
-
AccountDB
- new AccountDB(config)
-
.writeUserInfoToAccountDB(accDataList, callback) ⇒
None
-
.readUserInfofromAccountDB(accNameList) ⇒
Promise Object
-
.isAccountDBEmpty(callback) ⇒
None
-
.getAccountDB(callback) ⇒
None
-
.isAccountInAccountDB(accName, callback) ⇒
None
ProductDB
Kind: global class
TokenBlockChainDB Methods
new TokenBlockChainDB(config)
Param | Type | Description |
---|---|---|
config | Object |
contains the relative path for storing database |
None
tokenBlockChainDB.writeTokenBlockToDB(tokenData, callback) ⇒ Write single token block or full token chain data to database
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
tokenData | Array, Object |
single token block data or full token block chain data |
callback | function |
callback function, returns error if exist |
None
tokenBlockChainDB.isTokenBlockChainDBEmpty(callback) ⇒ Check whether the token block chain database is empty
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, emptyFlag) |
None
tokenBlockChainDB.getTokenBlockChainDB(callback) ⇒ Get all the block datas from token block chain database
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, block object array) |
None
tokenBlockChainDB.getTokenBlockFromDB(blockHashArray, callback) ⇒ Get token blocks according to block hash values
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
blockHashArray | String, Array |
block hash values, string or array format |
callback | function |
callback function, callback arguments (err, block object array) |
None
tokenBlockChainDB.getTokenChain(minBlockNumber, maxBlockNumber, callback) ⇒ Get token block chain data, from number 'minBlockNumber' to number 'maxBlockNumber'
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
minBlockNumber | Integer |
minimum block number |
maxBlockNumber | Integer |
maximum block number |
callback | function |
callback function, callback arguments (err, block object array) |
None
tokenBlockChainDB.delBlocksFromHeight(blockHeight, callback) ⇒ Delete blocks which have a higher height than the input 'blockHeight' argument
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
blockHeight | Integer |
blocks with larger height will be deleted from database |
callback | function |
callback function, callback arguments (err) |
None
tokenBlockChainDB.addUpdateBlock(pos, blockArray, callback) ⇒ Add new blocks from a specific position if the blocks does not exist
Update old blocks from a specific position if the blocks already exist
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
pos | Integer |
block add/update starting position |
blockArray | Array |
array of block data(json object) |
callback | function |
callback function, callback arguments (err) |
None
tokenBlockChainDB.findTxForUser(userAddress, callback) ⇒ Find all previous transactions for a user
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
userAddress | String |
user account address |
callback | function |
callback function, callback arguments (txArray, err) |
None
tokenBlockChainDB.findTx(txHash, callback) ⇒ Find a previous transactions for a user by transaction hash
Kind: instance method of TokenBlockChainDB
Param | Type | Description |
---|---|---|
txHash | String |
transaction hash |
callback | function |
callback function, callback arguments (txArray, err) |
TxBlockChainDB Methods
new TxBlockChainDB(config)
Param | Type | Description |
---|---|---|
config | Object |
contains the relative path for storing database |
None
txBlockChainDB.writeTxBlockToDB(txData, callback) ⇒ Write single tx block or full transaction chain data to database
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
txData | Array, Object |
single tx block data or full transaction block chain data |
callback | function |
callback function, returns error if exist |
None
txBlockChainDB.isTxBlockChainDBEmpty(callback) ⇒ Check whether the transaction block chain database is empty
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, emptyFlag) |
None
txBlockChainDB.getTxBlockChainDB(callback) ⇒ Get all the block datas from transaction block chain database
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, block object array) |
None
txBlockChainDB.getTxBlockFromDB(blockHashArray, callback) ⇒ Get transaction blocks according to block hash values
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
blockHashArray | String, Array |
block hash values, string or array format |
callback | function |
callback function, callback arguments (err, block object array) |
None
txBlockChainDB.getTxChain(minBlockNumber, maxBlockNumber, callback) ⇒ Get transaction block chain data, from number 'minBlockNumber' to number 'maxBlockNumber'
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
minBlockNumber | Integer |
minimum block number |
maxBlockNumber | Integer |
maximum block number |
callback | function |
callback function, callback arguments (err, block object array) |
None
txBlockChainDB.delBlocksFromHeight(blockHeight, callback) ⇒ Delete blocks which have a higher height than the input 'blockHeight' argument
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
blockHeight | Integer |
blocks with larger height will be deleted from database |
callback | function |
callback function, callback arguments (err) |
None
txBlockChainDB.addUpdateBlock(pos, blockArray, callback) ⇒ Add new blocks from a specific position if the blocks does not exist
Update old blocks from a specific position if the blocks already exist
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
pos | Integer |
block add/update starting position |
blockArray | Array |
array of block data(json object) |
callback | function |
callback function, callback arguments (err) |
None
TxBlockChainDB.findTxForUser(userAddress, callback) ⇒ Find all previous transactions for a user
Kind: instance method of TxBlockChainDB
Param | Type | Description |
---|---|---|
userAddress | String |
user account address |
callback | function |
callback function, callback arguments (txArray, err) |
AccountDB Methods
new AccountDB(config)
Param | Type | Description |
---|---|---|
config | Object |
contains the relative path for storing database |
None
accountDB.writeUserInfoToAccountDB(accDataList, callback) ⇒ Write user account information to account database
Kind: instance method of AccountDB
Param | Type | Description |
---|---|---|
accDataList | Array, Object |
single user account info(json object) or a list of user account info |
callback | function |
callback function, returns error if exist |
Promise Object
accountDB.readUserInfofromAccountDB(accNameList) ⇒ Read user account information from account database, returns a promise object
Kind: instance method of AccountDB
Param | Type | Description |
---|---|---|
accNameList | Array, String |
single user account address(string) or a list of user account addresses |
None
accountDB.isAccountDBEmpty(callback) ⇒ Check whether the account database is empty
Kind: instance method of AccountDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, emptyFlag) |
None
accountDB.getAccountDB(callback) ⇒ Get all the data in account database
Kind: instance method of AccountDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, block object array) |
None
accountDB.isAccountInAccountDB(accName, callback) ⇒ Check whether an account is in AccountDB
Kind: instance method of AccountDB
Param | Type | Description |
---|---|---|
accName | String |
account name |
callback | function |
callback function, callback arguments (err, block object array) |
ProductDB Methods
new ProductDB(config)
Param | Type | Description |
---|---|---|
config | Object |
contains the relative path for storing database |
None
productDB.writeTxBlockToDB(txData, callback) ⇒ Write single transaction block or full transaction chain data to product database
Kind: instance method of ProductDB
Param | Type | Description |
---|---|---|
txData | Array, Object |
single tx block data or full transaction block chain data |
callback | function |
callback function, returns error if exist |
None
productDB.isProductDBEmpty(callback) ⇒ Check whether the product database is empty
Kind: instance method of ProductDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, emptyFlag) |
None
productDB.getProductDB(callback) ⇒ Get all the data in product database
Kind: instance method of ProductDB
Param | Type | Description |
---|---|---|
callback | function |
callback function, callback arguments (err, block object array) |