storeMerkleProof abstract method

Future<void> storeMerkleProof(
  1. String txid,
  2. MerkleProof proof
)

Store merkle proof for a transaction.

Proofs are never deleted (audit bead libspiffy-mny). A transaction has one row per block its proofs name, plus rows without a block hash for proofs whose header was not known (told apart by their merkleProof). At most one row per txid is current (MerkleProof.isCurrent: verified or pendingHeader): the transaction's current proof.

Storing proof:

  • updates the row with the same (txid, block hash); else the row with no block hash and the same merkleProof (a MerkleProofStatus.pendingHeader proof whose header arrived); else, when proof has no block hash, a row with the same merkleProof (keeping that row's block hash); otherwise it adds a row. A MerkleProofStatus.rejected proof is stored without a block hash and only ever updates a row that has none (bead libspiffy-azl);
  • when proof is current, marks every other current row of txid orphaned (the transaction was mined again in another block): proof becomes the current proof;
  • when proof is orphaned or rejected, leaves the current proof alone.

A row keeps its first createdAt; statusChangedAt moves when its status changes (MerkleProof.statusChangedAt, default now).

Implementation

Future<void> storeMerkleProof(String txid, MerkleProof proof);