Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed Sep 3, 2021
1 parent 560370c commit 2b08b0c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 62 deletions.
14 changes: 0 additions & 14 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2151,8 +2151,6 @@ impl Blockstore {
Ok(())
}

<<<<<<< HEAD
=======
pub fn read_transaction_memos(&self, signature: Signature) -> Result<Option<String>> {
self.transaction_memos_cf.get(signature)
}
Expand All @@ -2161,18 +2159,6 @@ impl Blockstore {
self.transaction_memos_cf.put(*signature, &memos)
}

fn check_lowest_cleanup_slot(&self, slot: Slot) -> Result<std::sync::RwLockReadGuard<Slot>> {
// lowest_cleanup_slot is the last slot that was not cleaned up by LedgerCleanupService
let lowest_cleanup_slot = self.lowest_cleanup_slot.read().unwrap();
if *lowest_cleanup_slot > 0 && *lowest_cleanup_slot >= slot {
return Err(BlockstoreError::SlotCleanedUp);
}
// Make caller hold this lock properly; otherwise LedgerCleanupService can purge/compact
// needed slots here at any given moment
Ok(lowest_cleanup_slot)
}

>>>>>>> 5fa3e5744 (Populate memo in blockstore signatures-for-address (#19515))
fn ensure_lowest_cleanup_slot(&self) -> (std::sync::RwLockReadGuard<Slot>, Slot) {
// Ensures consistent result by using lowest_cleanup_slot as the lower bound
// for reading columns that do not employ strong read consistency with slot-based
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl TransactionStatusService {

if let Some(memos) = extract_and_fmt_memos(transaction.message()) {
blockstore
.write_transaction_memos(transaction.signature(), memos)
.write_transaction_memos(&transaction.signatures[0], memos)
.expect("Expect database write to succeed: TransactionMemos");
}

Expand Down
50 changes: 3 additions & 47 deletions transaction-status/src/extract_memos.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use {
crate::parse_instruction::parse_memo_data,
solana_sdk::{
message::{Message, SanitizedMessage},
pubkey::Pubkey,
},
solana_sdk::{message::Message, pubkey::Pubkey},
};

// A helper function to convert spl_memo::v1::id() as spl_sdk::pubkey::Pubkey to
Expand Down Expand Up @@ -54,30 +51,11 @@ impl ExtractMemos for Message {
}
}

impl ExtractMemos for SanitizedMessage {
fn extract_memos(&self) -> Vec<String> {
let mut memos = vec![];
if self
.account_keys_iter()
.any(|&pubkey| pubkey == spl_memo_id_v1() || pubkey == spl_memo_id_v3())
{
for (program_id, instruction) in self.program_instructions_iter() {
maybe_push_parsed_memo(&mut memos, *program_id, &instruction.data);
}
}
memos
}
}

#[cfg(test)]
mod test {
use {
super::*,
solana_sdk::{
hash::Hash,
instruction::CompiledInstruction,
message::{v0, MappedAddresses, MappedMessage, MessageHeader},
},
solana_sdk::{hash::Hash, instruction::CompiledInstruction},
};

#[test]
Expand Down Expand Up @@ -118,30 +96,8 @@ mod test {
spl_memo_id_v3(),
],
Hash::default(),
memo_instructions.clone(),
memo_instructions,
);
assert_eq!(message.extract_memos(), expected_memos);

let sanitized_message = SanitizedMessage::Legacy(message);
assert_eq!(sanitized_message.extract_memos(), expected_memos);

let mapped_message = MappedMessage {
message: v0::Message {
header: MessageHeader {
num_required_signatures: 1,
num_readonly_signed_accounts: 0,
num_readonly_unsigned_accounts: 3,
},
account_keys: vec![fee_payer],
instructions: memo_instructions,
..v0::Message::default()
},
mapped_addresses: MappedAddresses {
writable: vec![],
readonly: vec![spl_memo_id_v1(), another_program_id, spl_memo_id_v3()],
},
};
let sanitized_mapped_message = SanitizedMessage::V0(mapped_message);
assert_eq!(sanitized_mapped_message.extract_memos(), expected_memos);
}
}

0 comments on commit 2b08b0c

Please sign in to comment.