public bool TryAddHeader(ChainedHeader header)
{
CheckWriteTransaction();
try
{
using (SetSessionContext())
using (var jetUpdate = this.jetSession.BeginUpdate(this.headersTableId, JET_prep.Insert))
{
Api.SetColumns(this.jetSession, this.headersTableId,
new BytesColumnValue { Columnid = this.headerBlockHashColumnId, Value = DbEncoder.EncodeUInt256(header.Hash) },
new BytesColumnValue { Columnid = this.headerBytesColumnId, Value = DataEncoder.EncodeChainedHeader(header) });
jetUpdate.Save();
}
return true;
}
catch (EsentKeyDuplicateException)
{
return false;
}
}