Db0031 - added blockchain tx tracking
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Swarmops.Database
|
||||
/// </summary>
|
||||
public static int DbVersionExpected
|
||||
{
|
||||
get { return 30; }
|
||||
get { return 31; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,3 +28,4 @@
|
||||
0028 - Bugfix for 0027 [RF]
|
||||
0029 - Added unspent satoshis to hotaddress on create unspent [RF]
|
||||
0030 - Added flexibility for Resolver classes for OutboundComms [RF]
|
||||
0031 - Added foreign ID tables, procs for transactions, to track blockchain [RF]
|
||||
@@ -0,0 +1,49 @@
|
||||
CREATE TABLE `FinancialTransactionForeignIds` (
|
||||
`FinancialTransactionForeignIdId` INT NOT NULL AUTO_INCREMENT,
|
||||
`FinancialTransactionId` INT NOT NULL,
|
||||
`ForeignIdType` INT NOT NULL,
|
||||
`ForeignId` VARCHAR(256) NOT NULL,
|
||||
PRIMARY KEY (`FinancialTransactionForeignIdId`),
|
||||
INDEX `Ix_TxId` (`FinancialTransactionId` ASC),
|
||||
INDEX `Ix_IdType` (`ForeignIdType` ASC),
|
||||
INDEX `Ix_Identifier` (`ForeignId` ASC)
|
||||
)
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
DROP procedure IF EXISTS `SetFinancialTransactionForeignIdentity`
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetFinancialTransactionForeignIdentity`(
|
||||
IN financialTransactionId INT,
|
||||
IN foreignIdType INT,
|
||||
IN foreignId VARCHAR(256)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
IF ((SELECT COUNT(*) FROM FinancialTransactionForeignIds
|
||||
WHERE FinancialTransactionForeignIds.FinancialTransactionId=financialTransactionId
|
||||
AND FinancialTransactionForeignIds.ForeignIdType=foreignIdType) = 0)
|
||||
THEN
|
||||
|
||||
INSERT INTO FinancialTransactionForeignIds (FinancialTransactionId,ForeignIdType,ForeignId)
|
||||
VALUES (financialTransactionId,foreignIdType,foreignId);
|
||||
SELECT LAST_INSERT_ID() AS Identity;
|
||||
|
||||
ELSE
|
||||
|
||||
UPDATE FinancialTransactionForeignIds
|
||||
SET FinancialTransactionForeignId.ForeignId=foreignId
|
||||
WHERE FinancialTransactionForeignIds.FinancialTransactionId=financialTransactionId
|
||||
AND FinancialTransactionForeignIds.ForeignIdType=foreignIdType;
|
||||
|
||||
SELECT 0 AS Identity;
|
||||
|
||||
END IF;
|
||||
|
||||
END
|
||||
Reference in New Issue
Block a user